Public feed
#600866
--- [[ Global Variables ]] ----------
g_arena = nil -- The global arena class, to avoid having to pass it around functions
g_bGameRunning = false -- Is the game running?
--- [[ Functions ]] -------
-- when the arena is created, it runs this
function Arena_OnCreate(arena)
g_arena = arena
math.randomseed(os.time())
end
-- Code in this function is carried out when the player joins
function Player_OnJoin(player)
player:message("Debug message: Lua loaded")
end
-- when the game starts, it sets gameRunning to true
function Arena_OnGameStart()
g_bGameRunning = true
end
-- when the game finishes, it sets gameRunning to false
function Arena_OnGameEnd()
g_bGameRunning = false
end
-- Human Drops
function Vehicle_OnDeath(victim, killer, itemid)
local c = victim:coords()
local vid = victim:vehicletypeid()
if (vid == 10) then
g_arena:item_create("PDA", 1, c.x, c.y)
end
-- Snork Drops
function Vehicle_OnDeath(victim, killer, itemid)
local c = victim:coords()
local vid = victim:vehicletypeid()
if (vid == 100) then
g_arena:item_create("PDA", 2, c.x, c.y)
end
-- Zombie Drops
function Vehicle_OnDeath(victim, killer, itemid)
local c = victim:coords()
local vid = victim:vehicletypeid()
if (vid == 101) then
g_arena:item_create("PDA", 2, c.x, c.y)
end
-- Silo Resouces upon death
function Vehicle_OnDeath(victim, killer, itemid)
local c = victim:coords()
local vid = victim:vehicletypeid()
if (vid == 411) then
g_arena:item_create("Basic Resources", 5, c.x, c.y)
end
end
--The Following is the script for putting everyone on their respective team.
function Player_OnUnspec(plyr) -- player
local vid = plyr:getVehicle():vehicletypeid()
--Lets assign are unspeccer a team... That bastard
-- We only have two options, either hes a Human or hes a Mutant.
if (vid == 10) then --Oh that mother fucker is a human... Well we know what to do with mother fuckers like that dont we Prae?
plyr:changeTeam("Humans","adminonly") -- Put that mother fucker on the Human team!
return true
elseif (vid == 100) then -- If they are a Snork lets put them on that team.
plyr:changeTeam("Snork Mutants","adminonly") -- Put those fucker son the Mutant Team!
if (plyr:getTeam():num() <= 5) then --But if they have 5 or fewer players lets let them choose to be on that team
plyr:message("You currently have 5 or fewer players on your team.")
plyr:message("If you wish to switch to a team with more people use ?newteam.")
end
return true
elseif (vid == 101) then -- If they are Zombified lets put them on that team.
plyr:changeTeam("Zombified Mutants","adminonly") -- Put those fucker son the Mutant Team!
if (plyr:getTeam():num() <= 5) then --But if they have 5 or fewer players lets let them choose to be on that team
plyr:message("You currently have 5 or fewer players on your team.")
plyr:message("If you wish to switch to a team with more people use ?newteam.")
end
return true
else --if they are noe of the above dont let them unspec
plyr:message("Pick a class")
return false
end
return false -- return boolean (whether to allow the player to unspec or not)
end
function Msg_OnCommand(plyr, command, payload, recipient, msg_type) -- player, string, string, string, integer
local newteam = payload
if (command == "?newteam") then -- Are they trying to get a new team?
if (plyr:getTeam():num() <= 5) then -- Are they less than 5 people.
if (payload == "Zombified" or payload == "Snork") then -- Make sure they are trying to get on a new team
if (newteam:num() >= 5) then -- Does the new team have 5 or more people?
plyr:message("You will now be transfered to the new team.")
plyr:changeTeam(payload .. " Mutants", "adminonly")
end
plyr:message("That team is to small.")
end
plyr:message("You need to Specify which Mutant team to join. E.X ?newteam rodent")
end
plyr:message("You have more than 5 people, you cannot abandon your team")
end
if (command == "?deposit") then -- Are they trying to Deposit something?
if (payload ~= "") then -- If they forgot to put in a item name
if (plyr:getStat(1) == 1) then -- They have talked to a banker
plyr:inventory_modify(payload, -1) -- Take the item from them
plyr:inventory_modify(payload .. "depot", 1) -- Give them the depot version of that item EX. Pistol's Depo version is called Pistoldepot
plyr:message("You have succesfully deposited 1 " .. payload .. ".")
plyr:setStat(1 , 0)
else
plyr:message("You need to talk to a banker first")
end
else
plyr:message("You need to Deposit something with this. E.X. ?deposit Pistol")
end
end
if (command == "?withdraw") then -- are they trying to take something Back?
if (payload ~= "") then -- If they forgot to put in an Item name
if (plyr:inventory_find(payload .. "depot") >= 1) then -- they have the depot item?
if (plyr:getStat(1) == 1) then -- They ahve talked to a banker.
plyr:inventory_modify(payload .. "depot", -1)
plyr:inventory_modify(payload, 1)
plyr:message("You have successfuly withdrawn 1 " .. payload .. ".")
plyr:setStat(1 , 0)
else
plyr:message("You need to talk to a banker first!")
end
else
plyr:message("You have no " .. payload .. " to withdraw.")
end
else
plyr:message("You need to Withdraw something with this. E.X. ?Withdraw Pistol")
end
end
end
function Vehicle_OnProduce(vech, plyr, menuitem) -- vehicle, player, integer
local vid = vech:vehicletypeid()
if (vid == 410) then -- Make sure they are talking to the banker
plyr:setStat(1, 1) -- Stat index 1 is going to be "Have they talked to a banker" set it to they have.
if (menuitem == 0) then --they are using the first menu item
plyr:message("You can now withdraw or deposit an item using ?depost <item name> or ?withdraw <item name>")
return true
end
return true
end
return true --return boolean (whether to allow the produce or not)
end