Advertisement
HR_Shaft

Setup Player Grenades for SAPP

Oct 30th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. -- Setup Player Grenades for SAPP
  2. -- by H® Shaft
  3.  
  4. -- Allows server admins to set number of frag and plasma grenades per map, assigned when player spawns.
  5. -- See line 42 - load tables to modify the grenade counts you prefer per map, and to add maps.
  6. -- WILL work with stock pc and custom CE maps
  7.  
  8. -- sapp api version
  9. api_version = "1.8.0.0"
  10.  
  11. function OnScriptLoad()
  12.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  13.     register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
  14.     map_name = get_var(0,"$map")
  15.     Load_Tables()
  16. end
  17.  
  18. function OnScriptUnload()
  19.     frag_count = {}
  20.     plasma_count = {}
  21. end
  22.  
  23. function OnNewGame()
  24.     map_name = get_var(0,"$map")
  25.     Load_Tables()
  26. end
  27.  
  28. function GameEnd()
  29.     game_started = false
  30. end
  31.  
  32. function OnPlayerSpawn(PlayerIndex)
  33.     if player_alive(PlayerIndex) then
  34.         local player_object = get_dynamic_player(PlayerIndex)
  35.         safe_write(true)
  36.         write_word(player_object + 0x31E, frag_count[map_name])
  37.         write_word(player_object + 0x31F, plasma_count[map_name])
  38.         safe_write(false)
  39.     end
  40. end
  41.  
  42. function Load_Tables()
  43.     -- specify the number of frag grenades when player spawns
  44.     -- each map in this table, must be separated with a comma
  45.    
  46.     -- map name         # count
  47.     frag_count = {
  48.         beavercreek     =   2,
  49.         beavercreek     =   0,
  50.         bloodgulch      =   2,
  51.         boardingaction  =   2,
  52.         carousel        =   1,
  53.         chillout        =   0,
  54.         damnation       =   1,
  55.         dangercanyon    =   2,
  56.         deathisland     =   4,
  57.         gephyrophobia   =   2,
  58.         hangemhigh      =   1,
  59.         icefields       =   2,
  60.         infinity        =   4,
  61.         longest         =   1,
  62.         prisoner        =   2,
  63.         putput          =   0,
  64.         ratrace         =   1,
  65.         sidewinder      =   2,
  66.         timberland      =   2,
  67.         wizard          =   1,
  68.     }
  69.    
  70.     -- specify the number of plasma grenades when player spawns
  71.     -- map name         # count
  72.    
  73.     plasma_count = {
  74.         beavercreek     =   0,
  75.         bloodgulch      =   2,
  76.         boardingaction  =   2,
  77.         carousel        =   1,
  78.         chillout        =   0,
  79.         damnation       =   1,
  80.         dangercanyon    =   2,
  81.         deathisland     =   4,
  82.         gephyrophobia   =   2,
  83.         hangemhigh      =   1,
  84.         icefields       =   2,
  85.         infinity        =   4,
  86.         longest         =   1,
  87.         prisoner        =   2,
  88.         putput          =   2,
  89.         ratrace         =   1,
  90.         sidewinder      =   2,
  91.         timberland      =   2,
  92.         wizard          =   1, 
  93.     }
  94.  
  95. end
  96.  
  97. -- Created by H® Shaft
  98. -- Visit Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement