Jump to content

Cant enter vehicles without being in faction


Recommended Posts

I suppose the factions are sorted in teams, you can try this

Add this somewhere in your code. When you want to set a vehicle to be part of one of the teams, you have to do something like this

setVehicleTeamVehicle (car,theteam) or if you only know the teamname: setVehicleTeamVehicle (car,getTeamFromName("teamname"))

I hope that works :> the code is below.

addEventHandler("onVehicleStartEnter",getRootElement(), 
function(player,seat,jacked,door) 
  if getElementData (vehicle,"teamvehicle") then 
    if getPlayerTeam (player) == getElementData (vehicle,"teamvehicle") then 
      outputChatBox ("You entered a vehicle of your team!",player,255,0,0,false) 
      return 
    else 
      outputChatBox ("This vehicle isn't part of your team!",player,255,0,0,false) 
      cancelEvent () 
      return 
    end 
  end 
end) 
  
function setVehicleTeamVehicle (vehicle,team) 
  if vehicle and team and isElement (vehicle) and isElement (team) and getElementType (vehicle) == "vehicle" and getElementType (team) == "team" then 
    setElementData (vehicle,"teamvehicle",team) 
    return true 
  else 
    return false 
  end 
end 

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