Alen141 Posted December 26, 2012 Share Posted December 26, 2012 So i'm working on my private vehicle system,but it doesn't work why? here is lua : local vehicle = createVehicle( 602, 2279.1000976563, -1671.1999511719, 15.10000038147, 0, 0, 272 ) addEventHandler("onVehicleStartEnter", vehicle, function(player, seat, jacked) if ( source == vehicle ) then local user = getAccountName ( Alen ) if ( user == "Alen" ) then cancelEvent() outputChatBox("This vehicle is private.", player, 255, 0, 0, false) else outputChatBox("Welcome to your vehicle,Sir!", player, 0, 255, 0, false) end end end ) Link to comment
MatXpl Posted December 26, 2012 Share Posted December 26, 2012 use addEventHandler("onVehicleStartEnter", getRootElement(), if it dosnt work, sumbit a debug Link to comment
Alen141 Posted December 26, 2012 Author Share Posted December 26, 2012 use addEventHandler("onVehicleStartEnter", getRootElement(), if it dosnt work, sumbit a debug not working DEBUG : expected to close at line 3 near function Link to comment
MatXpl Posted December 26, 2012 Share Posted December 26, 2012 it should working have you another code in this script ? Link to comment
Castillo Posted December 26, 2012 Share Posted December 26, 2012 getAccountName requires an account element, you are using a variable that is not even defined. Link to comment
MatXpl Posted December 26, 2012 Share Posted December 26, 2012 Solidsnake14 have right you should use https://wiki.multitheftauto.com/wiki/GetPlayerAccount Link to comment
TAPL Posted December 26, 2012 Share Posted December 26, 2012 And i guess that you was meant this: if ( user == "Alen" ) then To be: if ( user ~= "Alen" ) then Link to comment
فتى تبوك Posted December 27, 2012 Share Posted December 27, 2012 local vehicle = createVehicle( 602, 2279.1000976563, -1671.1999511719, 15.10000038147, 0, 0, 272 ) addEventHandler("onVehicleStartEnter", vehicle, function(player, seat, jacked) if ( source == vehicle ) then local user = getAccountName ( Alen ) if ( user ~= "Alen" ) then cancelEvent() outputChatBox("This vehicle is private.", player, 255, 0, 0, false) else outputChatBox("Welcome to your vehicle,Sir!", player, 0, 255, 0, false) end end end ) Link to comment
TAPL Posted December 27, 2012 Share Posted December 27, 2012 local vehicle = createVehicle( 602, 2279.1000976563, -1671.1999511719, 15.10000038147, 0, 0, 272 ) addEventHandler("onVehicleStartEnter", vehicle, function(player, seat, jacked) if ( source == vehicle ) then local user = getAccountName ( Alen ) if ( user ~= "Alen" ) then cancelEvent() outputChatBox("This vehicle is private.", player, 255, 0, 0, false) else outputChatBox("Welcome to your vehicle,Sir!", player, 0, 255, 0, false) end end end ) This still wrong. Link to comment
ali Posted December 27, 2012 Share Posted December 27, 2012 try this function idk () local X, Y, Z = 2279.1000976563, -1671.1999511719, 15.10000038147 abcvehicle = createVehicle ( 602, X, Y, Z ) addEventHandler("onVehicleStartEnter", abcvehicle, abc ) end addEventHandler ( "onResourceStart", resourceRoot, idk ) function abc ( thePlayer, seat, jacked ) local accname = getAccountName ( getPlayerAccount ( thePlayer ) ) if accname == "Alen" then outputChatBox ("Welcome to your vehicle,Sir!", thePlayer, 0,255,0) else cancelEvent() outputChatBox("This vehicle is private", thePlayer, 255, 0, 0) 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