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 VERZIJA "1.3"
- #define AUTOR "Pićunak"
- #define HUD 1
- #define Prefiks "[Knife Mod]"
- #define Mapa "fy_snow"
- new trenutni_model_noza[33];
- new ubistva_igraca[33];
- new osvojeno_nozeva[33];
- new noz_vault;
- new hud_objekat;
- enum KnifeData
- {
- Naziv,
- PotrebnoUbistava,
- ViewModel,
- PlayerModel
- };
- new const PodaciNozeva[28][KnifeData][] =
- {
- //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"},
- {"Bowie", 950, "models/knife-system/v_bowie.mdl", "models/knife-system/p_bowie.mdl"}
- }
- public plugin_precache()
- {
- for(new i; i < sizeof(PodaciNozeva); i++)
- {
- precache_model(PodaciNozeva[i][ViewModel]);
- precache_model(PodaciNozeva[i][PlayerModel]);
- }
- }
- public plugin_init()
- {
- register_plugin(PLUGIN, VERZIJA, AUTOR)
- 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_message(get_user_msgid("SayText"),"handleSayText");
- noz_vault = nvault_open("KnifeSystem");
- if(noz_vault == INVALID_HANDLE) set_fail_state("Greska pri otvaranju gVaulta");
- hud_objekat = 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] < PodaciNozeva[i][PotrebnoUbistava][0])
- {
- formatex(MeniNozevi, charsmax(MeniNozevi), "%s \r[Ubistva %i/%i]", PodaciNozeva[i][Naziv], ubistva_igraca[id], PodaciNozeva[i][PotrebnoUbistava]);
- }
- else
- formatex(MeniNozevi, charsmax(MeniNozevi), "%s \y[Otkljucano]", PodaciNozeva[i][Naziv]);
- 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);
- }
- if(item == trenutni_model_noza[id])
- {
- ColorChat(id,GREEN,"%s ^1Vec koristis taj noz.", Prefiks);
- return;
- }
- 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] < PodaciNozeva[item][PotrebnoUbistava][0])
- ColorChat(id,GREEN,"%s ^1Nemas potreban broj ubistava za ovaj noz.", Prefiks);
- else
- PostaviNoz(id , item), ColorChat(id,GREEN,"%s ^1Promenio si noz, sada koristis %s.", Prefiks, PodaciNozeva[item][Naziv]);
- menu_destroy(menu);
- }
- PostaviNoz(id , knife)
- {
- new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo);
- if(Weapon != CSW_KNIFE)
- return;
- trenutni_model_noza[id] = knife;
- new vModel[56];
- new pModel[56];
- format(vModel, 55, PodaciNozeva[knife][ViewModel]);
- format(pModel, 55, PodaciNozeva[knife][PlayerModel]);
- entity_set_string(id, EV_SZ_viewmodel, vModel)
- entity_set_string(id, EV_SZ_weaponmodel, pModel)
- }
- public CurWeapon(id)
- {
- PostaviNoz(id, trenutni_model_noza[id]);
- }
- 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;
- set_hudmessage(0, 127, 255, 0.01, 0.23, 0, 0.0, 0.21, 0.0, 0.0, 2);
- ShowSyncHudMsg(id, hud_objekat, "[Trenutni noz: %s]^n[Ubistva : %i]^n[Otkljucano nozeva : %i]", PodaciNozeva[trenutni_model_noza[target]][Naziv], ubistva_igraca[target], osvojeno_nozeva[target]);
- return;
- }
- else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
- {
- new target = entity_get_int(id, EV_INT_iuser2);
- if(target == 0)
- return;
- set_hudmessage(0, 127, 255, 0.01, 0.23, 0, 0.0, 0.21, 0.0, 0.0, 2);
- ShowSyncHudMsg(id, hud_objekat, "[Trenutni noz: %s]^n[Ubistva : %i]^n[Otkljucano nozeva : %i]", PodaciNozeva[trenutni_model_noza[target]][Naziv], ubistva_igraca[target], osvojeno_nozeva[target]);
- return;
- }
- else
- {
- set_hudmessage(0, 127, 255, 0.01, 0.23, 0, 0.0, 0.21, 0.0, 0.0, 2);
- ShowSyncHudMsg(id, hud_objekat, "[Trenutni noz: %s]^n[Ubistva : %i]^n[Otkljucano nozeva : %i]", PodaciNozeva[trenutni_model_noza[id]][Naziv], ubistva_igraca[id], osvojeno_nozeva[id]);
- }
- }
- OsvojenoNozeva(id)
- {
- for(new i = 1; i < sizeof(PodaciNozeva); i++)
- {
- if(PodaciNozeva[i][PotrebnoUbistava][0] > ubistva_igraca[id])
- return i;
- }
- return sizeof(PodaciNozeva);
- }
- public client_authorized(id)
- {
- UcitajPodatke(id);
- set_task(3.0, "pokazi_podatke", id+HUD);
- }
- public client_disconnect(id)
- {
- SacuvajPodatke(id);
- }
- public client_death(killer,victim)
- {
- if(killer != victim)
- {
- ubistva_igraca[killer] ++;
- }
- SacuvajPodatke(killer);
- }
- SacuvajPodatke(id)
- {
- new AuthID[35];
- new vaultdata[12];
- get_user_authid(id, AuthID, charsmax(AuthID));
- format(vaultdata, charsmax(vaultdata), "%i", ubistva_igraca[id]);
- nvault_set(noz_vault, AuthID, vaultdata);
- }
- UcitajPodatke(id)
- {
- new AuthID[35];
- get_user_authid(id, AuthID, charsmax(AuthID));
- ubistva_igraca[id] = nvault_get(noz_vault, AuthID);
- }
- public plugin_end()
- {
- nvault_close(noz_vault);
- }
- public RestartUbistava(id)
- {
- new flags = get_user_flags(id);
- if(flags & ADMIN_RCON)
- {
- arrayset(ubistva_igraca, 0, sizeof(ubistva_igraca));
- nvault_prune(noz_vault, 0, get_systime());
- server_cmd("changelevel %s", Mapa);
- }
- return PLUGIN_HANDLED;
- }
- public Resetovanje(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED;
- ubistva_igraca[id] = 0;
- PostaviNoz(id, 0);
- ColorChat(0, NORMAL, "^4%s ^1Restartovao si svoja ubistva, sada su vracena na 0.", Prefiks);
- SacuvajPodatke(id);
- return PLUGIN_HANDLED;
- }
- public handleSayText(msgId, msgDest, msgEnt)
- {
- new id = get_msg_arg_int(1);
- if(is_user_connected(id))
- {
- new szTmp[256],
- szTmp2[256];
- get_msg_arg_string(2, szTmp, charsmax(szTmp));
- new szPrefix[64]
- formatex(szPrefix,charsmax( szPrefix ),"^x04[Otkljucao %i][Ubistva %i]", OsvojenoNozeva(id), ubistva_igraca[id])
- if(!equal(szTmp, "#Cstrike_Chat_All"))
- {
- add(szTmp2, charsmax(szTmp2), szPrefix);
- add(szTmp2, charsmax(szTmp2), " ");
- add(szTmp2, charsmax(szTmp2), szTmp);
- }
- else
- {
- add(szTmp2, charsmax(szTmp2), szPrefix);
- add(szTmp2, charsmax(szTmp2), "^x03 %s1^x01 : %s2");
- }
- set_msg_arg_string(2, szTmp2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement