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.2"
- #define AUTHOR "Pićunak"
- #define HUD 1
- #define Prefiks "[Knife Mod]"
- new trenutni_model_noza[33];
- new ubistva_igraca[33];
- new osvojeno_nozeva[33];
- new g_vault;
- new SyncHudObj;
- 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"},
- {"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][ViewModel]);
- precache_model(PodaciNozeva[i][PlayerModel]);
- }
- }
- 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_hud", "1");
- 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] < 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);
- return PLUGIN_HANDLED;
- }
- if(item == trenutni_model_noza[id])
- {
- ColorChat(id,GREEN,"%s ^1Vec koristis taj noz.", Prefiks);
- 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] < 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);
- 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][ViewModel]);
- format(pModel, 55, PodaciNozeva[knife][PlayerModel]);
- 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 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]][Naziv], 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]][Naziv], 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]][Naziv], ubistva_igraca[id], osvojeno_nozeva[id]);
- }
- return PLUGIN_CONTINUE;
- }
- 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)
- {
- 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];
- new vaultdata[12];
- get_user_authid(id, AuthID, charsmax(AuthID));
- format(vaultdata, charsmax(vaultdata), "%i", ubistva_igraca[id]);
- nvault_set(g_vault, AuthID, vaultdata);
- }
- public LoadData(id)
- {
- new AuthID[35];
- get_user_authid(id, AuthID, charsmax(AuthID));
- ubistva_igraca[id] = nvault_get(g_vault, AuthID);
- }
- public plugin_end()
- {
- nvault_close(g_vault);
- }
- public RestartUbistava(id)
- {
- new flags = get_user_flags(id);
- if(flags & ADMIN_RCON)
- {
- 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");
- }
- else
- {
- return PLUGIN_HANDLED;
- }
- 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%s ^1Restartovao si svoja ubistva, sada su vracena na 0.", Prefiks);
- SaveData(id);
- return PLUGIN_HANDLED;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement