Jump to content

need help with "if" and getPlayerTeam


heavy air

Recommended Posts

Posted

hi all :D

having problems getting this to work

i get no errors from debug but i only get the output to chatbox "tester" from upperdoorkey and i get "your on heavys team" from joinateam

here is the script

local upperdoorlock = createColSphere ( -1156, 43, 0, 15 ) 
local upperdoor = createObject ( 3113, -1156.52, 43.1175, 0, 0, 15.88000, 316.330 ) 
local heavysteam = { } 
  
function upperdoorkey ( player, cmd ) 
   local whatteam = getPlayerTeam ( player ) 
   outputChatBox ( "tester" ) 
      if whatteam == "heavysteam" then  
         outputChatBox ( "open sesame" ) 
            moveObject ( upperdoor, 5000, -1156.52, 43.1175, -10 ) 
            setTimer ( moveObject, 8000, 1, upperdoor, 5000, -1156.52, 43.1175, 0 ) 
            setTimer ( outputChatBox, 8000, 1, "close sesame" )   
  
       else 
       end 
end 
  
addCommandHandler ( "openupper", upperdoorkey ) 
  
  
function joinateam( source, cmd ) 
   createTeam ( "heavysteam" ) 
   setPlayerTeam ( source, heavysteam ) 
   outputChatBox ( "your on Heavys Team" ) 
end 
  
addCommandHandler ( "heavysside", joinateam ) 

i have tried a few different ways of checking what team the player is on but everything else i have tried has given me either bad player pointer errors or bad argument errors. not sure where ive gone wrong so any advice would be helpful.

the colsphere i was using to with getElementsWithinColShape and then getElementsByType "player" but i got really confused that way so i have tried this now

Thanx for l :shock: king

MTA the gift that keeps on giving

ALL! HAIL! THE MTA TEAM!!!

Posted

getPlayerTeam only returns the team element. If you want to compare the team name, you need to use getTeamName. So performing a getTeamName check on the player's team should make your if statement work.

Also your setPlayerTeam function is flawed. You need to pass the team element. createTeam returns a team element that you can pass into it, however.

VCP FOREVER!

8298.png

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