Jump to content

Team scripting issues


Recommended Posts

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 ) 
addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) 


function(thePlayer, commandName) 
    setPlayerTeam(thePlayer, teamMexicans) 
    outputChatBox("You are a Mexican.",thePlayer) 

function(thePlayer, commandName) 
    setPlayerTeam(thePlayer, teamBorderControl) 
    outputChatBox("You are the Border Control.",thePlayer) 

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"/> 
      "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"/> 
      "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 by Guest
Link to comment

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

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

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) 

and the giveWeapons script

function giveWeaponsOnSpawn ( theSpawnpont, theTeam ) 
    giveWeapon ( source, 31, 200 ) 
addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnSpawn ) 

Edited by Guest
Link to comment

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) 
addEventHandler("onPlayerSpawn", root, teamSpawnWep)  

Untested but maybe should be doing the job

EDIT: This is to give weps

Link to comment

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...