Krklec Posted August 25, 2014 Share Posted August 25, 2014 (edited) 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 August 25, 2014 by Guest Link to comment
Wei Posted August 25, 2014 Share Posted August 25, 2014 (edited) 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 August 25, 2014 by Guest Link to comment
Et-win Posted August 25, 2014 Share Posted August 25, 2014 Typ in the chatbox in-game: /debugscript 3 Does it output anything? ;P Link to comment
Krklec Posted August 25, 2014 Author Share Posted August 25, 2014 It still doesn't work Wei, but thanks. and i wrote /debugscript 3 and it show me this but I believe all this is from other scripts that r on server. Link to comment
Krklec Posted August 25, 2014 Author Share Posted August 25, 2014 yeah... copy it again doesn't work, no matter what skin that i'm using, I can still get in vehicle. Link to comment
Et-win Posted August 25, 2014 Share Posted August 25, 2014 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
Krklec Posted August 25, 2014 Author Share Posted August 25, 2014 Now it's kinda weird, because when i'm in "29" skin i can't get into car, it gives me lock animation, but when i'm in different skin I get in and get kicked out. Link to comment
Et-win Posted August 25, 2014 Share Posted August 25, 2014 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
Krklec Posted August 25, 2014 Author Share Posted August 25, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now