Advertisement
Tibers

knife_system_v1.2_by_pićunak

Mar 11th, 2024
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.03 KB | Source Code | 0 0
  1. #include <amxmodx>
  2. #include <nvault>
  3. #include <cstrike>
  4. #include <colorchat>
  5. #include <engine>
  6.  
  7. #define PLUGIN  "Knife System"
  8. #define VERSION "1.2"
  9. #define AUTHOR  "Pićunak"
  10. #define HUD     1
  11. #define Prefiks "[Knife Mod]"
  12.  
  13. new trenutni_model_noza[33];
  14. new ubistva_igraca[33];
  15. new osvojeno_nozeva[33];
  16. new g_vault;
  17. new SyncHudObj;
  18.  
  19. enum KnifeData
  20. {
  21.     Naziv,
  22.     PotrebnoUbistava,
  23.     ViewModel,
  24.     PlayerModel
  25. };
  26.  
  27. new const PodaciNozeva[28][KnifeData][] =
  28. {
  29.     //Naziv         Ubistva     "View" model                "Player" model
  30.     {"Default",     0,      "models/v_knife.mdl",           "models/p_knife.mdl"},
  31.     {"Machete",     10,     "models/knife-system/v_machete.mdl",    "models/knife-system/p_machete.mdl"},
  32.     {"Back",        20,     "models/knife-system/v_back.mdl",   "models/knife-system/p_back.mdl"},
  33.     {"Pocket",      30,     "models/knife-system/v_pocket.mdl", "models/knife-system/p_pocket.mdl"},
  34.     {"Butcher",     40,     "models/knife-system/v_butcher.mdl",    "models/knife-system/p_butcher.mdl"},
  35.     {"Wooden",      50,     "models/knife-system/v_wooden.mdl", "models/knife-system/p_wooden.mdl"},
  36.     {"Dragon",      60,     "models/knife-system/v_dragon.mdl", "models/knife-system/p_dragon.mdl"},
  37.     {"Ninja",       70,     "models/knife-system/v_ninja.mdl""models/knife-system/p_ninja.mdl"},
  38.     {"Black",       80,     "models/knife-system/v_black.mdl""models/knife-system/p_black.mdl"},
  39.     {"Hitman",      90,     "models/knife-system/v_hitman.mdl", "models/knife-system/p_hitman.mdl"},
  40.     {"Daedric",     100,        "models/knife-system/v_daedric.mdl",    "models/knife-system/p_daedric.mdl"},
  41.     {"Ice",         150,        "models/knife-system/v_ice.mdl",    "models/knife-system/p_ice.mdl"},
  42.     {"Katane",      200,        "models/knife-system/v_katana.mdl", "models/knife-system/p_katana.mdl"},
  43.     {"Rusty",       250,        "models/knife-system/v_rusty.mdl""models/knife-system/p_rusty.mdl"},
  44.     {"Crowbar",     300,        "models/knife-system/v_crowbar.mdl",    "models/knife-system/p_crowbar.mdl"},
  45.     {"Celurit",     350,        "models/knife-system/v_celurit.mdl",    "models/knife-system/p_celurit.mdl"},
  46.     {"Kabar",       400,        "models/knife-system/v_kabar.mdl""models/knife-system/p_kabar.mdl"},
  47.     {"Karambit",        450,        "models/knife-system/v_karambit.mdl",   "models/knife-system/p_karambit.mdl"},
  48.     {"Omega",       500,        "models/knife-system/v_domega.mdl", "models/knife-system/p_domega.mdl"},
  49.     {"Metal Machete",   550,        "models/knife-system/v_mmachete.mdl",   "models/knife-system/p_mmachete.mdl"},
  50.     {"Plunger",     600,        "models/knife-system/v_plunger.mdl",    "models/knife-system/p_plunger.mdl"},
  51.     {"Rambo",       650,        "models/knife-system/v_rambo.mdl""models/knife-system/p_rambo.mdl"},
  52.     {"Toporiaka",       700,        "models/knife-system/v_toporiaka.mdl""models/knife-system/p_toporiaka.mdl"},
  53.     {"Candy",       750,        "models/knife-system/v_candy.mdl""models/knife-system/p_candy.mdl"},
  54.     {"Elite",       800,        "models/knife-system/v_elite.mdl""models/knife-system/p_elite.mdl"},
  55.     {"Traker",      850,        "models/knife-system/v_traker.mdl", "models/knife-system/p_traker.mdl"},
  56.     {"Bayonet",     900,        "models/knife-system/v_bayonet.mdl",    "models/knife-system/p_bayonet.mdl"},
  57.     {"Triple",      950,        "models/knife-system/v_kunai.mdl""models/knife-system/p_kunai.mdl"}
  58. }
  59.  
  60. public plugin_precache()
  61. {
  62.      for(new i; i < sizeof(PodaciNozeva); i++)
  63.           {
  64.                     precache_model(PodaciNozeva[i][ViewModel]);
  65.                     precache_model(PodaciNozeva[i][PlayerModel]);
  66.           }
  67. }
  68.  
  69. public plugin_init()
  70. {
  71.     register_plugin(PLUGIN, VERSION, AUTHOR)
  72.     register_clcmd("say /knife", "PromeniNoz");
  73.     register_clcmd("say_team /knife", "PromeniNoz");
  74.     register_clcmd("say /noz", "PromeniNoz");
  75.     register_clcmd("say_team /noz", "PromeniNoz");
  76.     register_clcmd("say /resetall", "RestartUbistava");
  77.     register_clcmd("say_team /resetall", "RestartUbistava");
  78.     register_clcmd("say /reset", "Resetovanje");
  79.     register_clcmd("say_team /reset", "Resetovanje");
  80.     register_event("CurWeapon", "CurWeapon", "be", "1=1");
  81.     register_cvar("knife_hud", "1");
  82.     g_vault = nvault_open("KnifeSystem");
  83.     if(g_vault == INVALID_HANDLE) set_fail_state("Greska pri otvaranju gVaulta");
  84.     SyncHudObj = CreateHudSyncObj();
  85. }
  86.  
  87. public PromeniNoz(id)
  88. {
  89.     if(!is_user_connected(id))
  90.         return PLUGIN_HANDLED;
  91.  
  92.     new menu = menu_create("Izaberi noz" , "izaberi_noz_handle");
  93.     new MeniNozevi[64];
  94.     for(new i; i < sizeof(PodaciNozeva); i++)
  95.     {
  96.         if(ubistva_igraca[id] < PodaciNozeva[i][PotrebnoUbistava][0])
  97.         {
  98.             formatex(MeniNozevi, charsmax(MeniNozevi), "%s \r[Ubistva %i/%i]", PodaciNozeva[i][Naziv], ubistva_igraca[id], PodaciNozeva[i][PotrebnoUbistava]);
  99.         }
  100.         else
  101.         formatex(MeniNozevi, charsmax(MeniNozevi), "%s \y[Otkljucano]", PodaciNozeva[i][Naziv]);
  102.         menu_additem(menu, MeniNozevi);
  103.     }
  104.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  105.     menu_setprop(menu, MPROP_BACKNAME, "Prethodna stranica");
  106.     menu_setprop(menu, MPROP_NEXTNAME, "Sledeca stranica");
  107.     menu_setprop(menu, MPROP_EXITNAME, "Izlaz");
  108.     menu_display(id, menu);
  109.     return PLUGIN_HANDLED;
  110. }
  111.  
  112. public izaberi_noz_handle(id, menu, item)
  113. {
  114.     if(item == MENU_EXIT)
  115.     {
  116.         menu_destroy(menu);
  117.         return PLUGIN_HANDLED;
  118.     }
  119.     if(item == trenutni_model_noza[id])
  120.     {
  121.         ColorChat(id,GREEN,"%s ^1Vec koristis taj noz.", Prefiks);
  122.         return PLUGIN_HANDLED;
  123.     }
  124.    
  125.     new command[6], name[64], access, callback;
  126.     menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);
  127.    
  128.     if(ubistva_igraca[id] < PodaciNozeva[item][PotrebnoUbistava][0])
  129.     {
  130.         ColorChat(id,GREEN,"%s ^1Nemas potreban broj ubistava za ovaj noz.", Prefiks);
  131.     }
  132.     else
  133.     {
  134.         PostaviNoz(id , item), ColorChat(id,GREEN,"%s ^1Promenio si noz, sada koristis %s.", Prefiks, PodaciNozeva[item][Naziv]);
  135.     }
  136.     menu_destroy(menu);
  137.     return PLUGIN_HANDLED;
  138. }
  139.  
  140. public PostaviNoz(id , knife)
  141. {
  142.     new Clip, Ammo, Weapon = get_user_weapon(id, Clip, Ammo);
  143.     if(Weapon != CSW_KNIFE)
  144.         return PLUGIN_HANDLED;
  145.        
  146.     trenutni_model_noza[id] = knife;
  147.     new vModel[56];
  148.     new pModel[56];
  149.     format(vModel, 55, PodaciNozeva[knife][ViewModel]);
  150.     format(pModel, 55, PodaciNozeva[knife][PlayerModel]);
  151.     entity_set_string(id, EV_SZ_viewmodel, vModel)
  152.     entity_set_string(id, EV_SZ_weaponmodel, pModel)
  153.     return PLUGIN_CONTINUE;
  154. }
  155.  
  156. public CurWeapon(id)
  157. {
  158.     PostaviNoz(id, trenutni_model_noza[id]);
  159.     return PLUGIN_HANDLED;
  160. }
  161.  
  162. public pokazi_podatke(id)
  163. {
  164.     id -= HUD
  165.     set_task(0.2, "pokazi_podatke", id+HUD);
  166.     osvojeno_nozeva[id] = OsvojenoNozeva(id);
  167.     if(!is_user_alive(id))
  168.     {
  169.         new target = entity_get_int(id, EV_INT_iuser2);
  170.         if(target == 0)
  171.             return PLUGIN_CONTINUE;
  172.            
  173.         set_hudmessage(0, 127, 255, 0.02, 0.22, 0, 0.0, 0.21, 0.0, 0.0, 2);
  174.         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]);
  175.         return PLUGIN_CONTINUE;
  176.     }
  177.     else if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
  178.     {
  179.         new target = entity_get_int(id, EV_INT_iuser2);
  180.         if(target == 0)
  181.             return PLUGIN_CONTINUE;
  182.            
  183.         set_hudmessage(0, 127, 255, 0.02, 0.22, 0, 0.0, 0.21, 0.0, 0.0, 2);
  184.         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]);
  185.         return PLUGIN_CONTINUE;
  186.     }
  187.     else
  188.     {
  189.         set_hudmessage(0, 127, 255, 0.02, 0.02, 0, 0.0, 0.21, 0.0, 0.0, 2);
  190.         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]);
  191.     }
  192.     return PLUGIN_CONTINUE;
  193. }
  194.  
  195. OsvojenoNozeva(id)
  196. {
  197.     for(new i = 1; i < sizeof(PodaciNozeva); i++)
  198.     {
  199.         if(PodaciNozeva[i][PotrebnoUbistava][0] > ubistva_igraca[id])
  200.         return i;
  201.     }
  202.     return sizeof(PodaciNozeva);
  203. }
  204.  
  205. public client_authorized(id)
  206. {
  207.     LoadData(id);
  208.     if(get_cvar_num("knife_hud") == 1)
  209.     {
  210.         set_task(3.0, "pokazi_podatke", id+HUD);
  211.     }
  212.     if(is_user_alive(id))
  213.     {
  214.         PromeniNoz(id);
  215.     }
  216. }
  217.  
  218. public client_disconnect(id)
  219. {
  220.     SaveData(id);
  221. }
  222.  
  223. public client_death(killer,victim)
  224. {
  225.     if(killer != victim)
  226.     {
  227.         ubistva_igraca[killer] ++;
  228.     }
  229.     SaveData(killer);
  230.     return PLUGIN_CONTINUE;
  231. }
  232.  
  233. public SaveData(id)
  234. {
  235.     new AuthID[35];
  236.     new vaultdata[12];
  237.     get_user_authid(id, AuthID, charsmax(AuthID));
  238.     format(vaultdata, charsmax(vaultdata), "%i", ubistva_igraca[id]);
  239.     nvault_set(g_vault, AuthID, vaultdata);
  240. }
  241.  
  242. public LoadData(id)
  243. {
  244.     new AuthID[35];
  245.     get_user_authid(id, AuthID, charsmax(AuthID));
  246.     ubistva_igraca[id] = nvault_get(g_vault, AuthID);
  247. }
  248.  
  249. public plugin_end()
  250. {
  251.     nvault_close(g_vault);
  252. }
  253.  
  254. public RestartUbistava(id)
  255. {
  256.     new flags = get_user_flags(id);
  257.     if(flags & ADMIN_RCON)
  258.     {
  259.         new iPlayer[32], iNum;
  260.         get_players(iPlayer, iNum);
  261.         for(new i; i < iNum; i++)
  262.         {
  263.             ubistva_igraca[iPlayer[i]] = 0;
  264.         }
  265.         nvault_prune(g_vault, 0, get_systime());
  266.         server_cmd("changelevel de_dust2");
  267.     }
  268.     else
  269.     {
  270.         return PLUGIN_HANDLED;
  271.     }
  272.     return PLUGIN_CONTINUE;
  273. }
  274.  
  275. public Resetovanje(id)
  276. {
  277.     if(!is_user_connected(id))
  278.         return PLUGIN_HANDLED;
  279.        
  280.     ubistva_igraca[id] = 0;
  281.     PostaviNoz(id, 0);
  282.     ColorChat(0, NORMAL, "^4%s ^1Restartovao si svoja ubistva, sada su vracena na 0.", Prefiks);
  283.     SaveData(id);
  284.     return PLUGIN_HANDLED;
  285. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement