Jump to content

SOLVED!


Krklec

Recommended Posts

Hello guys!

I'm trying to make script that make vehicle locked to certain skin. But I made something wrong and I don't know how to fix it.

I'm still learning to script so this script isn't good. Can you help and fix the problem?

function cars () 
    c1 = createVehicle ( 602, 2284.399, -1114.599, 37.700, 0, 0, 90 ) 
end 
  
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function lock () 
        if getElementModel ( thePlayer ) == 29 then 
            setVehicleLocked ( c1, false ) 
        else 
            setVehicleLocked ( c1, true ) 
            removePedFromVehicle ( source ) 
            outputChatBox ("This vehicle is locked on team: Avenged Sevenfold!", source) 
        end 
end 
  
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), lock  

Thanks!

Edited by Guest
Link to comment
function cars () 
    c1 = createVehicle ( 602, 2284.399, -1114.599, 37.700, 0, 0, 90 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function lock (vehicle) 
    if (vehicle == c1) then 
        if (not getElementModel (source) == 29) then 
            cancelEvent() 
            outputChatBox ("This vehicle is locked on team: Avenged Sevenfold!", source) 
        end 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), lock) 

Edited by Guest
Link to comment

Yup.

function cars () 
    c1 = createVehicle ( 602, 2284.399, -1114.599, 37.700, 0, 0, 90 ) 
end 
  
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function lock () 
        if getElementModel ( source ) == 29 then 
            setVehicleLocked ( c1, false ) 
        else 
            setVehicleLocked ( c1, true ) 
            removePedFromVehicle ( source ) 
            outputChatBox ("This vehicle is locked on team: Avenged Sevenfold!", source) 
        end 
end 
  
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), lock) 

You had 'thePlayer' here, while it had to be 'source':

if getElementModel ( thePlayer ) == 29 then 

Link to comment

I think that is because of 'setVehicleLocked'. Try this:

function onEnter(thePlayer) 
    if (getElementModel(thePlayer) ~= 29) then 
        cancelEvent() 
        outputChatBox("Test1", thePlayer) 
    end 
end 
  
addEventHandler("onVehicleStartEnter", getRootElement(), onEnter) 

Link to comment
I think that is because of 'setVehicleLocked'. Try this:
function onEnter(thePlayer) 
    if (getElementModel(thePlayer) ~= 29) then 
        cancelEvent() 
        outputChatBox("Test1", thePlayer) 
    end 
end 
  
addEventHandler("onVehicleStartEnter", getRootElement(), onEnter) 

Et-win, that worked, thank you so much.

SOLVED!

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