HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. * Weapon Return
  3. *
  4. * Author: nikhilgupta345 (AKA H3avY Ra1n)
  5. *
  6. * Description
  7. * -----------
  8. * This plugin allows players to return their
  9. * weapons back to the store for a refund.
  10. *
  11. * Client Commands
  12. * ---------------
  13. * say /return - Returns current weapon of player.
  14. *
  15. * CVars
  16. * -----
  17. * rw_percent <percentage> <default:0.80>
  18. * - How much money players should get back.
  19. * - MUST BE A DECMIAL.
  20. *
  21. *
  22. * rw_buyzone <0/1> <default:1>
  23. * - Whether players must be in a buyzone
  24. * to return their weapon(s).
  25. *
  26. * Changelog
  27. * ---------
  28. * July 30, 2011 - v1.0 - Plugin Release
  29. * - v1.1 - Few optimizations
  30. * - v1.2 - Added support for shield return
  31. *
  32. * Credits
  33. * -------
  34. * XxAvalanchexX - ham_strip_weapon stock
  35. * Exolent - cs_set_user_shield stock
  36. *
  37. * Installation
  38. * ------------
  39. * - Compile this file
  40. * - Place 'weapon_return.amxx' in the plugins folder
  41. * - Add 'weapon_return.amxx' to plugins.ini
  42. * - Restart server or change map
  43. *
  44. * Plugin Thread
  45. * -------------
  46. * http://forums.alliedmods.net/showthread.php?t=163397
  47. *
  48. * Fordította: BBk - Death of Legend
  49. *
  50. */
  51.  
  52. #include < amxmodx >
  53. #include < cstrike >
  54. #include < hamsandwich >
  55. #include < fakemeta >
  56. #include < fun >
  57.  
  58. new const g_iWeaponCost[ CSW_P90 + 1 ] =
  59. {
  60. 0,
  61. 600,
  62. 2200,
  63. 2750,
  64. 300,
  65. 3000,
  66. 0, // c4
  67. 1400,
  68. 3500,
  69. 300,
  70. 800,
  71. 750,
  72. 1700,
  73. 4200,
  74. 2000,
  75. 2250,
  76. 500,
  77. 400,
  78. 4750,
  79. 1500,
  80. 5750,
  81. 1700,
  82. 3100,
  83. 1250,
  84. 5000,
  85. 200,
  86. 650,
  87. 3500,
  88. 2500,
  89. 0, // knife
  90. 2350
  91. };
  92.  
  93. const g_iShieldCost = 2200;
  94.  
  95. new g_pReturnPercent;
  96. new g_pBuyzoneOnly;
  97.  
  98. public plugin_init()
  99. {
  100. register_plugin( "Fegyver visszaadas", "1.0", "H3avY Ra1n" );
  101.  
  102. register_clcmd( "say /vissza", "Cmd_Return" );
  103.  
  104. g_pReturnPercent = register_cvar( "rw_percent", ".80" );
  105. g_pBuyzoneOnly = register_cvar( "rw_buyzone", "1" );
  106. }
  107.  
  108. public Cmd_Return( id )
  109. {
  110. if( !is_user_alive( id ) )
  111. {
  112. client_print( id, print_chat, "Halott vagy, nem hasznalhatod ezt a parancsot." );
  113. return PLUGIN_HANDLED;
  114. }
  115.  
  116. if( !cs_get_user_buyzone( id ) && get_pcvar_num( g_pBuyzoneOnly ) )
  117. {
  118. client_print( id, print_center, "Nem a vasarlasi zonanal tartozkodsz!" );
  119. return PLUGIN_HANDLED;
  120. }
  121.  
  122. new Float:fPercent = get_pcvar_float( g_pReturnPercent );
  123.  
  124. if( fPercent == 0.0 )
  125. {
  126. client_print( id, print_chat, "A fegyver vissza vasarlasa egyelore nem lehetseges." );
  127. return PLUGIN_HANDLED;
  128. }
  129.  
  130. new iWeapon = get_user_weapon( id );
  131.  
  132. new bool:bShield = cs_get_user_shield( id ) && iWeapon == CSW_KNIFE;
  133.  
  134. new iCost;
  135.  
  136. if( bShield )
  137. {
  138. iCost = g_iShieldCost;
  139. }
  140.  
  141. else
  142. {
  143. iCost = g_iWeaponCost[ iWeapon ];
  144. }
  145.  
  146. if( iCost <= 0 )
  147. {
  148. client_print( id, print_center, "Nem tudod vissza vasarolni a fegyvered." );
  149. return PLUGIN_HANDLED;
  150. }
  151.  
  152. new iRefund = floatround( iCost * fPercent, floatround_round );
  153.  
  154. if( iRefund == 0 )
  155. {
  156. client_print( id, print_center, "Nem tudod vissza vasarolni a fegyvered." );
  157. return PLUGIN_HANDLED;
  158. }
  159.  
  160. if( bShield )
  161. {
  162. cs_set_user_shield( id, 0 );
  163. }
  164.  
  165. else
  166. {
  167. new szWeaponName[ 32 ];
  168. get_weaponname( iWeapon, szWeaponName, charsmax( szWeaponName ) );
  169. ham_strip_weapon( id, szWeaponName );
  170. }
  171.  
  172. cs_set_user_money( id, min( cs_get_user_money( id ) + iRefund, 16000 ) );
  173.  
  174. client_print( id, print_chat, "A fegyvereid vissza vasaroltad $%i -ert.", iRefund );
  175.  
  176. return PLUGIN_HANDLED;
  177. }
  178.  
  179. // By XxAvalanchexX
  180. stock ham_strip_weapon(id,weapon[])
  181. {
  182. if(!equal(weapon,"weapon_",7)) return 0;
  183.  
  184. new wId = get_weaponid(weapon);
  185. if(!wId) return 0;
  186.  
  187. new wEnt;
  188. while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
  189. if(!wEnt) return 0;
  190.  
  191. if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
  192.  
  193. if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
  194.  
  195. ExecuteHamB(Ham_Item_Kill,wEnt);
  196.  
  197. set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
  198. return 1;
  199. }
  200.  
  201. // By Exolent
  202. stock cs_set_user_shield(id, set)
  203. {
  204. if(set)
  205. {
  206. give_item(id, "weapon_shield");
  207. }
  208. else
  209. {
  210. const m_iUserPrefs = 510;
  211. const USING_SHIELD = (1<<16);
  212. const HAS_SHIELD = (1<<24);
  213.  
  214. new prefs = get_pdata_int(id, m_iUserPrefs) & ~USING_SHIELD;
  215.  
  216. if(prefs & HAS_SHIELD)
  217. {
  218. new model[64];
  219. pev(id, pev_viewmodel2, model, charsmax(model));
  220.  
  221. if(equal(model, "models/shield/v_shield_", 23))
  222. {
  223. replace(model, charsmax(model), "shield/v_shield", "v");
  224.  
  225. set_pev(id, pev_viewmodel2, model);
  226. }
  227.  
  228. pev(id, pev_weaponmodel2, model, charsmax(model));
  229.  
  230. if(equal(model, "models/shield/p_shield_", 23))
  231. {
  232. replace(model, charsmax(model), "shield/p_shield", "p");
  233.  
  234. set_pev(id, pev_weaponmodel2, model);
  235. }
  236.  
  237. set_pdata_int(id, m_iUserPrefs, (prefs & ~HAS_SHIELD));
  238. }
  239. }
  240.  
  241. return 1;
  242. }