/* Plugin generated by AMXX-Studio */ #include #include #include #include #include #include #define PLUGIN "[ZP] Addon : Zombie Loots" #define VERSION "1.0.0" #define AUTHOR "Kia" // =============================================================================== // Editing begins here // =============================================================================== // Prefix for Messages #define LOOT_PREFIX "[Zombie Loots]" // Time in Seconds how long a player has "to loot" a dead body. #define LOOT_TIME 6.5 // Time in Seconds how long a dead body can be looted #define LOOT_EXISTENCE 25.0 // Size in Units how big the Dummy Entity is #define LOOT_SIZE 35.0 // Radius to search for dead players #define LOOT_RADIUS 2.0 // Chance in percent to recieve a loot #define LOOT_CHANCE 50.0 // Maximum amount of Ammo Packs you can get #define LOOT_MAX_AMMO 12 // =============================================================================== // and stops here. DO NOT MODIFY BELOW UNLESS YOU KNOW WHAT YOU'RE DOING // =============================================================================== // =============================================================================== // Variables // =============================================================================== /* Defines */ #define TASK_ID_LOOT 8452 #define TASK_ID_REMOVE 8453 /* Booleans */ new bool:g_bIsLooting[33] new bool:g_bIsUsing[33] // =============================================================================== // plugin_init // =============================================================================== public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) /* Logevents */ register_logevent("LogEvent_RoundStart", 2, "1=Round_Start") /* Hamsandwich */ RegisterHam(Ham_Killed, "player", "Ham_PlayerDiedPre", 1 ); } // =============================================================================== // client_putinserver - Called when someone joins the game // =============================================================================== public client_putinserver(id) { g_bIsLooting[id] = false g_bIsUsing[id] = false } // =============================================================================== // client_disconnect - Called when someone leaves the game // =============================================================================== public client_disconnect(id) { g_bIsLooting[id] = false g_bIsUsing[id] = false } // =============================================================================== // LogEvent_RoundEnd - Called when a round ends // =============================================================================== public LogEvent_RoundStart() { new iEnt, iTotal iTotal = entity_count() new szClassname[33] for(iEnt = 0; iEnt <= iTotal; iEnt++) { if(!is_valid_ent(iEnt)) continue; entity_get_string(iEnt, EV_SZ_classname, szClassname, charsmax(szClassname)) if(equali(szClassname,"dead_player")) remove_entity(iEnt) } } // =============================================================================== // Ham_PlayerPreThink - Called veeeeery often. // =============================================================================== public client_PreThink(id) { g_bIsUsing[id] = (pev(id, pev_button) & IN_USE) ? true : false new Float:flPlayerOrigin[3] pev(id, pev_origin, flPlayerOrigin) new iEntitys[32], iEnt, iNum = find_sphere_class(id, "dead_player", LOOT_RADIUS, iEntitys, charsmax(iEntitys), flPlayerOrigin) new iParamArray[2] if(iNum && g_bIsUsing[id] && !zp_get_user_zombie(id)) { if(g_bIsLooting[id]) return PLUGIN_HANDLED_MAIN g_bIsLooting[id] = true for(--iNum; iNum >= 0; iNum--) { iEnt = iEntitys[iNum] iParamArray[0] = TASK_ID_LOOT + id iParamArray[1] = iEnt set_task(LOOT_TIME, "Gameplay_GiveLoot", TASK_ID_LOOT + id, iParamArray, sizeof(iParamArray)) create_loading_bar(id, LOOT_TIME) client_print(id, print_center, "Looting...") } } else if (!iNum || !g_bIsUsing[id] || zp_get_user_zombie(id)) { if(task_exists(TASK_ID_LOOT + id)) { eliminate_loading_bar(id) remove_task(TASK_ID_LOOT + id) g_bIsLooting[id] = false } } return PLUGIN_HANDLED_MAIN } // =============================================================================== // Gameplay_GiveLoot - Gives the player his loot // =============================================================================== public Gameplay_GiveLoot(iParamArray[]) { new id = iParamArray[0] - TASK_ID_LOOT new iEnt = iParamArray[1] if(!g_bIsLooting[id] || !get_user_chance(LOOT_CHANCE)) return PLUGIN_HANDLED remove_entity(iEnt) new iReward = random_num(1, LOOT_MAX_AMMO) zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + iReward) print_color(id, id, 0, "^x04%s ^x01You recieved ^x03%i^x01 Ammo Packs from the dead body.", LOOT_PREFIX, iReward) remove_entity(iEnt) g_bIsLooting[id] = false return PLUGIN_HANDLED } // =============================================================================== // Ham_PlayerDiedPre - Called when a player dies // =============================================================================== public Ham_PlayerDiedPre( iVictim, iKiller, bShouldGib ) { if(zp_get_user_zombie(iVictim)) { new iOrigin[3] get_user_origin(iVictim, iOrigin) new Float:flOrigin[3] flOrigin[0] = float(iOrigin[0]) flOrigin[1] = float(iOrigin[1]) flOrigin[2] = float(iOrigin[2]) create_dummy_entity(flOrigin) } } // =============================================================================== // Stocks // =============================================================================== stock create_dummy_entity(Float:flOrigin[3]) { new Ent = create_entity("info_target") entity_set_string(Ent, EV_SZ_classname, "dead_player") entity_set_int(Ent, EV_INT_solid, SOLID_TRIGGER) entity_set_size(Ent, Float:{-LOOT_SIZE,-LOOT_SIZE,-LOOT_SIZE}, Float:{LOOT_SIZE,LOOT_SIZE,LOOT_SIZE}) entity_set_origin(Ent, flOrigin) } stock create_loading_bar(id, Float:flTime = 0.0) { if( flTime < -0.0 ) { return } static BarTime2 = 0 if( !BarTime2 ) { BarTime2 = get_user_msgid("BarTime2") } new iSeconds = floatround(flTime, floatround_ceil) message_begin(MSG_ONE, BarTime2, .player=id) write_short(iSeconds) write_short( 100 - floatround( (flTime/ iSeconds ) * 100 ) ) message_end() } stock eliminate_loading_bar(id) { static BarTime2 = 0 if( !BarTime2 ) { BarTime2 = get_user_msgid("BarTime2") } message_begin(MSG_ONE, BarTime2, .player=id) write_short(0) write_short(0) message_end() } stock bool:get_user_chance(Float:flPercent) { new Float:flTheChance = random_float(0.0, 100.0) if(flTheChance >= 100.0 - flPercent) return true else return false return false } // =============================================================================== // ColorChat // =============================================================================== public print_color(id, cid, color, const message[], any:...) { new msg[192] vformat(msg, charsmax(msg), message, 5) /* //if you want to use ML, enable replace_all(msg, charsmax(msg), "!g", "^x04") replace_all(msg, charsmax(msg), "!n", "^x01") replace_all(msg, charsmax(msg), "!t", "^x03")*/ new param if (!cid) return else param = cid new team[32] get_user_team(param, team, 31) switch (color) { case 0: msg_teaminfo(param, team) case 1: msg_teaminfo(param, "TERRORIST") case 2: msg_teaminfo(param, "CT") case 3: msg_teaminfo(param, "SPECTATOR") } if (id) msg_saytext(id, param, msg) else msg_saytext(0, param, msg) if (color != 0) msg_teaminfo(param, team) } msg_saytext(id, cid, msg[]) { message_begin(id?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, id) write_byte(cid) write_string(msg) message_end() } msg_teaminfo(id, team[]) { message_begin(MSG_ONE, get_user_msgid("TeamInfo"), {0,0,0}, id) write_byte(id) write_string(team) message_end() } /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par } */