ali Posted October 20, 2012 Share Posted October 20, 2012 server local X, Y, Z = 0, 3, 4 local accName1 = getAccountName ( getPlayerAccount ( player ) ) function idk () abc = createVehicle ( 432, X, Y, Z + 10 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), idk ) function abc ( theplayer, seat, jacked ) if accName1 = "aliarman" then outputChatBox ("Welcome to your Car") else cancelEvent() end end addEventHandler("onVehicleEnter", getRootElement(), abc ) meta.xml <meta> <info author="Ali" name="vehicle" version="2.0" type="script"/> <script src="ali.lua" type="server"/> </meta> error [2012-10-20 15:14:55] Starting speacialvehicle [2012-10-20 15:14:55] SCRIPT ERROR: speacialvehicle\ali.lua:11: 'then' expected near '=' [2012-10-20 15:14:55] WARNING: Loading script failed: speacialvehicle\ali.lua:11: 'then' expected near '=' Link to comment
Techial Posted October 20, 2012 Share Posted October 20, 2012 if(accName1=="aliarman")then Link to comment
denny199 Posted October 20, 2012 Share Posted October 20, 2012 (edited) addEventHandler("onVehicleEnter", getRootElement(), abc ) getRootElement() = for all elements, use the vehicle element. so: function idk () local X, Y, Z = 0, 3, 4 abcvehicle = createVehicle ( 432, X, Y, Z + 10 ) addEventHandler("onVehicleEnter", abcvehicle, abc ) end addEventHandler ( "onResourceStart", resourceRoot, idk ) function abc ( thePlayer, seat, jacked ) local accname = getAccountName ( getPlayerAccount ( thePlayer ) ) if accname == "denny19" then outputChatBox ("Welcome to your Car", thePlayer, 255,0,0,true) else cancelEvent() end end Tested Edited October 20, 2012 by Guest Link to comment
ali Posted October 20, 2012 Author Share Posted October 20, 2012 if(accName1=="aliarman")then got this [2012-10-20 15:49:20] Starting speacialvehicle [2012-10-20 15:49:20] WARNING: speacialvehicle\ali.lua:2: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-10-20 15:49:20] WARNING: speacialvehicle\ali.lua:2: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] Link to comment
Techial Posted October 20, 2012 Share Posted October 20, 2012 (edited) As stated above. function idk () local X, Y, Z = 0, 3, 4 abcvehicle = createVehicle ( 432, X, Y, Z + 10 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), idk ) function abc ( theplayer, seat, jacked ) local accname1 = getAccountName ( getPlayerAccount ( thePlayer ) ) if(accname1 == "aliarman") then outputChatBox ("Welcome to your Car", thePlayer, 255,0,0,true) else cancelEvent() end end addEventHandler("onVehicleEnter", root, abc ) Edited October 20, 2012 by Guest Link to comment
ali Posted October 20, 2012 Author Share Posted October 20, 2012 addEventHandler("onVehicleEnter", getRootElement(), abc )getRootElement() = for all elements, use the vehicle element. so: function idk () local X, Y, Z = 0, 3, 4 abcvehicle = createVehicle ( 432, X, Y, Z + 10 ) end addEventHandler ( "onResourceStart", resourceRoot, idk ) function abc ( theplayer, seat, jacked ) local accname = getAccountName ( getPlayerAccount ( thePlayer ) ) if accname == "aliarman" then outputChatBox ("Welcome to your Car", thePlayer, 255,0,0,true) else cancelEvent() end end addEventHandler("onVehicleEnter", abcvehicle, abc ) Tested got this [2012-10-20 15:51:35] Starting speacialvehicle [2012-10-20 15:51:35] WARNING: speacialvehicle\ali.lua:5: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] [2012-10-20 15:51:35] WARNING: speacialvehicle\ali.lua:15: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] Link to comment
denny199 Posted October 20, 2012 Share Posted October 20, 2012 (edited) I've edited the script. edit: here: function idk () local X, Y, Z = 0, 3, 4 abcvehicle = createVehicle ( 432, X, Y, Z + 10 ) addEventHandler("onVehicleEnter", abcvehicle, abc ) end addEventHandler ( "onResourceStart", resourceRoot, idk ) function abc ( thePlayer, seat, jacked ) local accname = getAccountName ( getPlayerAccount ( thePlayer ) ) if accname == "aliarman" then outputChatBox ("Welcome to your Car", thePlayer, 255,0,0,true) else cancelEvent() end end Edited October 20, 2012 by Guest Link to comment
Techial Posted October 20, 2012 Share Posted October 20, 2012 (edited) Use this: function idk () local X, Y, Z = 0, 3, 4 abcvehicle = createVehicle ( 432, X, Y, Z + 10 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), idk) function abc ( thePlayer, seat, jacked ) local accname1 = getAccountName ( getPlayerAccount ( thePlayer ) ) if(accname1 == "aliarman") then outputChatBox ("Welcome to your Car", thePlayer, 255,0,0,true) else cancelEvent() end end addEventHandler("onVehicleEnter", root, abc ) Edited October 20, 2012 by Guest Link to comment
denny199 Posted October 20, 2012 Share Posted October 20, 2012 Techial chek the function abc, it's [theplayer] and by getPlayerAccount [thePlayer] Use mine code, it's tested. Link to comment
ali Posted October 20, 2012 Author Share Posted October 20, 2012 Worked but the event didn't cancel Link to comment
Techial Posted October 20, 2012 Share Posted October 20, 2012 I don't know if you can cancel that event, try ejecting him instead. Link to comment
denny199 Posted October 20, 2012 Share Posted October 20, 2012 use onVehicleStartEnter instead of onVehicleEnter so: function idk () local X, Y, Z = 0, 3, 4 abcvehicle = createVehicle ( 432, X, Y, Z + 10 ) addEventHandler("onVehicleStartEnter", abcvehicle, abc ) end addEventHandler ( "onResourceStart", resourceRoot, idk ) function abc ( thePlayer, seat, jacked ) local accname = getAccountName ( getPlayerAccount ( thePlayer ) ) if accname == "aliarman" then outputChatBox ("Welcome to your Car", thePlayer, 255,0,0,true) else cancelEvent() end end 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