Jump to content

Restricted Cars HALP


Baseplate

Recommended Posts

copVehicles = { [523]=true,[598]=true,[596]=true,[597]=true,[599]=true } 
copTeams = {["Police"]=true,["Military"]=true,["SWAT"]=true} 
  
function copenterVehicle ( player, seat, jacked ) 
    if ( copVehicles[getElementModel ( source )] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) and ( seat == 0 ) then 
        removePedFromVehicle ( player )--force the player out of the vehicle 
        outputChatBox ( "You cannot drive this car.", 255, 0, 0, player ) --and tell the player why 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), copenterVehicle ) 

This is my current script so far, how can I make the player can't use the car before he open the door and gets in

Link to comment
  • Moderators

cancelEvent ()

copVehicles = { [523]=true,[598]=true,[596]=true,[597]=true,[599]=true } 
    copTeams = {["Police"]=true,["Military"]=true,["SWAT"]=true} 
      
    function copenterVehicle ( player, seat, jacked ) 
        if ( copVehicles[getElementModel ( source )] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) and ( seat == 0 ) then 
            cancelEvent () 
            outputChatBox ( "You cannot drive this car.", 255, 0, 0, player ) --and tell the player why 
        end 
    end 
    addEventHandler ( "onVehicleEnter", getRootElement(), copenterVehicle ) 

Link to comment

I want to keep it on Teams mate.

EDIT:I found a solution i'll test and i'll tell you

policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true } 
copTeams = {["Police"]=true,["Military"]=true,["SWAT"]=true} 
  
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle 
    if ( policeVehicles[getElementModel(source)] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin 
        cancelEvent() 
        outputChatBox ( "Only policeman can enter police cars!", player ) --and tell the player why 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) --add an event handler for onVehicleStartEnter 

Dosen't work :(

Link to comment
policeVehicles = 
    { 
        [ 598 ] = true, 
        [ 596 ] = true, 
        [ 597 ] = true, 
        [ 599 ] = true 
    } 
copTeams = 
    { 
        [ "Police" ] = true, 
        [ "Military" ] = true, 
        [ "SWAT" ] = true 
    } 
  
function enterVehicle ( player, seat, jacked ) 
    if ( policeVehicles [ getElementModel ( source ) ] ) and not ( copTeams [ getTeamName ( getPlayerTeam ( player ) ) ] ) then 
        cancelEvent ( ) 
        outputChatBox ( "Only policeman can enter police cars!", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), 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...