Advertisement
Guest User

Plugin norecoil

a guest
Jan 27th, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.85 KB | None | 0 0
  1. /* AMX Mod X
  2. * No Recoil
  3. *
  4. * This file is provided as is (no warranties)
  5. *
  6. * Original by: Petey B
  7. * Original Credits: Xavior, Mattcook, Fox-NL, KRoT@L, Others
  8. *
  9. * Ported by: Blitz (July 20, 2005)
  10. * Version: 1.3
  11. *
  12. * Changelog:
  13. * 1.3 Re-wrote most of the plugin
  14. * Added language dictionary for future multilanguage support
  15. * Added showing administrator activity from a CVAR
  16. * Added HUD notifications
  17. * Added short sound when you buy no recoil and return to normal
  18. * Changed way of detecting disabled no recoil
  19. * Changed way of executing recoil commands on clients
  20. * Changed way of telling clients how to use no recoil
  21. * Removed useless code
  22. * Removed limit CVAR per team because of unbalance
  23. * Cleaned and organized code
  24. * 1.2 Added when you buy no recoil, a message is given notifying the purchase
  25. * Added message saying if no recoil is disabled on the server
  26. * 1.1 Changed around some CVAR names
  27. * Added CVAR to limit amount of people using no recoil per team
  28. * Fixed bug where you are able to buy no recoil when you already have it
  29. * Fixed bug where you can buy no recoil when you're dead
  30. * 1.0 Ported to AMXX
  31. *
  32. * Note:
  33. * This plugin allows you to be able to get no recoil on weapons.
  34. * You can either buy no recoil or get it from an administrator.
  35. * You may return recoil to normal at anytime, but every round it is returned to normal.
  36. * This plugin is meant for EVERYONE. Have fun with it.
  37. *
  38. * You need the language file along with this .sma in order to work properly.
  39. *
  40. * Admin Commands:
  41. * amx_recoil <nick, part nick, @TEAM or *ALL> - gives client normal recoil
  42. * amx_norecoil <nick, part nick, @TEAM or *ALL> - gives client no recoil
  43. *
  44. * Client Commands:
  45. * say /recoil - return to normal recoil
  46. * say /norecoil - buy no recoil
  47. *
  48. * CVARs:
  49. * sv_norecoil <1/0> - enables/disables buying no recoil
  50. * sv_norecoil_tell <1/0> - tells everyone about no recoil on connect
  51. * sv_norecoil_cost <$> - sets the price of no recoil
  52. */
  53.  
  54. #include <amxmodx>
  55. #include <amxmisc>
  56. #include <engine>
  57. #include <cstrike>
  58.  
  59. #define ADMIN_FLAG ADMIN_LEVEL_H // replace this with any admin flag
  60.  
  61. new reco[33]
  62.  
  63. public plugin_init()
  64. {
  65. register_plugin("No Recoil","1.3","Blitz/Petey B")
  66.  
  67. register_dictionary("amx_norecoil.txt")
  68.  
  69. register_concmd("amx_norecoil","admin_norecoil",ADMIN_FLAG,"<nick, part of nick, @TEAM or *ALL>")
  70. register_concmd("amx_recoil","admin_recoil",ADMIN_FLAG,"<nick, part of nick, @TEAM or *ALL>")
  71.  
  72. register_clcmd("say /norecoil","noreco",0,": Purchases no recoil")
  73. register_clcmd("say /recoil","recoi",0,": Returns recoil to normal")
  74.  
  75. register_cvar("sv_norecoil","1")
  76. register_cvar("sv_norecoil_tell","1")
  77. register_cvar("sv_norecoil_cost","5000")
  78.  
  79. register_event("ResetHUD","newRound","b")
  80. register_event("CurWeapon","change_weapon","be","1=1")
  81. }
  82.  
  83. public plugin_modules()
  84. {
  85. require_module("engine")
  86. require_module("cstrike")
  87. }
  88.  
  89. public client_putinserver(id)
  90. {
  91. if (is_user_bot(id))
  92. return
  93. set_task(15.0, "recoMsg", id)
  94. }
  95.  
  96. public recoMsg(id)
  97. {
  98. if (get_cvar_num("sv_norecoil")==1)
  99. {
  100. if (get_cvar_num("sv_norecoil_tell")==1)
  101. {
  102. client_print(0, print_chat, "%L", LANG_PLAYER, "NR_CHECK_TELL")
  103. }
  104. }
  105. }
  106.  
  107. public admin_norecoil(id)
  108. {
  109. if (!(get_user_flags(id)&ADMIN_FLAG))
  110. {
  111. console_print(id, "%L", LANG_PLAYER, "AMX_ACCESS_DENIED")
  112. return PLUGIN_HANDLED
  113. }
  114. if (read_argc() <2)
  115. {
  116. client_print(id, print_console, "%L", LANG_PLAYER, "AMX_NR_USAGE")
  117. return PLUGIN_HANDLED
  118. }
  119. new arg[32], name2[32]
  120. read_argv(1,arg,31)
  121. get_user_name(id,name2,31)
  122. set_hudmessage(255, 25, 25, -1.0, 0.25, 0, 1.0, 9.0, 0.2, 0.4, 2)
  123. if (arg[0]=='@')
  124. {
  125. new players[32], inum, i
  126. get_players(players,inum,"ae",arg[1])
  127. if (inum==0)
  128. {
  129. console_print(id, "%L", LANG_PLAYER, "AMX_TEAM_FAILED")
  130. return PLUGIN_CONTINUE
  131. }
  132. else if (reco[players[i]]==1)
  133. {
  134. console_print(id, "%L", LANG_PLAYER, "AMX_NR_TEAM_EXISTS", arg[1])
  135. return PLUGIN_HANDLED
  136. }
  137. for (i=0; i<inum; ++i)
  138. {
  139. reco[players[i]] = 1
  140. }
  141. switch (get_cvar_num("amx_show_activity"))
  142. {
  143. case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_NR_TEAM_SET2", name2, arg[1])
  144. case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_NR_TEAM_SET1", arg[1])
  145. }
  146. console_print(id, "%L", LANG_PLAYER, "AMX_NR_TEAM_SET", arg[1])
  147. show_hudmessage(0, "%L", LANG_PLAYER, "HUD_NR_TEAM_SET", arg[1])
  148. return PLUGIN_CONTINUE
  149. }
  150. else if (arg[0]=='*')
  151. {
  152. new players[32], inum, i, changed
  153. get_players(players, inum)
  154. for (i=0; i<inum; ++i)
  155. {
  156. if(!is_user_connected(players[i]))
  157. continue
  158. if (reco[players[i]]!=1)
  159. {
  160. reco[players[i]] = 1; changed = 1;
  161. console_print(i, "%L", LANG_PLAYER, "AMX_NR_ALL_SET")
  162. }
  163. }
  164. if (changed==0)
  165. {
  166. console_print(id, "%L", LANG_PLAYER, "AMX_NR_ALL_EXISTS")
  167. }
  168. else
  169. {
  170. show_hudmessage(0, "%L", LANG_PLAYER, "HUD_NR_ALL_SET")
  171. }
  172. }
  173. else
  174. {
  175. new player = cmd_target(id,arg,0)
  176. new name[32]
  177. get_user_name(player,name,31)
  178. if (!player)
  179. {
  180. console_print(id, "%L", LANG_PLAYER, "AMX_CLIENT_FAILED")
  181. return PLUGIN_CONTINUE
  182. }
  183. else if (reco[player]==1)
  184. {
  185. console_print(id, "%L", LANG_PLAYER, "AMX_NR_CLIENT_EXISTS", name)
  186. return PLUGIN_HANDLED
  187. }
  188. reco[player] = 1
  189. switch (get_cvar_num("amx_show_activity"))
  190. {
  191. case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_NR_CLIENT_SET2", name2, name)
  192. case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_NR_CLIENT_SET1", name)
  193. }
  194. console_print(id, "%L", LANG_PLAYER, "AMX_NR_CLIENT_SET", name)
  195. show_hudmessage(0, "%L", LANG_PLAYER, "HUD_NR_CLIENT_SET", name)
  196. }
  197. return PLUGIN_HANDLED
  198. }
  199.  
  200. public admin_recoil(id)
  201. {
  202. if (!(get_user_flags(id)&ADMIN_FLAG))
  203. {
  204. console_print(id, "%L", LANG_PLAYER, "AMX_ACCESS_DENIED")
  205. return PLUGIN_HANDLED
  206. }
  207. if (read_argc() <2)
  208. {
  209. client_print(id, print_console, "%L", LANG_PLAYER, "AMX_R_USAGE")
  210. return PLUGIN_HANDLED
  211. }
  212. new arg[32], name2[32]
  213. read_argv(1,arg,31)
  214. get_user_name(id,name2,31)
  215. set_hudmessage(25, 125, 200, -1.0, 0.25, 0, 1.0, 9.0, 0.2, 0.4, 2)
  216. if (arg[0]=='@')
  217. {
  218. new players[32], inum, i
  219. get_players(players,inum,"ae",arg[1])
  220. if (inum==0)
  221. {
  222. console_print(id, "%L", LANG_PLAYER, "AMX_TEAM_FAILED")
  223. return PLUGIN_CONTINUE
  224. }
  225. else if (reco[players[i]]==0)
  226. {
  227. console_print(id, "%L", LANG_PLAYER, "AMX_R_TEAM_EXISTS", arg[1])
  228. return PLUGIN_HANDLED
  229. }
  230. for (i=0; i<inum; ++i)
  231. {
  232. reco[players[i]] = 0
  233. }
  234. switch (get_cvar_num("amx_show_activity"))
  235. {
  236. case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_R_TEAM_SET2", name2, arg[1])
  237. case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_R_TEAM_SET1", arg[1])
  238. }
  239. console_print(id, "%L", LANG_PLAYER, "AMX_R_TEAM_SET", arg[1])
  240. show_hudmessage(0, "%L", LANG_PLAYER, "HUD_R_TEAM_SET", arg[1])
  241. return PLUGIN_CONTINUE
  242. }
  243. else if (arg[0]=='*')
  244. {
  245. new players[32], inum, i, changed
  246. get_players(players, inum)
  247. for (i=0; i<inum; ++i)
  248. {
  249. if(!is_user_connected(players[i]))
  250. continue
  251. if (reco[players[i]]!=0)
  252. {
  253. reco[players[i]] = 0; changed = 1;
  254. console_print(i, "%L", LANG_PLAYER, "AMX_R_ALL_SET")
  255. }
  256. }
  257. if (changed==0)
  258. {
  259. console_print(id, "%L", LANG_PLAYER, "AMX_R_ALL_EXISTS")
  260. }
  261. else
  262. {
  263. show_hudmessage(0, "%L", LANG_PLAYER, "HUD_R_ALL_SET")
  264. }
  265. }
  266. else
  267. {
  268. new player = cmd_target(id,arg,0)
  269. new name[32]
  270. get_user_name(player,name,31)
  271. if (!player)
  272. {
  273. console_print(id, "%L", LANG_PLAYER, "AMX_CLIENT_FAILED")
  274. return PLUGIN_CONTINUE
  275. }
  276. else if (reco[player]==0)
  277. {
  278. console_print(id, "%L", LANG_PLAYER, "AMX_R_CLIENT_EXISTS", name)
  279. return PLUGIN_HANDLED
  280. }
  281. reco[player] = 0
  282. switch (get_cvar_num("amx_show_activity"))
  283. {
  284. case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_R_CLIENT_SET2", name2, name)
  285. case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "AMX_R_CLIENT_SET1", name)
  286. }
  287. console_print(id, "%L", LANG_PLAYER, "AMX_R_CLIENT_SET", name)
  288. show_hudmessage(0, "%L", LANG_PLAYER, "HUD_R_CLIENT_SET", name)
  289. }
  290. return PLUGIN_HANDLED
  291. }
  292.  
  293. public noreco(id)
  294. {
  295. if (get_cvar_num("sv_norecoil")==1)
  296. {
  297. if (!is_user_alive(id))
  298. {
  299. client_print(id, print_center, "%L", LANG_PLAYER, "NR_CHECK_ALIVE")
  300. return PLUGIN_HANDLED
  301. }
  302. }
  303. new money = cs_get_user_money(id)
  304. new recocost = get_cvar_num("sv_norecoil_cost")
  305. if (get_cvar_num("sv_norecoil")==0)
  306. {
  307. client_print(id, print_center, "%L", LANG_PLAYER, "AMX_CHECK_DISABLED")
  308. }
  309. else if (money < recocost)
  310. {
  311. client_print(id, print_center, "%L", LANG_PLAYER, "NR_CHECK_MONEY", recocost)
  312. }
  313. else
  314. {
  315. if (reco[id])
  316. {
  317. client_print(id, print_center, "%L", LANG_PLAYER, "NR_CHECK_EXISTS")
  318. }
  319. else if (get_cvar_num("sv_norecoil")==1)
  320. {
  321. cs_set_user_money(id, money - recocost)
  322. reco[id] = 1
  323. client_cmd(id, "spk items/clipinsert1.wav")
  324. client_print(id, print_center, "%L", LANG_PLAYER, "NR_CHECK_BUY")
  325. }
  326. }
  327. return PLUGIN_HANDLED
  328. }
  329.  
  330. public recoi(id)
  331. {
  332. if (get_cvar_num("sv_norecoil")==0)
  333. {
  334. client_print(id, print_center, "%L", LANG_PLAYER, "AMX_CHECK_DISABLED")
  335. }
  336. else
  337. {
  338. if (reco[id]==0)
  339. {
  340. client_print(id, print_center, "%L", LANG_PLAYER, "R_CHECK_EXISTS")
  341. }
  342. else if (reco[id]==1)
  343. {
  344. client_print(id, print_center, "%L", LANG_PLAYER, "R_CHECK_RETURN")
  345. reco[id] = 0
  346. client_cmd(id, "spk items/cliprelease1.wav")
  347. }
  348. }
  349. }
  350.  
  351. public newRound(id)
  352. {
  353. if (reco[id]==1)
  354. {
  355. client_print(id, print_center, "%L", LANG_PLAYER, "R_CHECK_RETURN")
  356. }
  357. reco[id] = 0
  358. return PLUGIN_HANDLED
  359. }
  360.  
  361. public client_PreThink(id)
  362. {
  363. if (reco[id]==1)
  364. {
  365. entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
  366. }
  367. }
  368.  
  369. public change_weapon(id)
  370. {
  371. if (reco[id]==1)
  372. {
  373. entity_set_vector(id, EV_VEC_punchangle, Float:{0.0, 0.0, 0.0})
  374. }
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement