Jump to content

Script for restricting vehciles


tim260

Recommended Posts

copVehicles = { [470]=true,[433]=true,[548]=true,[532]=true,[425]=true } 
copTeams = {["Police"]=true,["Cop"]=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 aren't a Police Officer , you mayn't drive this.", player ) --and tell the player why 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), copenterVehicle ) 

If i wanna make this for military vehicles what do i change ? do i do it like this ? :

militaryVehicles = { [523]=true,[598]=true,[596]=true,[597]=true,[490]=true } 
copTeams = {["Military"]=true,["Naval"]=true} 
  
function copenterVehicle ( player, seat, jacked ) 
    if ( militaryvehiclesVehicles[getElementModel ( source )] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) and ( seat == 0 ) then 
        removePedFromVehicle ( player )--force the player out of the vehicle 
        outputChatBox ( "You aren't a Military Officer , you mayn't drive this.", player ) --and tell the player why 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), copenterVehicle ) 

Link to comment

I would suggest using onVehicleStartEnter, then you can cancel the function before being executed.

militaryVehicles = { [523]=true,[598]=true,[596]=true,[597]=true,[490]=true } 
copTeams = {["Military"]=true,["Naval"]=true} 
  
function copenterVehicle ( player, seat, jacked ) 
    if ( militaryvehiclesVehicles[getElementModel ( source )] ) and ( not copTeams[getTeamName(getPlayerTeam( player ))] ) and ( seat == 0 ) then 
        outputChatBox ( "You aren't a Military Officer , you mayn't drive this.", player ) --and tell the player why 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), copenterVehicle ) 

Link to comment

Hmm Solidsnake it doesnt work probably its me making a mistake here :D so now i will thake this oppertunity to show this :

( its also not working but i dont know why )

function replaceTXD() 
  
txd = engineLoadTXD("textures/billbrd01_lan.txd") 
  engineImportTXD(txd, 4238) 
  
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceTXD) 

/\ thats my replacement for a billboard but it doesnt work, below my meta \/

  
type="script" version="1.0" author="tim"/> type="client" src="textures/billbrd01_lan.txd"/>  

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