All pastes #604996 Raw Edit

Stuff

public lua v1 · immutable
·published 2007-07-05 21:53 UTC
rendered paste body
--- [[ Global Variables ]] ---------- g_arena = nil      -- The global arena class, to avoid having to pass it around functionsg_bGameRunning = false  -- Is the game running?--- [[ Functions ]] --------- when the arena is created, it runs thisfunction 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 truefunction Arena_OnGameStart()	g_bGameRunning = trueend-- when the game finishes, it sets gameRunning to falsefunction Arena_OnGameEnd()	g_bGameRunning = falseend-- Silo Resouces upon deathfunction 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)	elseif (vid == 412) then --Bandito death drop		g_arena:item_create("PDA", 1, c.x, c.y)		g_arena:item_create("Human Blood", 2, c.x, c.y)			elseif (vid == 413) then --Bandito Sniper death drop		g_arena:item_create("PDA", 1, c.x, c.y)		g_arena:item_create("Human Blood", 2, c.x, c.y)		elseif (vid == 414) then --Bandito Heavy death drop		g_arena:item_create("PDA", 1, c.x, c.y)		g_arena:item_create("Human Blood", 2, c.x, c.y)	    endend	-- Human Death Dropfunction Player_OnDeath(killer, victim)	local c = victim:coords()	local vid = victim:getVehicle():vehicletypeid()		if (vid == 10) then		g_arena:item_create("PDA", 1, c.x, c.y)		g_arena:item_create("Human Blood", 2, c.x, c.y)	elseif (vid == 100) then -- snork death drop		g_arena:item_create("Mutant Blood", 2, c.x, c.y)		g_arena:item_create("Mutant Heart", 1, c.x, c.y)	elseif (vid == 101) then --zombie death drop		g_arena:item_create("Mutant Blood", 2, c.x, c.y)		g_arena:item_create("Mutant Heart", 1, c.x, c.y)   	end		--Lets find out if they are killing in a neutral location...	if (neutralLoc(killer) == true) then -- They are in a neutral location		if (killer:getFrequency() == victim:getFrequency()) then -- They are both on the same team			if (killer:getRequency() == 1) then -- They are on the Human team				killer:setFrequency(599) --Just set them to some random team so that the npcs around them shoot them.				killer:setStat(2, 1) -- Set the stat to 1			end		end	end		--If someone who is running from npcs dies lets make them teamed again	if (victim:getStat(2) == 1) then -- They are running from NPCS		victim:setFrequency(1) --Put them back on team		victim:setStat(2, 0) -- make that nothing again	end		end	function Reload()dofile("stalker.lua")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 our 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:setFrequency(0) -- 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:unspec("Snorks","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:unspec("Zombies","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)endfunction 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	endfunction 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)endfunction neutralLoc(plyr)	--coords of the top left of the area	local g_x1 = 1791	local g_y1 = 1546	--coords of the bottom right of the area	local g_x2 = 2063	local g_y2 = 1682	local coords = plyr:coords()		if (((coords.x > g_x1) and (coords.x < g_x2) and (coords.y > g_y1) and (coords.y < g_y2))) then		return true	else		return false	endend