Jump to content

Making Forts For Teams


heavy air

Recommended Posts

Posted

hi all :D

i am tryin to make a defense system for my base

i have made doors that open and close when entering a collision sphere but what i want to do is make the collision sphere check what team u are on and then open if your on the right team

this is what ive got so far and the doors were working fine until i tried to add the check for what team the player is on

local upperdoorlock = createColSphere ( -1156, 43, -200, 8 ) 
local upperdoor = createObject ( 3113, -1156.52, 43.1175, 0, 0, 15.88000, 316.330 ) 
local sidedoorlock = createColSphere ( -1108, 65, -200, 8 ) 
local sidedoor = createObject ( 10828, -1108, 65, 5, 0, 0, 314 ) 
local heavysteam = createTeam ( "heavysteam" ) 
  
function joinateam( source, cmd ) 
   setPlayerTeam ( source, heavysteam ) 
   outputChatBox ( "your on Heavys Team" ) 
end 
  
addCommandHandler ( "heavysside", joinateam ) 
  
function openupperdoor ( player ) 
   local myteam = getPlayerTeam ( player ) 
      if myteam == "heavysteam" then 
         outputChatBox ( "open sesame" ) 
         moveObject ( upperdoor, 5000, -1156.52, 43.1175, -10 ) 
         setElementPosition ( upperdoorlock, -1156, 43, -200 ) 
         setTimer ( moveObject, 8000, 1, upperdoor, 5000, -1156.52, 43.1175, 0 ) 
         setTimer ( setElementPosition, 10000, 1, upperdoorlock, -1156, 43, 0 ) 
         setTimer ( outputChatBox, 8000, 1, "close sesame" ) 
      else 
      end 
end 
  
function opensidedoor () 
   outputChatBox ( "open sesame" ) 
   setElementPosition ( sidedoorlock, -1110, 65, -200 ) 
   moveObject ( sidedoor, 5000, -1108, 65, -10 ) 
   setTimer ( MoveObject, 10000, 1, 5000, -1108, 65, 5 ) 
   setTimer ( setElementPosition, 12000, 1, sidedoorlock, -1110, 69, 5 ) 
   setTimer ( outputChatBox, 10000, 1, "close sesame" ) 
end 
  
function securemyfort ( player, cmd ) 
   setElementPosition ( upperdoorlock, -1156, 43, 0 ) 
   setElementPosition ( sidedoorlock, -1110, 69, 5 ) 
   addEventHandler ( "onColShapeHit", upperdoorlock, openupperdoor ) 
   addEventHandler ( "onColShapeHit", sidedoorlock, opensidedoor ) 
   outputChatBox ( "fort secured", 255, 0, 0 ) 
end 
  
  
addCommandHandler ( "secure", securemyfort ) 

i get an error on line 15 " bad player pointer" so i assume that i need to pass what player is triggering the collision sphere but i dont know how to do that or if thats what i need to do

i have had a quick look through the forums but cant find what i need . most of the time i can figure things out from the way other people have written other functions but i dont seem to be gettin anywhere with this one

thanks for any help

EDIT : the reason the check player team is only on one door is because this is first time i tried this and wanted to keep one working door for comparison

MTA the gift that keeps on giving

ALL! HAIL! THE MTA TEAM!!!

Posted

Are you walking through the door or driving - it'll trigger on the vehicle if you're driving...

Posted

i am driving

does that mean it looks for the team the vehicle is on sort of thing?

if thats the case would i need to do a check if player in vehicle and then get player occupying vehicle and then check what team player is on

EDIT : just tried it walking ( no vehicle ) and i get no error in debug but door doesnt work either

still gives me same error when i n vehicle though

MTA the gift that keeps on giving

ALL! HAIL! THE MTA TEAM!!!

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