HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <fvault>
  4. #include <fun>
  5. #include <cstrike>
  6. ///Fordította DarkFly
  7. new SZ_Password[ 192 ]
  8. new SZ_Password_T[ 33 ][ 192 ]
  9.  
  10. new Registrado[ 33 ]
  11. new BadPassword[ 33 ]
  12.  
  13. new const Vault[] = "GrenadeGame_Datos"
  14.  
  15. new gCvarPluginToggle
  16. new cvar_active
  17.  
  18. new g_PlayerXP[33];
  19. new g_PlayerLevel[33];
  20.  
  21. new gBuyCommands[][] = {
  22. "usp", "glock", "deagle", "p228", "elites", "fn57", "m3", "xm1014", "mp5", "tmp", "p90", "mac10", "ump45", "ak47",
  23. "galil", "famas", "sg552", "m4a1", "aug", "scout", "awp", "g3sg1", "sg550", "m249", "vest", "vesthelm", "flash", "hegren",
  24. "sgren", "defuser", "nvgs", "shield", "primammo", "secammo", "km45", "9x19mm", "nighthawk", "228compact", "12gauge",
  25. "autoshotgun", "smg", "mp", "c90", "cv47", "defender", "clarion", "krieg552", "bullpup", "magnum", "d3au1", "krieg550",
  26. "buyammo1", "buyammo2"
  27. }
  28.  
  29. #define NUM_OF_LEVELS 10
  30.  
  31. new const LEVELS[NUM_OF_LEVELS] = {
  32. 100,
  33. 200,
  34. 400,
  35. 800,
  36. 1600,
  37. 3200,
  38. 6400,
  39. 12800,
  40. 25600,
  41. 51200
  42. }
  43.  
  44. new const szHealth[] = {
  45. 105, 110, 115, 120, 125, 130, 135, 140, 145, 150
  46. }
  47. new const szVelocity[] = {
  48. 252, 254, 256, 260, 263, 267, 271, 275, 279, 284
  49. }
  50.  
  51. new gmsgStatusText;
  52.  
  53. #define PLUGIN "Grenade"
  54. #define AUTHOR "VodKa"
  55. #define VERSION "1.2"
  56.  
  57. /* Register mod by Kiske */
  58.  
  59. public plugin_init()
  60. {
  61. register_forward( FM_ClientUserInfoChanged, "FWClientUserInfoChanged" )
  62. register_event("CurWeapon" , "Event_CurWeapon" , "be" , "1=1" );
  63. gCvarPluginToggle = register_cvar("amx_block_buy", "1")
  64. cvar_active = register_cvar("amx_grenade", "1")
  65. register_plugin(PLUGIN, VERSION, AUTHOR)
  66. register_logevent("Ham_PlayerSpawn", 2, "1=Round_Start");
  67. register_clcmd( "say /registrarse", "CMDRegistrarse" )
  68. register_clcmd( "IntroducirContrasenia", "CMDIntroducirContrasenia" )
  69. register_cvar("sv_grenadegame", "1")
  70. register_event("DeathMsg", "DeathMsg", "a")
  71. register_cvar("XP_per_kill", "20")
  72. register_event("ResetHUD", "ResetHud", "b")
  73. gmsgStatusText = get_user_msgid("StatusText")
  74. register_event("Niveles", "Event_Niveles", "be", "1=1");
  75.  
  76. for (new i = 0; i < sizeof (gBuyCommands); i++)
  77. register_clcmd(gBuyCommands[i], "BlockBuyCommands")
  78. }
  79.  
  80. public DeathMsg()
  81. {
  82. if (!get_cvar_num("sv_grenadegame"))
  83. return;
  84.  
  85. new attacker = read_data(1)
  86. new victim = read_data(2)
  87.  
  88. if(g_PlayerLevel[attacker] == NUM_OF_LEVELS)
  89. return;
  90.  
  91. g_PlayerXP[attacker] += get_cvar_num("XP_per_kill")
  92.  
  93. if(g_PlayerXP[attacker] >= LEVELS[g_PlayerLevel[attacker]])
  94. {
  95. ++g_PlayerLevel[attacker];
  96.  
  97. client_print(attacker, _:print_chat, "[Grenade_Game] Gratulálunk szintet léptél %i!", g_PlayerLevel[attacker])
  98. }
  99. ShowHUD(attacker);
  100.  
  101. respawn_player(victim)
  102. give_item(victim, "weapon_hegrenade")
  103. give_item(victim, "weapon_flashbang")
  104. }
  105.  
  106. ShowHUD(id) {
  107. new HUD[51]
  108. format(HUD, 50, "[Grenade_Game] Szint: %i XP: %i", g_PlayerLevel[id], g_PlayerXP[id])
  109.  
  110. message_begin(MSG_ONE, gmsgStatusText, {0,0,0}, id)
  111. write_byte(0)
  112. write_string(HUD)
  113. message_end()
  114. }
  115.  
  116. public client_connect(id)
  117. {
  118. g_PlayerXP[id] = 0;
  119. g_PlayerLevel[id] = 0;
  120. }
  121.  
  122. public Event_Niveles(id)
  123. {
  124. set_pev(id, pev_health, szHealth[g_PlayerLevel[id]]);
  125. set_pev(id, pev_velocity, szVelocity[g_PlayerLevel[id]]);
  126. }
  127.  
  128. public client_disconnect(id)
  129. Save(id)
  130.  
  131. public client_putinserver(id)
  132. {
  133. Registrado[id] = 0
  134. BadPassword[id] = 0
  135. Load(id)
  136. }
  137.  
  138. public CMDRegistrarse(id)
  139. {
  140. if( Registrado[id] || BadPassword[id] )
  141. return PLUGIN_HANDLED;
  142.  
  143. client_cmd( id, "messagemode IntroducirContrasenia" )
  144.  
  145. return PLUGIN_CONTINUE;
  146. }
  147.  
  148. public CMDIntroducirContrasenia(id)
  149. {
  150. read_args( SZ_Password, 191 )
  151. remove_quotes( SZ_Password )
  152. trim( SZ_Password )
  153.  
  154. if( equal( SZ_Password, "" ) || contain( SZ_Password, " ") != -1)
  155. return PLUGIN_HANDLED;
  156. else
  157. {
  158. client_cmd(id, "setinfo _pass ^"%s^"", SZ_Password )
  159. Registrado[id] = 1
  160.  
  161. static SZ_Name[ 32 ], SZ_Data[ 512 ]
  162. get_user_name(id, SZ_Name, 31 )
  163.  
  164. formatex( SZ_Data, charsmax( SZ_Data ), "%s %d", SZ_Password, cs_get_user_money(id) )
  165.  
  166. fvault_set_data( Vault, SZ_Name, SZ_Data )
  167.  
  168. SZ_Password_T[id] = SZ_Password
  169.  
  170. return PLUGIN_HANDLED;
  171. }
  172.  
  173. return PLUGIN_CONTINUE;
  174. }
  175.  
  176. public Save(id)
  177. {
  178. if( !Registrado[id] || BadPassword[id] )
  179. return PLUGIN_HANDLED;
  180.  
  181. static SZ_Data[ 512 ], SZ_Name[ 32 ]
  182.  
  183. formatex( SZ_Data, charsmax( SZ_Data ), "%s %d", SZ_Password_T[id], cs_get_user_money(id) )
  184. get_user_name(id, SZ_Name, 31 )
  185.  
  186. fvault_set_data( Vault, SZ_Name, SZ_Data )
  187.  
  188. return PLUGIN_CONTINUE;
  189. }
  190.  
  191. public Load(id)
  192. {
  193. static SZ_Data[ 512 ], SZ_Name[ 32 ], SETINFO_Password[ 191 ], VAULT_Password[ 191 ], Dinero[ 11 ]
  194.  
  195. get_user_name(id, SZ_Name, 31 )
  196. get_user_info(id, "_pass", SETINFO_Password, 190 )
  197.  
  198. if( !fvault_get_data( Vault, SZ_Name, SZ_Data, charsmax( SZ_Data ) ) )
  199. return 0;
  200.  
  201. Registrado[id] = 1
  202.  
  203. parse( SZ_Data, VAULT_Password, 190, Dinero, 10 )
  204.  
  205. if( equal( SETINFO_Password, VAULT_Password ) )
  206. {
  207. SZ_Password_T[id] = SETINFO_Password
  208.  
  209. cs_set_user_money(id, str_to_num( Dinero ) )
  210.  
  211. return 2;
  212. }
  213. else
  214. {
  215. BadPassword[id] = 1
  216. set_hudmessage(255, 0, 0, -1.0, 0.15, 1, 6.0, 14.0)
  217. show_hudmessage(id, "Helytelen jelszó, próbálja újra");
  218. }
  219.  
  220. return 1;
  221. }
  222.  
  223. public FWClientUserInfoChanged(id, Buffer )
  224. {
  225. if( !is_user_connected(id) )
  226. return FMRES_IGNORED;
  227.  
  228. static NickName[32], NickOld[32]; get_user_name(id, NickOld, 31 )
  229. engfunc( EngFunc_InfoKeyValue, Buffer, "name", NickName, 31 )
  230.  
  231. if( equal( NickName, NickOld ) )
  232. return FMRES_IGNORED;
  233.  
  234. engfunc( EngFunc_SetClientKeyValue,id, Buffer, "name", NickOld )
  235.  
  236. client_cmd(id, "name ^"%s^"; setinfo name ^"%s^"", NickOld, NickOld )
  237.  
  238. return FMRES_SUPERCEDE;
  239. }
  240.  
  241. public BlockBuyCommands(id)
  242. {
  243. if (!get_pcvar_num(gCvarPluginToggle))
  244. return PLUGIN_CONTINUE;
  245.  
  246. return PLUGIN_HANDLED;
  247. }
  248.  
  249. public Ham_PlayerSpawn(id)
  250. {
  251. new players[32], num
  252. get_players(players, num, "a")
  253.  
  254. for( --num; num >= 0; num-- ) /* By ConnorMcLeod */
  255. {
  256. fm_strip_user_weapons(players[num])
  257. }
  258. }
  259.  
  260. public Event_CurWeapon( id )
  261. {
  262. if(get_pcvar_num(cvar_active))
  263. {
  264. new he = read_data(2)
  265.  
  266. if(he == CSW_HEGRENADE && is_user_alive(id))
  267.  
  268. return PLUGIN_CONTINUE
  269.  
  270. else
  271. {
  272. set_task(0.1, "he", id)
  273. }
  274. }
  275. else
  276. {
  277. return PLUGIN_CONTINUE;
  278. }
  279. return PLUGIN_HANDLED;
  280. }
  281.  
  282. public he(id)
  283. give_item(id,"weapon_hegrenade")
  284.  
  285. fm_strip_user_weapons( id ) {
  286. new iEnt = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "player_weaponstrip" ) );
  287.  
  288. if( !pev_valid( iEnt ) )
  289. return 0;
  290.  
  291. dllfunc( DLLFunc_Spawn, iEnt );
  292. dllfunc( DLLFunc_Use, iEnt, id );
  293. engfunc( EngFunc_RemoveEntity, iEnt );
  294.  
  295. return 1;
  296. }
  297.  
  298. /* By GHW_Chronic */
  299.  
  300. public respawn_player(id)
  301. {
  302. if(is_user_connected(id))
  303. {
  304. set_pev(id,pev_deadflag,DEAD_RESPAWNABLE);
  305. set_pev(id, pev_iuser1, 0);
  306. dllfunc(DLLFunc_Think,id)
  307.  
  308. engfunc(EngFunc_SetOrigin,id,Float:{-4800.0,-4800.0,-4800.0})
  309.  
  310. set_task(0.5,"spawnagain",id)
  311. }
  312. }
  313.  
  314. public spawnagain(id)
  315. {
  316. if(is_user_connected(id))
  317. {
  318. spawn(id)
  319. dllfunc(DLLFunc_Spawn,id)
  320. }
  321. }
  322.  
  323. /* XP Mod edit by VodKa' */
  324. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  325. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang11274\\ f0\\ fs16 \n\\ par }
  326. */
  327.