Guest User

Untitled

a guest
Aug 11th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < cstrike >
  3. #include < fakemeta_util >
  4. #include < fvault >
  5.  
  6. new const g_vault_name[] = "HNR_Vault";
  7.  
  8. new HNR_points[ 33 ]
  9. new HNR_maxplayers;
  10. new HNR_cvar;
  11.  
  12. forward ForwardClientWin( client );
  13.  
  14. enum _:Options
  15. {
  16. HNR_M4A1,
  17. HNR_INVISIBILITY,
  18. HNR_AK47,
  19. HNR_SPEED,
  20. HNR_NOCLIP
  21. };
  22.  
  23. new OptionsName[ Options ][ ] =
  24. {
  25. "M4a1",
  26. "Invisibilty",
  27. "Ak47",
  28. "Speed",
  29. "Noclip"
  30. };
  31.  
  32. new OptionsPrices[ Options ] =
  33. {
  34. 40,
  35. 70,
  36. 40,
  37. 70,
  38. 100
  39. };
  40.  
  41. public plugin_init()
  42. {
  43. register_plugin("Hit And Run Shop", "1.0", "iStrike")
  44.  
  45. register_clcmd("say /shop", "ShopMenu")
  46. register_clcmd("say /hnrshop", "ShopMenu")
  47.  
  48. HNR_cvar = register_cvar("hnr_shop", "1")
  49.  
  50. HNR_maxplayers = get_maxplayers();
  51.  
  52. register_event( "HLTV", "Event_New_Round", "a", "1=0", "2=0" )
  53. }
  54.  
  55. public Event_New_Round()
  56. {
  57. for ( new i; i <= HNR_maxplayers; i++ )
  58. {
  59. if ( !is_user_connected( i ) || !is_user_alive( i ) )
  60. continue;
  61.  
  62. fm_set_user_maxspeed(i, 250.0)
  63. fm_set_user_noclip(i, 0)
  64. fm_set_user_rendering(i)
  65. }
  66. }
  67.  
  68. public client_putinserver(plr)
  69. {
  70. LoadPoints(plr)
  71. }
  72.  
  73. public client_disconnect(plr)
  74. {
  75. SavePoints(plr)
  76. }
  77.  
  78. public ShopMenu(id)
  79. {
  80. if ( get_pcvar_num( HNR_cvar ) )
  81. {
  82. if ( is_user_alive( id ) )
  83. {
  84. new Shopmenu = menu_create("\r[\d Hit And Run \r] \ySelect Your Shop Items", "ShopHandler")
  85.  
  86. static Option[ 64 ], szNum[ 10 ];
  87.  
  88. for ( new i; i < Options; i ++ )
  89. {
  90. num_to_str( i + 1, szNum, charsmax( szNum ) )
  91.  
  92. formatex( Option, charsmax( Option ), "%s \dFor A Game \r[\d %d \r]", OptionsName[ i ], OptionsPrices[ i ] )
  93.  
  94. menu_additem(Shopmenu, Option, szNum )
  95. }
  96.  
  97. menu_setprop(Shopmenu, MPROP_EXIT, MEXIT_ALL )
  98.  
  99. menu_display(id, Shopmenu)
  100. }
  101.  
  102. else
  103. {
  104. ColorChat(id, "You Must Be Aive To Open The Hit And Run Shop")
  105. }
  106. }
  107. }
  108.  
  109. public ShopHandler(id, Shopmenu, item)
  110. {
  111. if ( item == MENU_EXIT || !get_pcvar_num( HNR_cvar ) )
  112. {
  113. menu_destroy( Shopmenu )
  114.  
  115. return PLUGIN_HANDLED;
  116. }
  117.  
  118. new data[6], iName[64]
  119. new access, callback
  120.  
  121. menu_item_getinfo(Shopmenu, item, access, data, 6, iName, 63, callback)
  122.  
  123. new key = str_to_num( data );
  124.  
  125. if ( HNR_points[ id ] < OptionsPrices[ key - 1 ] )
  126. {
  127. ColorChat( id, "You Dont Have Enough Points !" )
  128.  
  129. menu_destroy( Shopmenu )
  130.  
  131. return PLUGIN_HANDLED;
  132. }
  133.  
  134. switch( key - 1 )
  135. {
  136. case HNR_M4A1: fm_give_item(id, "weapon_m4a1") && cs_set_user_bpammo(id, CSW_M4A1, 9999)
  137. case HNR_INVISIBILITY: fm_set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
  138. case HNR_AK47: fm_give_item(id, "weapon_ak47") && cs_set_user_bpammo(id, CSW_AK47, 9999)
  139. case HNR_SPEED: fm_set_user_maxspeed(id, 900.0)
  140. case HNR_NOCLIP: fm_set_user_noclip(id, 1)
  141. }
  142.  
  143. HNR_points[ id ] -= OptionsPrices[ key - 1 ];
  144.  
  145. ColorChat(id, "You Bought %s For A Game", OptionsName[ key - 1 ] )
  146.  
  147. menu_destroy(Shopmenu)
  148.  
  149. return PLUGIN_HANDLED;
  150. }
  151.  
  152. public ForwardClientWin( client )
  153. {
  154. if ( is_user_connected( client ) )
  155. {
  156. HNR_points[ client ] += 4;
  157. }
  158. }
  159.  
  160. LoadPoints(plr)
  161. {
  162. new authid[35], data[16];
  163.  
  164. get_user_authid(plr, authid, sizeof(authid) - 1);
  165.  
  166. if( fvault_get_data(g_vault_name, authid, data, sizeof(data) - 1) )
  167. HNR_points[plr] = str_to_num(data);
  168.  
  169. else
  170. HNR_points[plr] = 0;
  171. }
  172.  
  173. SavePoints(plr)
  174. {
  175. new authid[35];
  176. get_user_authid(plr, authid, sizeof(authid) - 1);
  177.  
  178. new data[16];
  179. num_to_str(HNR_points[plr], data, sizeof(data) - 1);
  180.  
  181. fvault_set_data(g_vault_name, authid, data);
  182. }
  183.  
  184. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
  185. new msg[191], players[32], count = 1;
  186.  
  187. static len; len = formatex(msg, charsmax(msg), "^3[^1 Hit And Run Shop ^3]^1 ");
  188. vformat(msg[len], charsmax(msg) - len, string, 3);
  189.  
  190. if(id) players[0] = id;
  191. else get_players(players,count,"ch");
  192.  
  193. for (new i = 0; i < count; i++)
  194. {
  195. if(is_user_connected(players[i]))
  196. {
  197. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i]);
  198. write_byte(players[i]);
  199. write_string(msg);
  200. message_end();
  201. }
  202. }
  203. }
Add Comment
Please, Sign In to add comment