Jump to content

[HELP] Not allowed vehicles to drive


Brolis

Recommended Posts

Hi again, today I would like to ask you to give me a link to script/resource or create it to me, say how to create and ect. for not allowed vehicles.

Simple: I get in infernus and I have been kicked from this car with a chatboxmsg: * You are not allowed to drive this!

Or, When I am trying to get in I am not get'n there just no action with a same message.

Or something I just said.

Please, help me someone. Thanks a lot!

Link to comment
function enter ( theVehicle ) 
    local id = getElementModel ( theVehicle ) -- get the model ID of the vehicle 
    if id == 519 or id == 577 then 
  cancelEvent () 
outputChatBox("You're not allowed to drive this vehicle!") 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enter ) 

This may work, I have not tested it, I just simply edited some wiki thing. You'll have to replace the ID's though so they are the infernus's ID.

PS. Sorry if it doesn't work, as I said - I've not tested it.

Link to comment
function enter ( theVehicle, player ) 
    local id = getElementModel ( theVehicle ) -- get the model ID of the vehicle 
    if id == 487 or id == 577 then 
removePedFromVehicle ( source ) 
outputChatBox("You're not allowed to drive this vehicle!") 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enter ) 

Fixed and tested.

Link to comment
Guest Guest4401
addEventHandler("onVehicleStartEnter",root, 
    function() 
        cancelEvent() 
    end 
) 

Using ^that event is much more smoother in my opinion.

Link to comment
Guest Guest4401
But he doesn't say that it needs to be canceled for all vehicles.
Simple: I get in infernus and I have been kicked from this car with a chatboxmsg: * You are not allowed to drive this!
addEventHandler("onVehicleStartEnter",root, 
    function(p) 
        if getVehicleName(source) == "Infernus" then 
            outputChatBox("* You are not allowed to drive this!",p) 
            cancelEvent() 
        end 
    end 
) 

Link to comment
root = getRootElement() 
local blockedVehicleIDS = {[402]=true,[411]=true} 
  
addEventHandler("onVehicleStartEnter",root, 
    function(p) 
        if blockedVehicleIDS[getElementModel(source) ] then 
            outputChatBox("* You are not allowed to drive this!",p) 
            cancelEvent() 
        end 
    end 
) 

Just optimized.. if list get too big

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