Public feed #601388

Anonymous

public lua v1 · immutable
Raw Edit
·published 2007-07-03 13:59 UTC
rendered paste body
 --Global Arerna -- g_arena=nil g_player=nil g_teamPod = { } g_teamCra = { } g_turret1 = { } g_turret2 = { } g_turret3 = { } g_podrewards = { } g_reploypod = nil function Arena_OnCreate(arena)	-- Set our global value	g_arena = arena	-- Initialize random	math.randomseed(os.time())	--Create Vendorsendfunction test()		local vech1 = g_arena:vehicle_create(411, 2188, 272, 99) --create trainer	local vech2 = g_arena:vehicle_create(400, 2385, 277, 145) --create Certificate dealer	vech1:setFrequency(65535)	vech2:setFrequency(65535)	g_arena:message("NPCS respawned Succseffuly")	end function Player_OnDeath(killer, victim) -- player, player			--Give them Attribute points.	if (victim:getExperience() <= 25000) then -- If they kill someone with more than 25000 experience		killer:message("You have gained 2 Attribute Points")		killer:modPoints(2) -- Give them 2 Attribute Points	elseif (victim:getExperience() <= 50000) then --If they kill someone with more than 50000 experience		killer:message("You have gained 5 Attribute Points")		killer:modPoints(5) -- Give them 5 Attribute Points	elseif (victim:getExperience() <= 75000) then --If they kill someone with more than 75000 experience		killer:message("You have gained 7 Attribute Points")		killer:modPoints(7) --  Give them 7 Attribute Points	elseif (victim:getExperience() <=100000) then -- If they kill someone with more than 100000 experience		killer:message("You have gained 10 Attribute Points")		killer:modPoints(10) -- Give them 10 Attribute Points	elseif (victim:getExperience() >=100001) then -- If they kill someone with more than 100000 experience		killer:message("You have gained 10 Attribute Points")		killer:modPoints(10) -- Give them 10 Attribute Points	end			--Check if they have enough Attribute Points and remind them how to spend them.	if (killer:getPoints() >= 50) then -- if they have 40 or more attribute points.		killer:message("You currently have 10 or more Attribute points, ")		killer:message("I suggest typing ?attribute if you have forgotten how to use them.")	end		end function loc(plyr)		local c = plyr:coords()		plyr:message("X = " .. c.x .. " Y = " .. c.y .. " Rotation = " .. c.rotation)end	function att()local tor = g_arena:getPlayer("Toriad")tor:modPoints(25)tor:message("you have 50 points!")end	function Player_OnJoin(player)		if (noSkills(player) == true)then		player:inventory_modify("Soldier",1)		player:message("It would seem you have never played Infantry RPG before, if this is true please type ?tutorial")	else		player:message("Welcome back to Infantry RPG " .. player.m_name .. ", type in ?login to join the world")	end			endfunction Player_OnUnspec(player) -- player	player:message("You need to type ?login")	return falseendfunction noSkills(player) -- Finds out if a player has skills	if (player:skillFind(1) == false) then		if (player:skillFind(10) == false) then			return true		end		return false	endendfunction Msg_OnCommand(plyr, command, payload, recipient, msg_type) -- player, string, string, string, integer	local player = plyr	local ore = ""	local style = "" 	local team_n = ""	local team_p = ""	local password = math.random(1,1000)	-- string.len("string") returns length of the string	-- string.find("string", ":") returns the position of the character found	-- if not found then returns nil.  Starts at 1.	-- string.sub("string", 1, 4) returns "stri", first index is the	-- starting position and last index is the ending position	-- string.sub("string", 4) returns "ing", with one argument	-- the function starts from the index and goes to the end		if (command == "?tutorial")then --Tutorial Command		player:message("Welcome to Infantry RPG, you will soon get used to ")		player:message("the style of gameplay however here are the basics.")		player:message("You will first notice you are your on team this is ")		player:message("because I am trying to keep a very RPG feel to this game.")		player:message("If you wish to team up with other people you will need ")		player:message("to goto a tavern in one of the many cities and type ")		player:message("?party 'The Name of the Party:Password if any' without the '.")		player:message("You get money and experience by killing other people or ")		player:message("mining and selling the resources back to the local NPC purchaser.")		player:message("There are 4 ways to advance your character in this Zone. ")		player:message("Training, Certifications, Permissions, and Class Changes.")		player:message("Each way has its pros and cons, by visiting a trainer in ")		player:message("a city you can recieve training which will allow you to use different weapons.")		player:message("Certifications work the same as training however you ")		player:message("might be required to get both in order to get a new class or use new weapons.")		player:message("Permissions allow you to do certain things such as build things, ")		player:message("drive certain vehicles and to get aura bonuses.")		player:message("Class Changing in this zone is different than any other zone, ")		player:message("first you must reach the requirements of that ")		player:message("class then you must find a trainer in the ")		player:message("city, and ask him to change your class. ")		player:message("Then you will be asked a couple of simple questions ")		player:message("about your decision to change classes and then allowed to change.");		player:message("When you are ready to join the game type ?login .")	end		if (command == "?login")then		if (noSkills(player) == true)then			player:inventory_modify("Soldier",1)			player:message("It would seem you have never played Infantry RPG before, if this is true please type ?tutorial")		end		player:unspec(player.m_name,"" .. password)				end	if (command == "?attribute") then		plyr:message("Each Attribute costs you 40 points. for list of attributes type ?list attributes.")		plyr:message("In order to purchase an attribute type ?levelup 'name of attribute'")	end		if (command == "?list") then -- If they are asking for a list		if (payload == "attributes") then -- If that list is attributes.			plyr:message("Agility")			plyr:message("Endurance")			plyr:message("Health")			plyr:message("Intelligence")			plyr:message("Reflexes")			plyr:message("Strength")		else			plyr:message("?list <argument here>")		end	end		if (command == "?levelup") then -- If they are trying to level up something		if (payload == "Agility" or payload == "agility") then -- If they are trying to level up Agility			if (plyr:getPoints() >= 50) then -- Do they have enough Attribute points?				plyr:modPoints(-50)				plyr:inventory_modify("Agility", 1)				plyr:message("Your Agility has increased by 1")			else				plyr:message("You need " .. (50 - plyr:getPoints()) .. " more attribute points.")			end		elseif (payload == "Endurance" or payload == "endurance") then			if (plyr:getPoints() >= 50) then -- Do they have enough Attribute points?				plyr:modPoints(-50)				plyr:inventory_modify("Endurance", 1)				plyr:message("Your Endurance has increased by 1")			else				plyr:message("You need " .. (50 - plyr:getPoints()) .. " more attribute points.")			end		elseif (payload == "Health" or payload == "health") then			if (plyr:getPoints() >= 50) then -- Do they have enough Attribute points?				plyr:modPoints(-50)				plyr:inventory_modify("Health", 1)				plyr:message("Your Health has increased by 1")			else				plyr:message("You need " .. (50 - plyr:getPoints()) .. " more attribute points.")			end		elseif (payload == "Intelligence" or payload == "intelligence") then			if (plyr:getPoints() >= 50) then -- Do they have enough Attribute points?				plyr:modPoints(-50)				plyr:inventory_modify("Intelligence", 1)				plyr:message("Your Intelligence has increased by 1")			else				plyr:message("You need " .. (50 - plyr:getPoints()) .. " more attribute points.")			end		elseif (payload == "Reflexes" or payload == "reflexes") then			if (plyr:getPoints() >= 50) then -- Do they have enough Attribute points?				plyr:modPoints(-50)				plyr:inventory_modify("Reflexes", 1)				plyr:message("Your Reflexes has increased by 1")			else				plyr:message("You need " .. (50 - plyr:getPoints()) .. " more attribute points.")			end		elseif (payload == "Strength" or payload == "strength") then			if (plyr:getPoints() >= 50) then -- Do they have enough Attribute points?				plyr:modPoints(-50)				plyr:inventory_modify("Strength", 1)				plyr:message("Your Strength has increased by 1")			else				plyr:message("You need " .. (50 - plyr:getPoints()) .. " more attribute points.")			end		else			plyr:message("?levelup <argument required>")		end	end	if (command == "?craft") then		if (string.len(payload) > 0) and (string.find(payload, ":") ~= nil) then			ore = string.sub(payload, 1, (string.find(payload, ":") - 1))			style = string.sub(payload, (string.find(payload, ":") + 1))		else			plyr:message("No Payload. E.X. ?craft <ore here>:<style here E.X Legging, Neck, Chest>")		end		if (ore == "Noobium") then			plyr:message("Craft part works!")			if (style == "Leggings") then				plyr:message("style part works!")			else				plyr:message("You did not try to use a valid Style")			end		else			plyr:message("You did not try to use a valid ore")		end	end			if (command == "?party") then		if (string.len(payload) > 0) and (string.find(payload, ":") ~= nil) then			team_n = string.sub(payload, 1, (string.find(payload, ":") - 1))			team_p = string.sub(payload, (string.find(payload, ":") + 1))			if (innOne(plyr) == true) then				plyr:message("You are now in the party " .. team_n ".")				plyr:changeTeam(team_n, team_p)			end		else			plyr:message("You need to make sure your putting the part name in E.X ?Party Killers:42")		end	end	if (command == "?loc") then -- They are finding their location		loc(plyr)	end	if (command == "?deploy") then -- They are deploying the Crawler		if (plyr:inventory_find("Crawler Training") >= 1) then -- They are a commander			if (plyr:inventory_find("Crawler -> Pod") >= 1) then -- They have the required item				if (g_teamPod[plyr:getTeam().m_name] == nil) then -- they dont have a Pod					messagetoteam(plyr:getTeam(), "A Pod has been created for your team.")					plyr:inventory_modify("Crawler -> Pod", -1)					g_teamPod[plyr:getTeam().m_name] = g_arena:vehicle_create(407, plyr:coords().x, plyr:coords().y, 0)					g_teamPod[plyr:getTeam().m_name]:setFrequency(plyr:getFrequency())					g_turret1[plyr:getTeam().m_name] = g_arena:vehicle_create(408, plyr:coords().x, plyr:coords().y -250, 0)					g_turret1[plyr:getTeam().m_name]:setFrequency(plyr:getFrequency())					g_turret2[plyr:getTeam().m_name] = g_arena:vehicle_create(408, plyr:coords().x - 125, plyr:coords().y + 125, 0)					g_turret2[plyr:getTeam().m_name]:setFrequency(plyr:getFrequency())					g_turret3[plyr:getTeam().m_name] = g_arena:vehicle_create(408, plyr:coords().x + 125, plyr:coords().y + 125, 0)					g_turret3[plyr:getTeam().m_name]:setFrequency(plyr:getFrequency())					g_podrewards[plyr:getTeam().m_name] = event_createarg(podrewards, -5000, g_arena, plyr:getTeam())					else							plyr:message("You already have a pod created.")				end			else				plyr:message("You do not have the required pods. Please pickup your Crawler.")			end		else			plyr:message("You are not trained in the Crawler Technology.")		end	end		if (command == "?reploy") then -- They are reploying the Crawler		if (plyr:inventory_find("Crawler Training") >= 1) then -- They are a commander			if (g_teamPod[plyr:getTeam().m_name] ~= nil) then -- They have a Pod				messagetoteam(plyr:getTeam(), "Your Team's Pod is being reployed into a Crawler. This will take 30 seconds.")				local reploypod = event_createarg(reploypod, -3000, g_arena, player)				g_arena:message("OWN")				event_destroy(g_podrewards[plyr:getTeam().m_name])			else				plyr:message("You do not have a Pod to reploy.")			end		else			plyr:message("You are not trained in Crawler Technology")		end	end	if (command == "?reload") then -- They are reloading lua		if (plyr.m_name == "Toriad") then			reload()		end	end		if (command == "?cash") then -- They are reloading lua		if (plyr.m_name == "Toriad" or plyr.m_name == "Randy") then			plyr:modCash(100000)		end	end	if (command == "?exp") then -- They are reloading lua		if (plyr.m_name == "Toriad" or plyr.m_name == "Randy") then			plyr:modExperience(100000)		end	end	end	function trainCheck(xp, cash, plyr, item) --Bring in XP, cash ,Plyr, and Item requirements output table	local myTable = {false, false, false}		if (plyr.getExperience() >= xp) then		myTable[1] = true	end		if (plyr.getCash() >= cash) then		myTable[2] = true	end		if (plyr.inventory_find(item) == 0) then		myTable[3] = true	end		return myTableendfunction ubah(plyr)local statplyr:setStat(1, 10)stat = plyr:getStat(1)plyr:message(stat)endfunction purchaseTraining(plyr, item, expr, cash)	plyr:message(item .. " requires " .. expr .. " Experince and " .. cash .. " credits.")			if (plyr:inventory_find(item) < 1) then				if (plyr:getCash() >= cash) then					if (plyr:getExperience() >= expr) then						plyr:modExperience(-expr)						plyr:modCash(-cash)						plyr:message("You are now trained in " .. item .. ".")						return true					else						plyr:message("You need " .. expr .. " Experience, you only have " .. plyr:getExperience() .. ".")						return false					end				else					plyr:message("You need " .. cash .. " Credits, you only have " .. plyr:getCash() .. ".")					return false				end			else				plyr:message("You have already been trained in this, you cannot learn anything else.")				return false			end	return falseendfunction purchaseCert(plyr, item, expr, cash)	plyr:message(item .. " requires " .. expr .. " Experince and " .. cash .. " credits.")			if (plyr:inventory_find(item) < 1) then				if (plyr:getCash() >= cash) then					if (plyr:getExperience() >= expr) then						plyr:modExperience(-expr)						plyr:modCash(-cash)						plyr:message("You are now " .. item .. ".")						return true					else						plyr:message("You need " .. expr .. " Experience, you only have " .. plyr:getExperience() .. ".")						return false					end				else					plyr:message("You need " .. cash .. " Credits, you only have " .. plyr:getCash() .. ".")					return false				end			else				plyr:message("You have already been certified in this, you cannot achieve anything by becomeing certified again.")				return false			end	return falseendfunction Vehicle_OnProduce(vech, plyr, menuitem) -- vehicle, player, integer	local vid = vech:vehicletypeid()	local menu = menuitem + 1	local turret1 = g_turret1[plyr:getTeam().m_name]	local turret2 = g_turret2[plyr:getTeam().m_name]	local turret3 = g_turret3[plyr:getTeam().m_name]		--For testing---	--g_arena:message("'Vehicle_OnProduce' called by " .. plyr.m_name .. " with vid " .. vid .. " and menu item " .. menuitem)	------------------		if (vid == 411) then -- It's the training vehicle		if (menu == 1) then --They've pressed menu item 1			if (purchaseTraining(plyr, "Crawler Training", 30000, 15000) == true) then				return true			else				return false			end		elseif (menu == 2) then --They've pressed menu item 2			if (purchaseTraining(plyr, "Pod Training", 30000, 15000) == true) then				return true			else				return false			end		end	end	if (vid == 400) then --It's the certificate Vehicle		if (menu == 1) then			if (purchaseCert(plyr, "Command Certification", 30000, 15000) == true) then				return true			else				return false			end		elseif (menu == 2) then			if (purchaseCert(plyr, "Mental Certification", 35000, 2000) == true) then				return true			else				return false			end		elseif (menu == 3) then			if (purchaseCert(plyr, "Missing Certification", 50000, 2000) == true) then				return true			else				return false			end		end	end	if (vid == 401) then -- It's the Shrine they are using.		if (menu == 1) then			plyr:message("fgun")		end	end	if (vid == 406 or vid == 404 or vid == 405 or vid == 403) then -- If they are trying to capture a flag in city1		if (menu == 1) then			if (vech:getFrequency() == plyr:getFrequency()) then -- They already have the flag				plyr:message("Your team has already captured this flag.")			elseif (vech:getFrequency() ~= plyr:getFrequency()) then -- They dont have this flag				plyr:message("You have Captured the " .. vech:vehiclename() .. "!")				g_arena:message("" .. plyr.m_name .. " has captured the " .. vech:vehiclename() .. "!")				vech:setFrequency(plyr:getFrequency())			end		end	end	if (vid ==407) then -- They are trying to use the Pod		if (plyr:inventory_find("Pod Training") >= 1) then --They are a commander			if (vech:getFrequency() == plyr:getFrequency()) then -- They are on the same team as the Pod				if (menu == 1) then -- They are trying to use repair					if (plyr:getCash() >= 10000) then -- they ahve neough cash						plyr:modCash(-10000)						turret1:setHealth(turret1:getHealth() + 50)						turret2:setHealth(turret2:getHealth() + 50)						turret3:setHealth(turret3:getHealth() + 50)						plyr:message("Your turrets have been repaired")					else						plyr:message("You need to have at least 10000 credits.")					end				elseif (menu == 2) then --they are trying to rebuild					if (plyr:getCash() >= 30000) then -- They have enough cash						plyr:modCash(-30000)						turret1:destroy()						turret2:destroy()						turret3:destroy()						turret1 = g_arena:vehicle_create(408, vech:coords().x, vech:coords().y - 250, 0)						turret1:setFrequency(plyr:getFrequency())						turret2 = g_arena:vehicle_create(408, vech:coords().x - 125, vech:coords().y + 125, 0)						turret2:setFrequency(plyr:getFrequency())						turret3 = g_arena:vehicle_create(408, vech:coords().x + 125, vech:coords().y + 125, 0)						turret3:setFrequency(plyr:getFrequency())						plyr:message("Your base has been rebuilt at the cost of 30,000 credits!")					else						plyr:message("You need to have at least 30000 credits.")					end				end			else				plyr:message("This is not your teams Pod")			end		else			plyr:message("You are not trained in Pod Technology.")		end	end					return falseendfunction Vehicle_OnDeath(vech, plyr, itemid) -- vehicle, player, integer	local vid = vech:vehicletypeid()	local pteam = plyr:getTeam()			if (vid == 402) then --If they killed Toriad of Malion		g_arena:message("Toriad of Malion has been killed by " .. plyr.m_name .. " from team " .. pteam.m_name .. ".")		plyr:message("You have captured the soul of Toriad of Malion, sacrafice his soul at a Shrine of Malion and choose your reward.")		plyr:inventory_modify("Soul of Toriad", 1)	end	if (vid == 407) then --They killed a pod! god damn them		local vteam = team_fromId(g_arena, vech:getFrequency())		local cashreward = ((g_arena:numPlaying() * vteam:numPlayer()) * 2)		local expreward = (g_arena:numPlaying() * vteam:numPlayer()())		g_arena:message("Team " .. vteam.m_name .. "'s Pod was destroyed by " .. plyr.m_name .. " of team " .. plyr:getTeam().m_name .. ".")		for i=1, plyr:getTeam():num() do			g_arena:message("for works")			g_arena:message("plyr")			local targ = team:get(i)			if (targ ~= nil) and (targ:valid()) then				g_arena:messages("Lets do some modding!")				plyr:setBounty(false, (g_arena:numPlaying() * vteam:num() / 2))				g_arena:messages("Cash FTW!")				targ:message("Your team has destroyed Team " .. vteam.m_name .. "'s Pod and has recieved " .. expreward .. " experience and " .. cashreward .. " credits.")				targ:message("You have also recieved a " .. (g_arena:numPlaying() * vteam:num() / 2) .. " bounty bonus to your current bounty.")				targ:modCash(cashreward)				targ:modExperience(expreward)				g_arena:messages("Exp FTW!")				event_destroy(g_arena, g_reploypod[plyr:getTeam().m_name])				event_destroy(g_arena, g_podrewards[plyr:getTeam().m_name])			end		end	endendfunction innOne(plyr)	local g_x1 = 1791	local g_y1 = 1546	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	endendfunction podrewards(team)		if (team ~= nil) then 		local cashreward = 5000		local expreward = 10000		for i=1, team:num() do			local plyr = team:get(i)			if (plyr ~= nil) and (plyr:valid()) then				plyr:modCash(cashreward)				plyr:message("For having your Pod deployed you get " .. expreward .. " Experience and " .. cashreward .. " Credits!")				plyr:modExperience(expreward)			end		end	else	g_arena:message("Team not work")	end		return false	endfunction messagetoteam(team, message)	if (team ~= nil) then		for i=1, team:num() do			local player = team:get(i)			if (player ~= nil) and (player:valid()) then				player:message(message)				g_arena:message("woot2")			end		end	end	g_arena:message("woot3")endfunction reploypod(plyr)		local pod = g_teamPod[plyr:getTeam().m_name]:coords()		g_arena:vehicle_create(124, pod.x, pod.y, 0)	g_turret1[plyr:getTeam().m_name]:destroy()	g_turret2[plyr:getTeam().m_name]:destroy()	g_turret3[plyr:getTeam().m_name]:destroy()	g_teamPod[plyr:getTeam().m_name]:destroy()endfunction reload()dofile("rpg.lua")end