Advertisement
Tibers

knife_system_v1.3_by_pićunak

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