hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.08.03. 00:43



Jelenlévő felhasználók

Jelenleg 395 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 394 vendég

A legtöbb felhasználó (2883 fő) 2025.07.30. 16:00-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot]az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [3 hozzászólás ] 
Szerző Üzenet
HozzászólásElküldve:2012.06.26. 21:21 
Offline
Lelkes
Avatar

Csatlakozott:2011.02.03. 17:33
Hozzászólások:22
Megköszönt másnak: 2 alkalommal
Üdv!
Az lenne a kérdésem hogy lehetne megoldani azt, hogy ezt a plugint az első körben, csak egyszer lehessen használni.
Kód:
  1.  

  2. #include <amxmodx>

  3. #include <amxmisc>

  4. #include <fakemeta>

  5. #include <cstrike>

  6.  

  7. #define Plugin "Fegyver Eladas"

  8. #define Version "1.4"

  9. #define Author "PHP"

  10.  

  11. #define MAX_WEAPONS 33

  12.  

  13. new const g_prices[MAX_WEAPONS][] = {

  14.         "0",

  15.         "600",

  16.         "0",

  17.         "2750",

  18.         "0",

  19.         "3000",

  20.         "0",

  21.         "1400",

  22.         "3500",

  23.         "0",

  24.         "800",

  25.         "750",

  26.         "1700",

  27.         "4200",

  28.         "2000",

  29.         "2250",

  30.         "500",

  31.         "400",

  32.         "4750",

  33.         "1500",

  34.         "5750",

  35.         "1700",

  36.         "3100",

  37.         "1250",

  38.         "5000",

  39.         "0",

  40.         "650",

  41.         "3500",

  42.         "2500",

  43.         "0",

  44.         "2350",

  45.         "0",

  46.         "0"

  47. }

  48.  

  49. new cvar, buyzone, annonce, divide //Pcvar stuff, makes life easier

  50. public plugin_init() // Plugin_init(): Does all the "one-time" stuff. Called after plugin_precache().

  51. {

  52.         register_plugin(Plugin, Version, Author) //Register's the plugin so it can be seen in amx_help

  53.  

  54.         register_clcmd("say /sell", "cmd_sell") //Registers the command itself. So if someone say /sell the function will be executed

  55.         register_clcmd("say_team /sell", "cmd_sell") //Save as above but for team chat

  56.  

  57.         cvar = register_cvar("SW_enabled", "1") //Registers the cvar SW_enabled, Default 1 (If nothing else is in server.cfg or any other .cfg file)

  58.         buyzone = register_cvar("SW_buyzone", "1") //Registers the cvar SW_buyzone, Default 0 (If nothing else is in server.cfg or any other .cfg file)

  59.         annonce = register_cvar("SW_annonce", "120") //Registers the cvar SW_annonce, Default 120 (If nothing else is in server.cfg or any other .cfg file)

  60.         divide = register_cvar("SW_divide", "2") //Registers the cvar SW_divide, Default 2 (If nothing else is in server.cfg or any other .cfg file)

  61.  

  62.         if(get_pcvar_num(annonce) > 1) //If the pcvar annonce is higher then 1

  63.                 set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b") //Set a task to run the annonce function every get_pcvar_float(annonce) time

  64. }

  65.  

  66. public print_annonce() //The function that shows the annonce

  67. {

  68.         if(get_pcvar_num(annonce) < 1) //If it's lower then 1

  69.         return PLUGIN_CONTINUE //Make the plugin continue (Yes i know i should do remove_task() but this is better)

  70.  

  71.         client_print(0, print_chat, "Elakarod adni ezt a fegyvert? Ird be a chatbe hogy /sell") //Prints the message to everyones chat area

  72.         return PLUGIN_CONTINUE //Continue...

  73. }

  74.  

  75. stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) { // http://forums.alliedmods.net/showthread.php?t=28284

  76.         new strtype[11] = "classname", ent = index

  77.         switch (jghgtype) {

  78.                 case 1: copy(strtype, 6, "target")

  79.                 case 2: copy(strtype, 10, "targetname")

  80.         }

  81.  

  82.         while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}

  83.  

  84.         return ent

  85. }

  86.  

  87. stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") { // http://forums.alliedmods.net/showthread.php?t=28284

  88.         new ent_class[32]

  89.         if (!wid && wname[0])

  90.                 copy(ent_class, 31, wname)

  91.         else {

  92.                 new weapon = wid, clip, ammo

  93.                 if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))

  94.                         return false

  95.  

  96.                 get_weaponname(weapon, ent_class, 31)

  97.         }

  98.  

  99.         new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)

  100.         if (!ent_weap)

  101.                 return false

  102.  

  103.         engclient_cmd(index, "drop", ent_class)

  104.  

  105.         new ent_box = pev(ent_weap, pev_owner)

  106.         if (!ent_box || ent_box == index)

  107.                 return false

  108.  

  109.         dllfunc(DLLFunc_Think, ent_box)

  110.  

  111.         return true

  112. }

  113.  

  114. public cmd_sell(id) //The whole main function

  115. {

  116.         if(get_pcvar_num(cvar) < 1) //If the pcvar cvar is lower then one

  117.         return PLUGIN_CONTINUE //Continue...

  118.  

  119.         if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0) //If pcvar buyzone is equal to one and user is not in a buyzone

  120.         {

  121.                 client_print(id, print_chat, "[Sell] Buyzone-ban kell lenned hogy eladhasd a fegyvert!") //Prints a angry little message :)

  122.                 return PLUGIN_HANDLED //And ends the function

  123.         }

  124.  

  125.         if(!is_user_alive(id)) //Isn't he alive?!

  126.         {

  127.                 client_print(id, print_chat, "[Sell] Csak elve adhatsz el fegyvert!") //Prints a angry little message :)

  128.                 return PLUGIN_HANDLED //And ends the function

  129.         }

  130.  

  131.         new temp, weapon = get_user_weapon(id, temp, temp) //Fills weapon with the current hold weapon (temp is a so called dummy)

  132.         new price = str_to_num(g_prices[weapon]) //Gets the price for the current weapon

  133.  

  134.         if(price == 0) //If it's equal to zero

  135.         {

  136.                 client_print(id, print_chat, "[Sell] Nem lehet eladni ezt a fegyvert!") //Prints a angry little message :)

  137.                 return PLUGIN_HANDLED //And ends the function

  138.         }

  139.  

  140.         new weaponname[32] //Makes an array called weaponname, with a maximum of 32 - 1 chars

  141.         get_weaponname(weapon, weaponname, 31) //Gets the weapon name

  142.  

  143.         new oldmoney = cs_get_user_money(id) //Gets the players money

  144.         new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000) //clamps the total amount of cash, so it doesn't extend the 16000 limit

  145.  

  146.         fm_strip_user_gun(id, weapon) //Calls the fm_strip_user_gun() stock

  147.         cs_set_user_money(id, cash) //Sets the money from cash

  148.  

  149.         client_print(id, print_chat, "[Sell] Kaptal %d$-t amiert eladtal egy %s -t", cs_get_user_money(id) - oldmoney, weaponname[7]) //Prints some info about what you got

  150.         return PLUGIN_HANDLED

  151.         }

  152.  

  153.  


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve:2012.06.27. 07:31 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
csinálsz egy bool változót, s azt első körbe truera rakod, körvégén falsera, a parancsolnál meg lekérdezed hogy igaz-e!

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
HozzászólásElküldve:2012.06.27. 08:35 
Offline
Veterán
Avatar

