Jump to content

Certain Team can enter Veh?


Lloyd Logan

Recommended Posts

How can i make it so that only the "Bus Driver" team can enter the Bus/Coaches?

I have this for the Veh and Skins, I would like it for the team?

busSkins = { [255] = true } 
busVehs = { [437] = true } 
  
function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if ( busVehs[getElementModel ( source )] ) and ( not busSkins[getElementModel ( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin 
        removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
        outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment
busTeams = { [Team] = true } 
busVehs = { [437] = true } 
  
function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if ( busVehs[getElementModel ( source )] ) and ( not busTeams[getPlayerTeam( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin 
        removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
        outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment

There are some solutions for this:

teams = { ["busteam"] = true; ["busteam2"] = true } 
  
function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if ( busVehs[getElementModel ( source )] ) and ( not teams[getTeamName( getPlayerTeam( thePlayer ) )] ) then  
        removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
        outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Or this:

function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle 
    if ( busVehs[getElementModel ( source )] ) and ( getPlayerTeam( thePlayer ) ~= team )] ) then  
        removePedFromVehicle( thePlayer )-- force the player out of the vehicle 
        outputChatBox("Only Bus Drivers can drive this vehicle!", thePlayer) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment
teamName = "Bus Driver" 
busVehs = { [437] = true } 
  
function enterVehicle ( thePlayer ) 
    if busVehs [ getElementModel ( source ) ] then 
        if getTeamFromName ( teamName ) then 
            if getPlayerTeam ( thePlayer ) ~= getTeamFromName ( teamName ) then 
                outputChatBox ( "Only Bus Drivers can drive this vehicle!", thePlayer, 255, 0, 0, true ) 
                cancelEvent ( ) 
            end 
        else 
            outputChatBox ( "The Team Is not Available !", thePlayer, 255, 255, 0, true )        
        end 
    end 
end 
addEventHandler ( "onVehicleStartEnter", 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...