Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <engine>
- #include <superspawns>
- #include <dhudmessage>
- #include <fun>
- #include <cstrike>
- native get_user_cash( const index );
- native set_user_cash( const index, cash );
- new const gszSupply[] = "Top/JB/spawnbox1";
- new const gszSupplyModel[] = "models/Top/JB/FindBox.mdl"
- new RoundTime, g_iSprite, cvar_spawnchance
- public plugin_init()
- {
- register_plugin("spawnbox", "v1.0", "@,TheBomB`");
- register_logevent("round_start", 2, "1=Round_Start");
- register_logevent("round_end", 2, "1=Round_End");
- register_touch(gszSupply, "player", "FwdTouchSupply")
- cvar_spawnchance = register_cvar("supply_spawnchance","50")
- RoundTime = get_cvar_pointer("mp_roundtime");
- SsInit(0.0)
- SsScan()
- SsDump()
- }
- public round_start()
- {
- if (random_num(1, 100) <= get_pcvar_num(cvar_spawnchance))
- {
- new Float:randomTime = random_float(0.0, get_pcvar_float(RoundTime) * 60.0 - 30.0);
- if (!task_exists())
- set_task(randomTime, "DoSomething");
- else
- change_task(_, randomTime);
- }
- }
- public round_end()
- {
- remove_task()
- new ent = find_ent_by_class(-1, gszSupply);
- if(is_valid_ent(ent)) remove_entity(ent);
- }
- public plugin_precache()
- {
- precache_model(gszSupplyModel)
- precache_sound("Top/JB/spawnbox1.wav")
- g_iSprite = precache_model ( "sprites/white.spr" )
- }
- public DoSomething()
- {
- new Float:vOrigin[3]
- if(SsGetOrigin(vOrigin))
- {
- new iSupply = create_entity("info_target")
- if(!is_valid_ent(iSupply)) return PLUGIN_CONTINUE
- entity_set_string(iSupply, EV_SZ_classname, gszSupply)
- entity_set_int(iSupply, EV_INT_solid, SOLID_TRIGGER)
- entity_set_vector(iSupply, EV_VEC_origin, vOrigin)
- entity_set_model(iSupply, gszSupplyModel)
- drop_to_floor(iSupply)
- MakeSprite()
- emit_sound( 0 ,CHAN_ITEM, "Top/JB/spawnbox1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM )
- set_dhudmessage(255, 0, 0, -1.0, 0.02, 0, 1.0, 4.0, 0.1, 3.5)
- show_dhudmessage( 0, "The Suprise Box have spawned find it and get Cash!")
- ColorChat(0,"The ^3Suprise Box ^1have spawned find it and ^4get Cash^1!");
- }
- return PLUGIN_CONTINUE;
- }
- public MakeSprite()
- {
- new Float:Origin[ 3 ]
- new iSupply = find_ent_by_class(-1, gszSupply);
- entity_get_vector( iSupply, EV_VEC_origin, Origin );
- engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, Origin, 0);
- write_byte ( TE_BEAMCYLINDER )
- engfunc( EngFunc_WriteCoord, Origin[ 0 ] );
- engfunc( EngFunc_WriteCoord, Origin[ 1 ] );
- engfunc( EngFunc_WriteCoord, Origin[ 2 ] );
- engfunc( EngFunc_WriteCoord, Origin[ 0 ] );
- engfunc( EngFunc_WriteCoord, Origin[ 1 ] );
- engfunc( EngFunc_WriteCoord, Origin[ 2 ] + 140 );
- write_short ( g_iSprite )
- write_byte ( 0 )
- write_byte ( 1 )
- write_byte ( 8 )
- write_byte ( 10 )
- write_byte ( 1 )
- write_byte ( 60 )
- write_byte ( 30 )
- write_byte ( 255 )
- write_byte ( 255 )
- write_byte ( 0 )
- message_end ( )
- set_task( 1.0, "MakeSprite")
- }
- public FwdTouchSupply(iEntity, iPlayer)
- {
- if (cs_get_user_team(iPlayer) == CS_TEAM_T)
- {
- new szName[32]; get_user_name(iPlayer, szName, 31)
- remove_task()
- emit_sound(iPlayer, CHAN_STATIC, "buttons/latchunlocked2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
- remove_entity(iEntity)
- new g_num = random_num(1, 3);
- if(g_num <= 1)
- {
- set_user_cash( iPlayer, get_user_cash( iPlayer ) + 5000 )
- ColorChat(0,"^3%s ^1has recived^4 5000 ^1cash from ^3Suprise Box",szName);
- return PLUGIN_HANDLED;
- }
- if(g_num <= 2)
- {
- set_user_cash( iPlayer, get_user_cash( iPlayer ) + 10000 )
- ColorChat(0,"^3%s ^1has recived^4 10000 ^1cash from ^3Suprise Box",szName);
- return PLUGIN_HANDLED;
- }
- if(g_num <= 3)
- {
- set_user_cash( iPlayer, get_user_cash( iPlayer ) + 15000 )
- ColorChat(0,"^3%s ^1has recived^4 15000 ^1cash from ^3Suprise Box",szName);
- return PLUGIN_HANDLED;
- }
- }
- return PLUGIN_HANDLED;
- }
- stock ColorChat(index, const Msg[], {Float, Sql, Result,_}:...) {
- new Buffer[190], Buffer2[192]
- formatex(Buffer2, sizeof(Buffer2)-1, "^4[^1 Cyber ^4]^1 %s", Msg)
- vformat(Buffer, sizeof(Buffer)-1, Buffer2, 3)
- if(!index) {
- for (new i = 1; i <= get_maxplayers(); i++)
- {
- if(!is_user_connected(i))
- continue
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, i)
- write_byte(i)
- write_string(Buffer)
- message_end()
- }
- }
- else
- {
- if(!is_user_connected(index))
- return
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, index)
- write_byte(index)
- write_string(Buffer)
- message_end()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement