Hutchpe Posted October 31, 2012 Share Posted October 31, 2012 (edited) I am in the process of creating scripts for my server. The aim is to have two teams and when a player joins a team they are teleported to a set of co-ordinates. I currently have the script to create the teams on start-up and to let people join the teams. function createTeamsOnStart () teamBorderControl = createTeam ( "Border Control", 0, 255, 0 ) teamMexicans = createTeam ( "Mexicans", 200, 0, 100 ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) and addCommandHandler("joinmexicans", function(thePlayer, commandName) setPlayerTeam(thePlayer, teamMexicans) outputChatBox("You are a Mexican.",thePlayer) end ) addCommandHandler("joinbordercontrol", function(thePlayer, commandName) setPlayerTeam(thePlayer, teamBorderControl) outputChatBox("You are the Border Control.",thePlayer) end ) Can anyone point me in the right direction to modify this so that when a player joins a team they are teleported to specific co-ordinates? I am also wanting to know how to apply attributes in the MAP file to each of the teams. This is what I have in the map file currently. "Mexihunt" version="1.0"> "5000" maxkills="60" ff="off"/> "00" h="10" locked="false" /> team="Border Control" red="255" green="0" blue="0"> "9" ammo="1"/> "23" ammo="100"/> "25" ammo="200"/> "32" ammo="500"/> "31" ammo="200"/> "33" ammo="50"/> "33"/> "5438.780762" posY="-1917.095703" posZ="1.538315" rot="0" randx="0" randy="0" randz="0"/> "5429" posY="-1831" posZ="3.22" rot="0" randx="0" randy="0" randz="0"/> "5253" posY="-2075" posZ="5.24" rot="0" randx="0" randy="0" randz="0"/> "5424" posY="-2060" posZ="9.09" rot="0" randx="0" randy="0" randz="0"/> team="Mexicans" red="255" green="255" blue="255"> "3" ammo="1"/> "24" ammo="100"/> "27" ammo="200"/> "29" ammo="500"/> "30" ammo="200"/> "34" ammo="50"/> "70"/> "5068.007813" posY="-2083.547119" posZ="7.487796" rot="0" randx="0" randy="0" randz="0"/> "5141" posY="-1873" posZ="6.66" rot="0" randx="0" randy="0" randz="0"/> "5095" posY="-1938" posZ="16.87" rot="0" randx="0" randy="0" randz="0"/> "5067" posY="-2068" posZ="14.8" rot="0" randx="0" randy="0" randz="0"/> "5099" posY="-2084" posZ="15.53" rot="0" randx="0" randy="0" randz="0"/> Any help is very much appreciated. Edited October 31, 2012 by Guest Link to comment
myonlake Posted October 31, 2012 Share Posted October 31, 2012 spawnPlayer You don't need setPlayerTeam when you have spawnPlayer by the way. Check the arguments from Wiki. Use XML functions when you want to connect map/xml with a script. Link to comment
Hutchpe Posted October 31, 2012 Author Share Posted October 31, 2012 Thanks for the reply. I replaced setPlayerTeam with spawnPlayer and it works beautifully! I've decided to scrap the .MAP config and implement weapons through the script. Can anyone give some advice on how to use the giveWeapon argument only when a player joins a specific team? Link to comment
myonlake Posted October 31, 2012 Share Posted October 31, 2012 I don't think there are team events, so you're gonna have to put the code after the spawnPlayer function. Link to comment
Hutchpe Posted October 31, 2012 Author Share Posted October 31, 2012 (edited) Sorry for being a bit of a noob but could you show me what they would look like put together? So far I have the script to join a team addCommandHandler("joinbordercontrol", function(thePlayer, commandName) spawnPlayer(thePlayer, 2495.3654785156,-1687.6867675781,13.517179548035, 0,0,0,0,teamBorderControl) fadeCamera (source, true) setCameraTarget (source, source) outputChatBox("You are the Border Control.",thePlayer) end ) and the giveWeapons script function giveWeaponsOnSpawn ( theSpawnpont, theTeam ) giveWeapon ( source, 31, 200 ) end addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnSpawn ) Edited October 31, 2012 by Guest Link to comment
Baseplate Posted October 31, 2012 Share Posted October 31, 2012 You can get the team function teamSpawnWep () local team = getPlayerTeam (source) if (team == teamBorderControl) then giveWeapon (source, id) if (team == teamMexicans) then giveWeapon (source, id) end end end addEventHandler("onPlayerSpawn", root, teamSpawnWep) Untested but maybe should be doing the job EDIT: This is to give weps Link to comment
Hutchpe Posted October 31, 2012 Author Share Posted October 31, 2012 It works great! Thanks so much 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