Csatlakozott:2011.06.07. 15:29
Hozzászólások:1728
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 63 alkalommal
Kód:
  1.  

  2.  

  3. #include <amxmodx>

  4.  

  5. #include <amxmisc>

  6.  

  7. #include <fakemeta>

  8.  

  9. #include <cstrike>

  10.  

  11.  

  12.  

  13. #define Plugin "Fegyver Eladas"

  14.  

  15. #define Version "1.4"

  16.  

  17. #define Author "PHP"

  18.  

  19.  

  20.  

  21. #define MAX_WEAPONS 33

  22.  

  23.  

  24.  

  25. new const g_prices[MAX_WEAPONS][] = {

  26.  

  27.         "0",

  28.  

  29.         "600",

  30.  

  31.         "0",

  32.  

  33.         "2750",

  34.  

  35.         "0",

  36.  

  37.         "3000",

  38.  

  39.         "0",

  40.  

  41.         "1400",

  42.  

  43.         "3500",

  44.  

  45.         "0",

  46.  

  47.         "800",

  48.  

  49.         "750",

  50.  

  51.         "1700",

  52.  

  53.         "4200",

  54.  

  55.         "2000",

  56.  

  57.         "2250",

  58.  

  59.         "500",

  60.  

  61.         "400",

  62.  

  63.         "4750",

  64.  

  65.         "1500",

  66.  

  67.         "5750",

  68.  

  69.         "1700",

  70.  

  71.         "3100",

  72.  

  73.         "1250",

  74.  

  75.         "5000",

  76.  

  77.         "0",

  78.  

  79.         "650",

  80.  

  81.         "3500",

  82.  

  83.         "2500",

  84.  

  85.         "0",

  86.  

  87.         "2350",

  88.  

  89.         "0",

  90.  

  91.         "0"

  92.  

  93. }

  94.  

  95.  

  96. new bool:elsokor

  97. new bool:elsokor_use[33]

  98.  

  99. new cvar, buyzone, annonce, divide //Pcvar stuff, makes life easier

  100.  

  101. public plugin_init() // Plugin_init(): Does all the "one-time" stuff. Called after plugin_precache().

  102.  

  103. {

  104.  

  105.         register_plugin(Plugin, Version, Author) //Register's the plugin so it can be seen in amx_help

  106.  

  107.          register_logevent("korveg", 2,         "1=Round_End")

  108.          register_logevent("elso_kor", 2, "0=World triggered", "1&Restart_Round_")

  109.  

  110.         register_logevent("elso_kor", 2, "0=World triggered", "1=Game_Commencing")

  111.  

  112.  

  113.         register_clcmd("say /sell", "cmd_sell") //Registers the command itself. So if someone say /sell the function will be executed

  114.  

  115.         register_clcmd("say_team /sell", "cmd_sell") //Save as above but for team chat

  116.  

  117.  

  118.  

  119.         cvar = register_cvar("SW_enabled", "1") //Registers the cvar SW_enabled, Default 1 (If nothing else is in server.cfg or any other .cfg file)

  120.  

  121.         buyzone = register_cvar("SW_buyzone", "1") //Registers the cvar SW_buyzone, Default 0 (If nothing else is in server.cfg or any other .cfg file)

  122.  

  123.         annonce = register_cvar("SW_annonce", "120") //Registers the cvar SW_annonce, Default 120 (If nothing else is in server.cfg or any other .cfg file)

  124.  

  125.         divide = register_cvar("SW_divide", "2") //Registers the cvar SW_divide, Default 2 (If nothing else is in server.cfg or any other .cfg file)

  126.  

  127.  

  128.  

  129.         if(get_pcvar_num(annonce) > 1) //If the pcvar annonce is higher then 1

  130.  

  131.                 set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b") //Set a task to run the annonce function every get_pcvar_float(annonce) time

  132.  

  133. }

  134. public elso_kor()

  135. {

  136.         elsokor = true

  137.        

  138.         for(new i = 0;i<=get_playersnum();i++)

  139.                 elsokor_use[i] = false

  140. }

  141. public korveg()

  142. {

  143.         elsokor = false

  144. }

  145. public print_annonce() //The function that shows the annonce

  146.  

  147. {

  148.  

  149.         if(get_pcvar_num(annonce) < 1) //If it's lower then 1

  150.  

  151.         return PLUGIN_CONTINUE //Make the plugin continue (Yes i know i should do remove_task() but this is better)

  152.  

  153.  

  154.  

  155.         client_print(0, print_chat, "Elakarod adni ezt a fegyvert? Ird be a chatbe hogy /sell") //Prints the message to everyones chat area

  156.  

  157.         return PLUGIN_CONTINUE //Continue...

  158.  

  159. }

  160.  

  161.  

  162.  

  163. stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) { // http://forums.alliedmods.net/showthread.php?t=28284

  164.  

  165.         new strtype[11] = "classname", ent = index

  166.  

  167.         switch (jghgtype) {

  168.  

  169.                 case 1: copy(strtype, 6, "target")

  170.  

  171.                 case 2: copy(strtype, 10, "targetname")

  172.  

  173.         }

  174.  

  175.  

  176.  

  177.         while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}

  178.  

  179.  

  180.  

  181.         return ent

  182.  

  183. }

  184.  

  185.  

  186.  

  187. stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") { // http://forums.alliedmods.net/showthread.php?t=28284

  188.  

  189.         new ent_class[32]

  190.  

  191.         if (!wid && wname[0])

  192.  

  193.                 copy(ent_class, 31, wname)

  194.  

  195.         else {

  196.  

  197.                 new weapon = wid, clip, ammo

  198.  

  199.                 if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))

  200.  

  201.                         return false

  202.  

  203.  

  204.  

  205.                 get_weaponname(weapon, ent_class, 31)

  206.  

  207.         }

  208.  

  209.  

  210.  

  211.         new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)

  212.  

  213.         if (!ent_weap)

  214.  

  215.                 return false

  216.  

  217.  

  218.  

  219.         engclient_cmd(index, "drop", ent_class)

  220.  

  221.  

  222.  

  223.         new ent_box = pev(ent_weap, pev_owner)

  224.  

  225.         if (!ent_box || ent_box == index)

  226.  

  227.                 return false

  228.  

  229.  

  230.  

  231.         dllfunc(DLLFunc_Think, ent_box)

  232.  

  233.  

  234.  

  235.         return true

  236.  

  237. }

  238.  

  239.  

  240.  

  241. public cmd_sell(id) //The whole main function

  242.  

  243. {

  244.         if(elsokor == true)

  245.         {

  246.                 if(elsokor_use[id] == true)

  247.                 return PLUGIN_HANDLED

  248.         }

  249.  

  250.  

  251.         if(get_pcvar_num(cvar) < 1) //If the pcvar cvar is lower then one

  252.  

  253.         return PLUGIN_CONTINUE //Continue...

  254.  

  255.  

  256.  

  257.         if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0) //If pcvar buyzone is equal to one and user is not in a buyzone

  258.  

  259.         {

  260.  

  261.                 client_print(id, print_chat, "[Sell] Buyzone-ban kell lenned hogy eladhasd a fegyvert!") //Prints a angry little message :)

  262.  

  263.                 return PLUGIN_HANDLED //And ends the function

  264.  

  265.         }

  266.  

  267.  

  268.  

  269.         if(!is_user_alive(id)) //Isn't he alive?!

  270.  

  271.         {

  272.  

  273.                 client_print(id, print_chat, "[Sell] Csak elve adhatsz el fegyvert!") //Prints a angry little message :)

  274.  

  275.                 return PLUGIN_HANDLED //And ends the function

  276.  

  277.         }

  278.  

  279.  

  280.  

  281.         new temp, weapon = get_user_weapon(id, temp, temp) //Fills weapon with the current hold weapon (temp is a so called dummy)

  282.  

  283.         new price = str_to_num(g_prices[weapon]) //Gets the price for the current weapon

  284.  

  285.  

  286.  

  287.         if(price == 0) //If it's equal to zero

  288.  

  289.         {

  290.  

  291.                 client_print(id, print_chat, "[Sell] Nem lehet eladni ezt a fegyvert!") //Prints a angry little message :)

  292.  

  293.                 return PLUGIN_HANDLED //And ends the function

  294.  

  295.         }

  296.  

  297.  

  298.  

  299.         new weaponname[32] //Makes an array called weaponname, with a maximum of 32 - 1 chars

  300.  

  301.         get_weaponname(weapon, weaponname, 31) //Gets the weapon name

  302.  

  303.  

  304.  

  305.         new oldmoney = cs_get_user_money(id) //Gets the players money

  306.  

  307.         new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000) //clamps the total amount of cash, so it doesn't extend the 16000 limit

  308.  

  309.  

  310.  

  311.         fm_strip_user_gun(id, weapon) //Calls the fm_strip_user_gun() stock

  312.  

  313.         cs_set_user_money(id, cash) //Sets the money from cash

  314.  

  315.  

  316.  

  317.         client_print(id, print_chat, "[Sell] Kaptal %d$-t amiert eladtal egy %s -t", cs_get_user_money(id) - oldmoney, weaponname[7]) //Prints some info about what you got

  318.         elsokor_use[id] = true

  319.         return PLUGIN_HANDLED

  320.  

  321.         }

  322.  

  323.  

  324.  

  325.  


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése: Rendezés 
Új téma nyitása Hozzászólás a témához  [3 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 34 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole