Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <nvault>
- #include <cstrike>
- #include <colorchat>
- #include <engine>
- #define PLUGIN "Knife System"
- #define VERSION "1.1"
- #define AUTHOR "Pićunak"
- #define HUD 1
- new trenutni_model_noza[33];
- new ubistva_igraca[33];
- new osvojeno_nozeva[33];
- new g_vault;
- new SyncHudObj;
- new const PodaciNozeva[][][] =
- {
- //Naziv Ubistva "View" model "Player" model
- {"Default", "0", "models/v_knife.mdl", "models/p_knife.mdl"},
- {"Machete", "10", "models/knife-system/v_machete.mdl", "models/knife-system/p_machete.mdl"},
- {"Back", "20", "models/knife-system/v_back.mdl", "models/knife-system/p_back.mdl"},
- {"Pocket", "30", "models/knife-system/v_pocket.mdl", "models/knife-system/p_pocket.mdl"},
- {"Butcher", "40", "models/knife-system/v_butcher.mdl", "models/knife-system/p_butcher.mdl"},
- {"Wooden", "50", "models/knife-system/v_wooden.mdl", "models/knife-system/p_wooden.mdl"},
- {"Dragon", "60", "models/knife-system/v_dragon.mdl", "models/knife-system/p_dragon.mdl"},
- {"Ninja", "70", "models/knife-system/v_ninja.mdl", "models/knife-system/p_ninja.mdl"},
- {"Black", "80", "models/knife-system/v_black.mdl", "models/knife-system/p_black.mdl"},
- {"Hitman", "90", "models/knife-system/v_hitman.mdl", "models/knife-system/p_hitman.mdl"},
- {"Daedric", "100", "models/knife-system/v_daedric.mdl", "models/knife-system/p_daedric.mdl"},
- {"Ice", "150", "models/knife-system/v_ice.mdl", "models/knife-system/p_ice.mdl"},
- {"Katane", "200", "models/knife-system/v_katana.mdl", "models/knife-system/p_katana.mdl"},
- {"Rusty", "250", "models/knife-system/v_rusty.mdl", "models/knife-system/p_rusty.mdl"},
- {"Crowbar", "300", "models/knife-system/v_crowbar.mdl", "models/knife-system/p_crowbar.mdl"},
- {"Celurit", "350", "models/knife-system/v_celurit.mdl", "models/knife-system/p_celurit.mdl"},
- {"Kabar", "400", "models/knife-system/v_kabar.mdl", "models/knife-system/p_kabar.mdl"},
- {"Karambit", "450", "models/knife-system/v_karambit.mdl", "models/knife-system/p_karambit.mdl"},
- {"Omega", "500", "models/knife-system/v_domega.mdl", "models/knife-system/p_domega.mdl"},
- {"Metal Machete", "550", "models/knife-system/v_mmachete.mdl", "models/knife-system/p_mmachete.mdl"},
- {"Plunger", "600", "models/knife-system/v_plunger.mdl", "models/knife-system/p_plunger.mdl"},
- {"Rambo", "650", "models/knife-system/v_rambo.mdl", "models/knife-system/p_rambo.mdl"},
- {"Toporiaka", "700", "models/knife-system/v_toporiaka.mdl", "models/knife-system/p_toporiaka.mdl"},
- {"Candy", "750", "models/knife-system/v_candy.mdl", "models/knife-system/p_candy.mdl"},
- {"Elite", "800", "models/knife-system/v_elite.mdl", "models/knife-system/p_elite.mdl"},
- {"Traker", "850", "models/knife-system/v_traker.mdl", "models/knife-system/p_traker.mdl"},
- {"Bayonet", "900", "models/knife-system/v_bayonet.mdl", "models/knife-system/p_bayonet.mdl"},
- {"Triple", "950", "models/knife-system/v_kunai.mdl", "models/knife-system/p_kunai.mdl"}
- }
- public plugin_precache()
- {
- for(new i; i < sizeof(PodaciNozeva); i++)
- {
- precache_model(PodaciNozeva[i][2]);
- precache_model(PodaciNozeva[i][3]);
- }
- }
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_clcmd("say /knife", "PromeniNoz");
- register_clcmd("say_team /knife", "PromeniNoz");
- register_clcmd("say /noz", "PromeniNoz");
- register_clcmd("say_team /noz", "PromeniNoz");
- register_clcmd("say /resetall", "RestartUbistava");
- register_clcmd("say_team /resetall", "RestartUbistava");
- register_clcmd("say /reset", "Resetovanje");
- register_clcmd("say_team /reset", "Resetovanje");
- register_event("CurWeapon", "CurWeapon", "be", "1=1");
- register_cvar("knife_chat_poruke", "1");
- register_cvar("knife_hud", "1");
- if(get_cvar_num("knife_chat_pruke") == 1)
- {
- set_task(1.0, "Pomoc");
- }
- g_vault = nvault_open("KnifeSystem");
- if(g_vault == INVALID_HANDLE) set_fail_state("Greska pri otvaranju gVaulta");
- SyncHudObj = CreateHudSyncObj();
- }
- public PromeniNoz(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- new menu = menu_create("Izaberi noz" , "izaberi_noz_handle");
- new MeniNozevi[64];
- for(new i; i < sizeof(PodaciNozeva); i++)
- {
- if(ubistva_igraca[id] < str_to_num(PodaciNozeva[i][1]))
- {
- formatex(MeniNozevi, charsmax(MeniNozevi), "%s \r[Ubistva %i/%s]", PodaciNozeva[i][0], ubistva_igraca[id], PodaciNozeva[i][1]);
- }
- else
- formatex(MeniNozevi, charsmax(MeniNozevi), "%s \y[Otkljucano]", PodaciNozeva[i][0]);
- menu_additem(menu, MeniNozevi);
- }
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_setprop(menu, MPROP_BACKNAME, "Prethodna stranica");
- menu_setprop(menu, MPROP_NEXTNAME, "Sledeca stranica");
- menu_setprop(menu, MPROP_EXITNAME, "Izlaz");
- menu_display(id, menu);
- return PLUGIN_HANDLED;
- }
- public izaberi_noz_handle(id, menu, item)
- {
- if(item == MENU_EXIT)
- {
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- if(item == trenutni_model_noza[id])
- {
- ColorChat(id,GREEN,"[Knife Mod] ^1Vec koristis taj noz.");
- return PLUGIN_HANDLED;
- }
- new command[6], name[64], access, callback;
- menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);
- if(ubistva_igraca[id] < str_to_num(PodaciNozeva[item][1]))
- {
- ColorChat(id,GREEN,"[Knife Mod] ^1Nemas potreban broj ubistava za ovaj noz.");
- }
- else
- {
- PostaviNoz(id , item), ColorChat(id,GREEN,"[Knife Mod] ^1Promenio si noz, sada koristis %s.", PodaciNozeva[item][0]);
- }
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- public PostaviNoz(id , knife)
- {
- new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo);
- if(Weapon != CSW_KNIFE)
- return PLUGIN_HANDLED;
- trenutni_model_noza[id] = knife;
- new vModel[56];
- new pModel[56];
- format(vModel, 55, PodaciNozeva[knife][2]);
- format(pModel, 55, PodaciNozeva[knife][3]);
- entity_set_string(id, EV_SZ_viewmodel, vModel)
- entity_set_string(id, EV_SZ_weaponmodel, pModel)
- return PLUGIN_CONTINUE;
- }
- public CurWeapon(id)
- {
- PostaviNoz(id, trenutni_model_noza[id]);
- return PLUGIN_HANDLED;
- }
- public Pomoc()
- {
- switch(random(4))
- {
- case 0: ColorChat(0, NORMAL, "^4[Knife Mod] ^1Da promenis noz kucaj /noz ili /knife.");
- case 1: ColorChat(0, NORMAL, "^4[Knife Mod] ^1Za uzimanje svakog noza potreban je odredjen broj ubistava.");
- case 2: ColorChat(0, NORMAL, "^4[Knife Mod] ^1Da bi otkljucao sve nozeve potrebno je da ubijes 950 ljudi.");
- case 3: ColorChat(0, NORMAL, "^4[Knife Mod] ^1Da restartujes svoja ubistva kucaj /reset.");
- }
- set_task(16.0, "Pomoc");
- }
- public pokazi_podatke(id)
- {
- id -= HUD
- set_task(0.2, "pokazi_podatke", id+HUD);
- osvojeno_nozeva[id] = OsvojenoNozeva(id);
- if(!is_user_alive(id))
- {
- new target = entity_get_int(id, EV_INT_iuser2);
- if(target == 0)
- return PLUGIN_CONTINUE;
- set_hudmessage(0, 127, 255, 0.02, 0.22, 0, 0.0, 0.21, 0.0, 0.0, 2);
- ShowSyncHudMsg(id, SyncHudObj, "[Trenutni noz: %s]^n[Ubistva : %i]^n[Otkljucano nozeva : %i]", PodaciNozeva[trenutni_model_noza[target]][0], ubistva_igraca[target], osvojeno_nozeva[target]);
- return PLUGIN_CONTINUE;
- }
- else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- {
- new target = entity_get_int(id, EV_INT_iuser2);
- if(target == 0)
- return PLUGIN_CONTINUE;
- set_hudmessage(0, 127, 255, 0.02, 0.22, 0, 0.0, 0.21, 0.0, 0.0, 2);
- ShowSyncHudMsg(id, SyncHudObj, "[Trenutni noz: %s]^n[Ubistva : %i]^n[Otkljucano nozeva : %i]", PodaciNozeva[trenutni_model_noza[target]][0], ubistva_igraca[target], osvojeno_nozeva[target]);
- return PLUGIN_CONTINUE;
- }
- else
- {
- set_hudmessage(0, 127, 255, 0.02, 0.02, 0, 0.0, 0.21, 0.0, 0.0, 2);
- ShowSyncHudMsg(id, SyncHudObj, "[Trenutni noz: %s]^n[Ubistva : %i]^n[Otkljucano nozeva : %i]", PodaciNozeva[trenutni_model_noza[id]][0], ubistva_igraca[id], osvojeno_nozeva[id]);
- }
- return PLUGIN_CONTINUE;
- }
- OsvojenoNozeva(id)
- {
- for(new i = 1; i < sizeof(PodaciNozeva); i++)
- {
- if(str_to_num(PodaciNozeva[i][1]) > ubistva_igraca[id])
- return i;
- }
- return sizeof(PodaciNozeva);
- }
- public client_authorized(id)
- {
- LoadData(id);
- if(get_cvar_num("knife_hud") == 1)
- {
- set_task(3.0, "pokazi_podatke", id+HUD);
- }
- if(is_user_alive(id))
- {
- PromeniNoz(id);
- }
- }
- public client_disconnect(id)
- {
- SaveData(id);
- }
- public client_death(killer,victim)
- {
- if(killer != victim)
- {
- ubistva_igraca[killer] ++;
- }
- SaveData(killer);
- return PLUGIN_CONTINUE;
- }
- public SaveData(id)
- {
- new AuthID[35];
- get_user_authid(id,AuthID,34);
- new vaultkey[64],vaultdata[256];
- format(vaultkey,63,"%s-Knife",AuthID);
- format(vaultdata,255,"%i",ubistva_igraca[id]);
- nvault_set(g_vault,vaultkey,vaultdata);
- return PLUGIN_CONTINUE;
- }
- public LoadData(id)
- {
- new AuthID[35];
- get_user_authid(id,AuthID,34);
- new vaultkey[64],vaultdata[256];
- format(vaultkey,63,"%s-Knife",AuthID);
- format(vaultdata,255,"%i",ubistva_igraca[id]);
- nvault_get(g_vault,vaultkey,vaultdata,255);
- replace_all(vaultdata, 255, "#", " ");
- new ubistva[32];
- parse(vaultdata, ubistva, 31);
- ubistva_igraca[id] = str_to_num(ubistva);
- return PLUGIN_CONTINUE;
- }
- public plugin_end()
- {
- nvault_close(g_vault);
- }
- public RestartUbistava(id)
- {
- new flags = get_user_flags(id)
- if(flags & ADMIN_RCON)
- {
- ColorChat(0, NORMAL, "^4[Knife Mod] ^1Restart svih ubistava ce se izvrsiti za 10 sekundi.");
- set_task(10.0, "RestartujUbistva");
- }
- else
- {
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- public RestartujUbistva()
- {
- new iPlayer[32], iNum;
- get_players(iPlayer, iNum);
- for(new i; i < iNum; i++)
- {
- ubistva_igraca[iPlayer[i]] = 0;
- }
- nvault_prune(g_vault, 0, get_systime());
- server_cmd("changelevel de_dust2");
- return PLUGIN_CONTINUE;
- }
- public Resetovanje(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- ubistva_igraca[id] = 0;
- PostaviNoz(id, 0);
- ColorChat(0, NORMAL, "^4[Knife Mod] ^1Restartovao si svoja ubistva, sada su vracena na 0.");
- SaveData(id);
- return PLUGIN_HANDLED;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement