capitanazop Posted June 8, 2009 Share Posted June 8, 2009 hi, i have a problem i create a simple deathmatch gamemode whit maps files and its work perfectly, but when the server has no start the gamemode and use /votemap deathmatch and i choice one but the screen still black and use /reconnect and spawn perfectly. how i can fix that? function loadMap(startedMap, player) mapRoot = getResourceRootElement(startedMap) setTimer(joinHandler,1000,1,player) end addEventHandler("onGamemodeMapStart", dm_root, loadMap) function joinHandler() local total_spawns = getElementChildrenCount( getElementByID( "spawns" ) ) local num = math.random( 0, total_spawns - 1 ) local spawn_random = getElementChild ( getElementByID( "spawns" ), num ) local x = getElementData ( spawn_random, "posX" ) local y = getElementData ( spawn_random, "posY" ) local z = getElementData ( spawn_random, "posZ" ) local rot = getElementData ( spawn_random, "rot" ) spawnPlayer(source, x, y, z, rot) setCameraTarget ( source, source ) fadeCamera(source, true) giveWeapon(source, 22, 999) giveWeapon(source, 4, 1) end addEventHandler("onPlayerJoin", dm_root, joinHandler) thx bye (. Link to comment
knash94 Posted June 8, 2009 Share Posted June 8, 2009 What about using event: addEventHandler ( "onResourceStart", getRootElement(), joinHandler ) Link to comment
capitanazop Posted June 8, 2009 Author Share Posted June 8, 2009 yes i tryed this but only get warnings i need a code for spawn all players in the server but i dont know how i can make this. bye y thx for the reply (. Link to comment
50p Posted June 8, 2009 Share Posted June 8, 2009 yes i tryed this but only get warnings i need a code for spawn all players in the server but i dont know how i can make this.bye y thx for the reply (. To spawn everyone you have to loop through all the player elements, like so: local plrs = getElementsByType( "player" ); for i, plr in pairs( plrs ) do spawnPlayer( plr, x, y, z, rot ); setCameraTarget ( plr, plr ); fadeCamera( plr, true ); giveWeapon( plr, 22, 999 ); giveWeapon( plr, 4, 1 ); end Link to comment
capitanazop Posted June 9, 2009 Author Share Posted June 9, 2009 i tried this but dont work only work in players event i can use spawn player but not whit the random functions we made. bye n sorry forma english Link to comment
50p Posted June 9, 2009 Share Posted June 9, 2009 You haven't try this. Why I know that? Because it doesn't matter where you put this code, it'll get all the players that are online and loop through them. Link to comment
capitanazop Posted June 9, 2009 Author Share Posted June 9, 2009 local players = getElementsByType ( "player" ) for k,v in ipairs(players) do sorry man i had this code and i thought that are the same (. now works .D thanks man Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now