Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <engine>
- #include <fakemeta>
- #include <fun>
- #include <ColorChat>
- #include <codmod>
- #define MIN 1
- #define MAX 6
- new const chatPrefix[] = "^x04[^x01PACK^x04]^x01";
- new const itemModel[] = "models/cod_paczka.mdl";
- new const healthValues[] =
- {
- 10,
- 20,
- 30,
- 40,
- 50
- }
- new const coinsValues[] =
- {
- 21,
- 42,
- 53,
- 64,
- 75
- }
- new const expValues[] =
- {
- 144,
- 244,
- 344,
- 444,
- 544
- }
- public plugin_init()
- {
- register_plugin("COD: Pack Bonuses", "1.0", "radim");
- register_event("DeathMsg", "deathMessage", "a");
- register_logevent("roundStart", 2, "1=Round_Start");
- }
- public plugin_precache()
- {
- precache_model(itemModel);
- }
- public roundStart()
- {
- kill_all_entity("packes");
- }
- public deathMessage()
- {
- new killer = read_data(1),
- victim = read_data(2);
- if(killer == victim || !is_user_connected(killer) || !is_user_connected(victim))
- {
- return PLUGIN_CONTINUE;
- }
- create_itm(victim, 0);
- return PLUGIN_CONTINUE;
- }
- public usePackes(index)
- {
- if(!is_user_alive(index))
- {
- return PLUGIN_HANDLED;
- }
- new randomCase = random_num(MIN, MAX);
- switch(randomCase)
- {
- case 1:
- {
- new randomHealth = healthValues[random_num(0, sizeof(healthValues) - 1)];
- set_user_health(index, get_user_health(index) - randomHealth);
- ColorChat(index, NORMAL, "%sZnalazles trucizne.. Tracisz %i HP", chatPrefix, randomHealth);
- }
- case 2:
- {
- new randomHealth = healthValues[random_num(0, sizeof(healthValues) - 1)];
- set_user_health(index, get_user_health(index) + randomHealth);
- ColorChat(index, NORMAL, "Znalazles apteczke.. Dostajesz %i HP", chatPrefix, randomHealth);
- }
- case 3:
- {
- new randomCoins = coinsValues[random_num(0, sizeof(coinsValues) - 1)];
- cod_set_user_coins(index, cod_get_user_coins(index) + randomCoins);
- ColorChat(index, NORMAL, "W paczce znalazles kilka monet (%i)", chatPrefix, randomCoins)
- }
- case 4:
- {
- new randomCoins = coinsValues[random_num(0, sizeof(coinsValues) - 1)];
- if(cod_get_user_coins(index) - randomCoins < 0)
- {
- ColorChat(index, NORMAL, "Ktos probowal cie okrasc, ale nie masz hajsu ;-;", chatPrefix);
- return PLUGIN_HANDLED
- }
- cod_set_user_coins(index, cod_get_user_coins(index) - randomCoins);
- ColorChat(index, NORMAL, "Ktos Cie okradl z %i monet :O", chatPrefix, randomCoins)
- }
- case 5:
- {
- new randomExp = expValues[random_num(0, sizeof(expValues) - 1)]
- if(cod_get_user_xp(index) - randomExp < 0)
- {
- ColorChat(index, NORMAL, "... %i", chatPrefix, randomExp);
- return PLUGIN_HANDLED
- }
- }
- case 6:
- {
- new randomExp = expValues[random_num(0, sizeof(expValues) - 1)]
- cod_set_user_xp(index, cod_get_user_xp(index) + randomExp);
- ColorChat(index, NORMAL, "W paczce znalazles dodatkowe %i EXP'a!", chatPrefix, randomExp);
- }
- }
- return PLUGIN_HANDLED;
- }
- public create_itm(index, index_item)
- {
- new Float:origins[3],
- entit = create_entity("info_target");
- pev(index, pev_origin, origins);
- origins[0] += 50.0;
- origins[2] -= 32.0;
- set_pev(entit, pev_origin, origins);
- entity_set_model(entit, itemModel);
- set_pev(entit, pev_classname, "paczka");
- dllfunc(DLLFunc_Spawn, entit);
- set_pev(entit, pev_solid, SOLID_BBOX);
- set_pev(entit, pev_movetype, MOVETYPE_FLY);
- engfunc(EngFunc_SetSize, entit,
- {-1.1, -1.1, -1.1},
- {1.1, 1.1, 1.1}
- );
- engfunc(EngFunc_DropToFloor, entit);
- set_pev(entit, pev_iuser1, index_item);
- }
- public fwd_touch(ent, index)
- {
- static classname[32];
- pev(ent, pev_classname, classname, charsmax(classname));
- if(!is_user_alive(index))
- {
- return FMRES_IGNORED;
- }
- if(!pev_valid(ent))
- {
- return FMRES_IGNORED;
- }
- if(!equali(classname, "packes"))
- {
- return FMRES_IGNORED;
- }
- if(pev(index, pev_button))
- {
- usePackes(index);
- engfunc(EngFunc_RemoveEntity, ent);
- }
- return FMRES_IGNORED;
- }
- public kill_all_entity(classname[])
- {
- new iEnt = find_ent_by_class(-1, classname)
- while(iEnt > 0)
- {
- remove_entity(iEnt)
- iEnt = find_ent_by_class(iEnt, classname);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement