Frank-De-Ruiter Posted March 21, 2008 Share Posted March 21, 2008 hi all, Im requesting an simple gamemode that can load an map and spawn players at the maps spawnpoint. Just an simple script that i need as my base and build from there. Greatings Frank Link to comment
[Ska]Vladmo Posted March 22, 2008 Share Posted March 22, 2008 If it's so simple then why can't you do it? Link to comment
Siyo Posted March 22, 2008 Share Posted March 22, 2008 [Ska]Vladmo said: If it's so simple then why can't you do it? Was that suppose to be funny? Because half of your posts are dumb requests and the rest is flaming people that tried to help you. Link to comment
tma Posted March 22, 2008 Share Posted March 22, 2008 [Ska]Vladmo said: If it's so simple then why can't you do it? If it's so simple, why don't you show him ? Frank-De-Ruiter said: hi all,Im requesting an simple gamemode that can load an map and spawn players at the maps spawnpoint. Just an simple script that i need as my base and build from there. Greatings Frank Edit : To be constructive. Look at this post I've made. It is what you want (almost) - a basic dumb freeroam mode. It doesn't use a map for spawn points however, but should get you started. Link to comment
[Ska]Vladmo Posted March 22, 2008 Share Posted March 22, 2008 tma said: [Ska]Vladmo said: If it's so simple then why can't you do it? If it's so simple, why don't you show him ? Who ever said it was simple for me? Link to comment
Frank-De-Ruiter Posted March 23, 2008 Author Share Posted March 23, 2008 omfg, the only thing i mean with simple that it only has to have the basic stuff to run it, so i can implant my scripts into it! Link to comment
Frank-De-Ruiter Posted March 24, 2008 Author Share Posted March 24, 2008 hey, ive got some problems with this gamemode, its all working now, you do spawn, but i have some problems with the teams, ive got the TeamBalance but i want that on Spawn player gets random put in Team1 or Team2, ive looked trough some functions but i can't seem to get it working. My GM: addEventHandler("onPlayerJoin",getRootElement(), function() local joinedPlayerName = getClientName ( source ) joinHandler(source) outputChatBox ( "Welcome " .. joinedPlayerName .. " to the official Arena Deathmatch server!!" , source, 255, 255, 255 ) end ) addEventHandler("onPlayerWasted",getRootElement(), function() setTimer(joinHandler,5000,1,source) end ) addEventHandler("onResourceStart",getRootElement(), function(res) if res == getThisResource() then for _,player in pairs(getElementsByType("player")) do joinHandler(player) end end end ) function joinHandler(player) fadeCamera(player,true) spawnPlayer(player,math.random(10) * 3,math.random(10) * 3,5) end function onGameResourceStart() team1 = createTeam("Team1", 255, 0, 0) team2 = createTeam("Team2", 255, 255, 0) end addEventHandler("onResourceStart", getRootElement(), onGameResourceStart) function balanceTeams ( thePlayer ) local team1 = getTeamFromName ( "Team1" ) local team2 = getTeamFromName ( "Team2" ) local team1Count = countPlayersInTeam ( team1 ) local team2Count = countPlayersInTeam ( team2 ) if team1Count == team2Count then setPlayerTeam ( thePlayer , team1 ) elseif team1Count > team2Count then setPlayerTeam ( thePlayer , team2Team ) elseif team1Count < team2Count then setPlayerTeam ( thePlayer , team1Team ) end end addEventHandler("onPlayerJoin", getRootElement(), blanceTeams) Can someone help me with what? Greatings Frank Link to comment
tma Posted March 24, 2008 Share Posted March 24, 2008 I changed your code to this : addEventHandler("onPlayerJoin",getRootElement(), function() local joinedPlayerName = getClientName ( source ) joinHandler(source) outputChatBox ( "Welcome " .. joinedPlayerName .. " to the official Arena Deathmatch server!!" , source, 255, 255, 255 ) end ) addEventHandler("onPlayerWasted",getRootElement(), function() setTimer(joinHandler,5000,1,source) end ) addEventHandler("onResourceStart",getRootElement(), function(res) if res == getThisResource() then team1 = createTeam("Team1", 255, 0, 0) team2 = createTeam("Team2", 255, 255, 0) for _,player in pairs(getElementsByType("player")) do setTimer(joinHandler,1000,1,player) end end end ) function joinHandler(player) fadeCamera(player,true) spawnPlayer(player,math.random(10) * 3,math.random(10) * 3,5) balanceTeams(player) end function balanceTeams ( thePlayer ) if countPlayersInTeam(team1) > countPlayersInTeam(team2) then setPlayerTeam ( thePlayer , team2 ) else setPlayerTeam ( thePlayer , team1 ) end end A few things: 1. You miss-spelled the call to balanceTeams() in the addEventHandler(). This should have come up as an error in the server console for you to find. 2. You weren't handling the team assingment when somebody was already connected on game mode start. What's odd is that it didn't work when I started the game mode while connected but did when I joined (with it running). This is the reason for adding another timer into the onResourceStart() bit for player spawning - without it, it appears that using the newly created teams directly after seems to fail ? Edit: You may need to clear the play team on wasted so that when he player goes through the balance process again, he's not already in a team e.g. setPlayerTeam(player,nil) If you don't want to do that (which may swap a players team on death), you could just check to see if the players in a team and only assign them one if not e.g. function balanceTeams ( thePlayer ) if not getPlayerTeam(thePlayer) then if countPlayersInTeam(team1) > countPlayersInTeam(team2) then setPlayerTeam ( thePlayer , team2 ) else setPlayerTeam ( thePlayer , team1 ) end end end Link to comment
Frank-De-Ruiter Posted March 24, 2008 Author Share Posted March 24, 2008 Oh yeah, now that you tell me i see it myself to, tanks mate! May i ask you this last thing? i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me if you could do that i will be all happy. Thanks, Grtz. Frank Link to comment
[Ska]Vladmo Posted March 24, 2008 Share Posted March 24, 2008 Frank-De-Ruiter said: Oh yeah, now that you tell me i see it myself to, tanks mate!May i ask you this last thing? i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me if you could do that i will be all happy. Thanks, Grtz. Frank Turn the mode on? Lol Link to comment
Frank-De-Ruiter Posted March 24, 2008 Author Share Posted March 24, 2008 [Ska]Vladmo said: Frank-De-Ruiter said: Oh yeah, now that you tell me i see it myself to, tanks mate!May i ask you this last thing? i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me if you could do that i will be all happy. Thanks, Grtz. Frank Turn the mode on? Lol Omg, dude i mean to load an .map file -.- Link to comment
[Ska]Vladmo Posted March 24, 2008 Share Posted March 24, 2008 Frank-De-Ruiter said: [Ska]Vladmo said: Frank-De-Ruiter said: Oh yeah, now that you tell me i see it myself to, tanks mate!May i ask you this last thing? i don't understand how to load an map into the mode, can you explain me how to do this? it would realy help me if you could do that i will be all happy. Thanks, Grtz. Frank Turn the mode on? Lol Omg, dude i mean to load an .map file -.- What's the mapfile name? Link to comment
[Ska]Vladmo Posted March 24, 2008 Share Posted March 24, 2008 <map src="filename.map" /> RIght click your meta.xml and click edit then put that code line above with your other lines. Link to comment
Frank-De-Ruiter Posted March 25, 2008 Author Share Posted March 25, 2008 But does this automaticly load the map into de mode? and how to tell the script to use the .map Spawnpoints inplace of the Random spawn? Link to comment
tma Posted March 25, 2008 Share Posted March 25, 2008 Frank-De-Ruiter said: But does this automaticly load the map into de mode? and how to tell the script to use the .map Spawnpoints inplace of the Random spawn? Yes, it should load the spawnpoints. If you then want to spawn a player at a random spawnpoint, swap: spawnPlayer(player,math.random(10) * 3,math.random(10) * 3,5) for call(getResourceFromName("spawnmanager"),"spawnPlayerAtSpawnpoint",player) Link to comment
Frank-De-Ruiter Posted March 25, 2008 Author Share Posted March 25, 2008 Thanks tma for your help! 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