Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Grenade Refill by H® Shaft for SAPP
- -- Allows you to setup a call for a grenade refill and a limit per game that each player can call for a refill
- -- Players type "Refill" in chat, and are given a grenade refill if they are alive and within the refill limit.
- -- Each time players call for a refill, they are told how many refill calls they have remaining, and if they have reached the limit (refill_limit below)
- -- all players are notified: "H® Shaft called for a grenades REFILL" - which helps other players to know they can type REFILL too.
- -- set grenade counts to what you want them each time a player requests a grenade REFILL:
- frag_count = 2
- plasma_count = 1
- refill_limit = 3 -- Number of times a player can call a grenade REFILL during the current game.
- -- sapp api version
- api_version = "1.8.0.0"
- -- don't edit --
- refill_player = {}
- game_started = false
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'],"OnNewGame")
- register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
- register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
- register_callback(cb['EVENT_CHAT'], "OnPlayerChat")
- end
- function OnScriptUnload() end
- function OnPlayerJoin(PlayerIndex)
- if player_present(PlayerIndex) then
- refill_player[PlayerIndex] = 0
- end
- end
- function OnNewGame()
- game_started = true
- for i = 1,16 do
- if player_present(i) then
- refill_player[i] = 0
- end
- end
- end
- function OnGameEnd()
- game_started = false
- refill_player = {}
- end
- function OnPlayerChat(PlayerIndex, Message)
- local response = nil
- local name = get_var(PlayerIndex,"$name")
- local Message = string.lower(Message)
- if (Message == "refill") or (Message == "refill?") then
- response = false
- if refill_player[PlayerIndex] < refill_limit then
- if game_started then
- if player_alive(PlayerIndex) then
- say_all(string.format("%s called for grenades REFILL.", tostring(name)))
- refill_player[PlayerIndex] = refill_player[PlayerIndex] + 1
- timer(500, "GiveNades", PlayerIndex)
- say(PlayerIndex, "Grenades Refill: " ..plasma_count.. " Plamsa, and " ..frag_count.. " Frags. You have " .. refill_limit - refill_player[PlayerIndex] .. " grenade refills remaining.")
- say_all(string.format("%s requested a grenade REFILL. ", tostring(name)))
- else
- say(PlayerIndex, "Oops! You are dead, grenades wont help you. Refill cancelled.")
- end
- end
- else
- say(PlayerIndex, "You have reached the grenade refill limit of " .. refill_limit .. " per game. Refill cancelled.")
- end
- end
- return response
- end
- function GiveNades(PlayerIndex)
- if player_present(PlayerIndex) then
- if game_started then
- if player_alive(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- safe_write(true)
- write_word(player_object + 0x31E, frag_count)
- write_word(player_object + 0x31F, plasma_count)
- safe_write(false)
- end
- end
- end
- return false
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement