Jump to content

getTeamName to allow use vehicles


kuwalda

Recommended Posts

Can someone please show me brief example on how to createVehicle and then apply on it rule, that only specific team can gain access to it?

I had an idea like:

  
car1 = createVehicle ( 540, x, y, z ) 
car2 = createVehicle ( 540, x, y, z ) 
car3 = createVehicle ( 540, x, y, z ) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
if car1 or car2 or car3 and getTeamName ~= "myTeam" then 
      --kick him out of the car 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 
  

but is this basiclly the only way? I would like better that those cars are locked and only "myTeam" can open the doors and drive normally with them. Is this possible or I have to use something like I mentioned above? Or maybe someone have better solution or advice?

Link to comment
car1 = createVehicle ( 540, x, y, z ) 
car2 = createVehicle ( 540, x, y, z ) 
car3 = createVehicle ( 540, x, y, z ) 
  
function enterVehicle ( thePlayer, seat, jacked ) 
    if not (getTeamName(getPlayerTeam(thePlayer)) == "MyTeam") then 
        if (source == car1) or (source == car2) or (source == car3) then 
            cancelEvent() 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment

you mean like this , ?

Vehicles = { [540]=true} -- Cars , 
  
function enterVehicle(player) 
     local Team = getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) 
     if (Vehicles[getElementModel(source)]) and (Team ~= "myTeam") then 
     outputChatBox('welcome Back ',player, 0, 255, 0 ) 
     else 
     removePedFromVehicle(player) 
     outputChatBox("You Cant Use this Car it's Private !", player, 255, 0, 0) 
     end 
end 
addEventHandler("onVehicleEnter", root, enterVehicle) 
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...