#include amxmodx #include reapi native entity_set_model(ent, const model[]) native zp_get_user_zombie(id) native zp_get_user_ammo_packs(id) native zp_set_user_ammo_packs(id, ammount) native zp_has_round_ended() native zp_has_round_started() #define BOX_MODEL_01 "models/box/mysterybox_T.mdl" #define BOX_MODEL_02 "models/box/mysterybox_CT.mdl" #define BOX_SOUND "box/box_pickup.wav" #define ENTITY_NAME "mystery_box" #define TIME_REMOVE_ENT 10.0 #define MAX_BOXES 16 new g_limit = 0 new bool:g_Speed[33], bool:g_Gravity[33], g_Jumps[33], g_JumpsNum[33], BoxesNum public plugin_init() { register_plugin("[ZP] Mystery Box", "2.5", "sNk_DarK") RegisterHookChain(RG_CBasePlayer_Killed, "RG_PlayerDeath") RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "RG_Reset_SpeedGravity") RegisterHookChain(RG_CBasePlayer_Jump, "RG_PlayerJump") register_event("HLTV", "RoundStart", "a", "1=0", "2=0") } public plugin_precache() { precache_model(BOX_MODEL_01) precache_model(BOX_MODEL_02) precache_sound(BOX_SOUND) } public RG_PlayerDeath(victim) { if (!is_user_connected(victim)) return g_Speed[victim] = false g_Gravity[victim] = false g_JumpsNum[victim] = 0 if (g_limit != 0) if (BoxesNum >= MAX_BOXES) return CreateBox(victim) } CreateBox(victim) { if (!zp_has_round_started() || zp_has_round_ended()) return //if (!is_user_connected(victim)) return new box = rg_create_entity("info_target") if (is_nullent(box)) return new Float:origin[3] get_entvar(victim, var_origin, origin) set_entvar(box, var_classname, ENTITY_NAME) if (zp_get_user_zombie(victim)) { entity_set_model(box, BOX_MODEL_02) set_entvar(box, var_rendercolor, Float:{135.0, 206.0, 250.0}) } else { entity_set_model(box, BOX_MODEL_01) set_entvar(box, var_rendercolor, Float:{255.0, 99.0, 71.0}) } set_entvar(box, var_origin, origin) set_entvar(box, var_solid, SOLID_TRIGGER) set_entvar(box, var_movetype, MOVETYPE_TOSS) set_entvar(box, var_animtime, get_gametime()) set_entvar(box, var_framerate, 1.0) set_entvar(box, var_nextthink, get_gametime() + TIME_REMOVE_ENT) set_entvar(box, var_rendermode, 0) set_entvar(box, var_renderamt, 120.0) set_entvar(box, var_renderfx, 19) new Float:mins[3] = {-8.0, -8.0, -18.0} new Float:maxs[3] = {8.0, 8.0, 18.0} SetEntSize(box, mins, maxs) if (g_limit != 0) BoxesNum++ SetTouch(box, "Touch_MysteryBox") SetThink(box, "Think_MysteryBox") } public Think_MysteryBox(ent) { if (is_nullent(ent)) return SetThink(ent, "") SetTouch(ent, "") rg_remove_entity(ent) } public Touch_MysteryBox(ent, other) { if (is_nullent(ent) || !is_user_alive(other)) return new random_item = random_num(0, 5) switch (random_item) { case 0: { if (zp_get_user_zombie(other)) { client_print_color(other, other, "You got^4 ++Health") if (Float:get_entvar(other, var_health) + 450.0 <= 7500.0) set_entvar(other, var_health, Float:get_entvar(other, var_health) + 450.0) } else { client_print_color(other, other, "You got^4 ++Armor") if (rg_get_user_armor(other) + 30 <= 300) rg_set_user_armor(other, rg_get_user_armor(other) + 30, ARMOR_NONE) } } case 1: { zp_set_user_ammo_packs(other, zp_get_user_ammo_packs(other) + 25) client_print_color(other, other, "You got^4 ++Ammo Packs") } case 2: { if (g_JumpsNum[other] == 1) client_print_color(other, other, "Sorry, you already have^3 Double Jump^1, try next box...") else { g_JumpsNum[other]++ client_print_color(other, other, "You got^4 ++Jumps") } } case 3: { if (g_Speed[other]) client_print_color(other, other, "Sorry, you already have^3 Speed^1, try next box...") else { g_Speed[other] = true RG_Reset_SpeedGravity(other) client_print_color(other, other, "You got^4 ++Speed") } } case 4: { if (g_Gravity[other]) client_print_color(other, other, "Sorry, you already have^3 Gravity^1, try next box...") else { g_Gravity[other] = true RG_Reset_SpeedGravity(other) client_print_color(other, other, "You got^4 ++Gravity") } } case 5: client_print_color(other, other, "You got^4 Nothing^1, try next box") } emit_sound(other, CHAN_VOICE, BOX_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM) rg_remove_entity(ent) } public RG_Reset_SpeedGravity(id) { if (!is_user_alive(id)) return 0 new bool:speed = false if (g_Speed[id] && Float:get_entvar(id, var_maxspeed) < 280.0) { speed = true set_entvar(id, var_maxspeed, 280.0) } if (g_Gravity[id] && Float:get_entvar(id, var_gravity) > 0.4) set_entvar(id, var_gravity, 0.4) return speed ? 1 : 0 } public RG_PlayerJump(id) { if (!is_user_alive(id)) return // ZP 6.2 Jumps if (g_JumpsNum[id]) { new nbut = get_entvar(id, var_button) new obut = get_entvar(id, var_oldbuttons) if ((nbut & IN_JUMP) && !(get_entvar(id, var_flags) & FL_ONGROUND) && !(obut & IN_JUMP) && g_Jumps[id] <= g_JumpsNum[id] - 1) { static Float:fVelocity[3] get_entvar(id, var_velocity, fVelocity) fVelocity[2] = random_float(265.0, 285.0) set_entvar(id, var_velocity, fVelocity) g_Jumps[id]++ } if ((nbut & IN_JUMP) && (get_entvar(id, var_flags) & FL_ONGROUND)) g_Jumps[id] = 0 } } public RoundStart() { new maxPlayers = get_maxplayers() for (new i = 1; i <= maxPlayers; i++) { if (is_user_connected(i)) { g_Speed[i] = false g_Gravity[i] = false g_JumpsNum[i] = 0 } } BoxesNum = 0 new ent = -1 while ((ent = rg_find_ent_by_class(ent, ENTITY_NAME)) != 0) { SetTouch(ent, "") SetThink(ent, "") rg_remove_entity(ent) } } public client_putinserver(id) { g_Speed[id] = false g_Gravity[id] = false g_JumpsNum[id] = 0 } public client_disconnected(id) { g_Speed[id] = false g_Gravity[id] = false g_JumpsNum[id] = 0 } SetEntSize(ent, Float:mins[3], Float:maxs[3]) { new Float:size[3] size[0] = maxs[0] - mins[0] size[1] = maxs[1] - mins[1] size[2] = maxs[2] - mins[2] set_entvar(ent, var_size, size) }