Advertisement
Tibers

knife_system_v1.1_by_pićunak

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