Jump to content

My first attempt to make MAP gamemode


Recommended Posts

Posted

Hey, I'm making basic gamemode with votemaps and so on and I failed :)

function tvhMap(startedMap)
mapRoot = getResourceRootElement(startedMap)
end
addEventHandler("onGamemodeMapStart", getRootElement(), tvhMap)

function humanityChosen()
local spawn = getElementsByType("humanitySpawn", mapRoot)
local x,y,z
for key, value in pairs(spawn) do
	x = getElementData(value, "posX")
	y = getElementData(value, "posY")
	z = getElementData(value, "posZ")
spawnPlayer(source,x,y,z)
setCameraTarget(source,source)
end
end
addEvent("humanity",true);
addEventHandler("humanity",getRootElement(),humanityChosen)

These are just parts of it, but it debugs an error about

ERROR: Infite/Too long execution (mapmanager)

ERROR: Aborting; infite running script

What's wrong, it doesn't even start the map what i made. And trust me there's these humanityspawns on map file and the gamemodes for map file is set OK, like

<meta>
<info type="map" gamemodes="TestMode"/>
<map src="junkyard.map"/>
meta>

and in my gamemode:

<info author="Taalasmaa" type="gamemode" name="TestMode" version="0.0.1"  />

Well, thanks.

Best Regards

Taalasmaa

Posted

ERROR: Infite/Too long execution (mapmanager)

you messed something with votes it think (as this is mapmanager infinite run, not your gamemode whatever its called)

and..

local spawn = getElementsByType("humanitySpawn", mapRoot)
local x,y,z
for key, value in pairs(spawn) do
     x = getElementData(value, "posX")
     y = getElementData(value, "posY")
     z = getElementData(value, "posZ")
spawnPlayer(source,x,y,z)
setCameraTarget(source,source)
end

what you tried to do by that?

it will spawn at last spawnpoint anyway ..

Posted
local spawn = getElementsByType("humanitySpawn", mapRoot)
local x,y,z
for key, value in pairs(spawn) do
     x = getElementData(value, "posX")
     y = getElementData(value, "posY")
     z = getElementData(value, "posZ")
spawnPlayer(source,x,y,z)
setCameraTarget(source,source)
end

what you tried to do by that?

it will spawn at last spawnpoint anyway ..

no it wont, pairs() is outputing everything in random order

Posted
pairs() is outputing everything in random order

rly? that's weird..

anyway, looping through all spawnpoints, and spawning player at these place, and stop spawning after last random spawn -- not so good idea.. better is to choose one (random) and spawn.. and thats all

Posted

So, any help?

EDIT; It gives an error

bad arguement #1 to 'pairs'

So it seems that this gamemode doesn't detect any suitable maps, what's wrong?

Help would be good

Posted
try removing 2nd arg at getElementsByType, and check is the name right, then try again

Nvm, i fixed it, my server bugged :) Any gamemode didn't worked :S Now i'm angry because I spent many hours in trying to solve the problem and it was causing because of server... :evil:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...