isa_Khamdan Posted August 16, 2013 Author Posted August 16, 2013 addEventHandler("onVehicleEnter", getRootElement(), function () if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ); if ( v ) then vehicleTimer[thePlayer] = setTimer ( randomVehColors, 2000, 0, thePlayer ); end end end ); It doesn't work? Error Bad argument in getPlayerSerial
isa_Khamdan Posted August 16, 2013 Author Posted August 16, 2013 "thePlayer" is not defined. Thank you but it will set the timer anytime you get into the vehicle even if you didn't use the command before to start it I want it that if you use the command it will start and if you exit the Vehicle it will stop and when you enter and the command was already used it will start the timer again and that's the whole code local theSerial = "0396C6F543425FFE37A326883D73B4F4" local vehicleTimer = {} addCommandHandler("colors", function(thePlayer, command) if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ); if ( v ) then if ( isTimer ( vehicleTimer[thePlayer] ) ) then killTimer ( vehicleTimer[thePlayer] ); return; end vehicleTimer[thePlayer] = setTimer ( randomVehColors, 2000, 0, thePlayer ); end end end ); addEventHandler("onVehicleEnter", getRootElement(), function ( thePlayer ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ); if ( v ) then vehicleTimer[thePlayer] = setTimer ( randomVehColors, 2000, 0, thePlayer ); end end end ); addEventHandler( "onVehicleStartExit", root, function ( thePlayer ) if ( isTimer ( vehicleTimer[thePlayer] ) ) then killTimer ( vehicleTimer[thePlayer] ); end end ); local color = {} function randomVehColors ( thePlayer ) local car = getPedOccupiedVehicle( thePlayer ) if not ( car ) then if ( isTimer ( vehicleTimer[thePlayer] ) ) then killTimer ( vehicleTimer[thePlayer] ); end return; end if ( isVehicleDamageProof( car ) == true ) then color[1] = math.random(0,126) ; color[2] = math.random(0,126); color[3] = math.random(0,126); color[4] = math.random(0,126) ; setVehicleColor ( car, color[1], color[2], color[3], color[4] ) end end
Castillo Posted August 16, 2013 Posted August 16, 2013 local theSerial = "0396C6F543425FFE37A326883D73B4F4" local vehicleTimer = { } local isEnabled = { } addCommandHandler ( "colors", function ( thePlayer, command ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( not isEnabled [ thePlayer ] ) then isEnabled [ thePlayer ] = true else isEnabled [ thePlayer ] = false end if ( isEnabled [ thePlayer ] and v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end ) addEventHandler ( "onVehicleEnter", getRootElement(), function ( thePlayer ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then if ( isEnabled [ thePlayer ] ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end end ) addEventHandler ( "onVehicleStartExit", root, function ( thePlayer ) if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end end ) function randomVehColors ( thePlayer ) local car = getPedOccupiedVehicle( thePlayer ) if ( not car ) then if ( isTimer ( vehicleTimer [ thePlayer] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end return end if ( isVehicleDamageProof ( car ) == true ) then local c1 = math.random ( 0, 126 ) local c2 = math.random ( 0, 126 ) local c3 = math.random ( 0, 126 ) local c4 = math.random ( 0, 126 ) setVehicleColor ( car, c1, c2, c3, c4 ) end end
isa_Khamdan Posted August 16, 2013 Author Posted August 16, 2013 local theSerial = "0396C6F543425FFE37A326883D73B4F4" local vehicleTimer = { } local isEnabled = { } addCommandHandler ( "colors", function ( thePlayer, command ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( not isEnabled [ thePlayer ] ) then isEnabled [ thePlayer ] = true else isEnabled [ thePlayer ] = false end if ( isEnabled [ thePlayer ] and v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end ) addEventHandler ( "onVehicleEnter", getRootElement(), function ( thePlayer ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then if ( isEnabled [ thePlayer ] ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end end ) addEventHandler ( "onVehicleStartExit", root, function ( thePlayer ) if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end end ) function randomVehColors ( thePlayer ) local car = getPedOccupiedVehicle( thePlayer ) if ( not car ) then if ( isTimer ( vehicleTimer [ thePlayer] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end return end if ( isVehicleDamageProof ( car ) == true ) then local c1 = math.random ( 0, 126 ) local c2 = math.random ( 0, 126 ) local c3 = math.random ( 0, 126 ) local c4 = math.random ( 0, 126 ) setVehicleColor ( car, c1, c2, c3, c4 ) end end Thanks a lot it works like a charm now
isa_Khamdan Posted August 16, 2013 Author Posted August 16, 2013 You're welcome. there still one problem when I type the command again it don't stop changing the colors?
Castillo Posted August 16, 2013 Posted August 16, 2013 local theSerial = "0396C6F543425FFE37A326883D73B4F4" local vehicleTimer = { } local isEnabled = { } addCommandHandler ( "colors", function ( thePlayer, command ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( not isEnabled [ thePlayer ] ) then isEnabled [ thePlayer ] = true else if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end isEnabled [ thePlayer ] = false end if ( isEnabled [ thePlayer ] and v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end ) addEventHandler ( "onVehicleEnter", getRootElement(), function ( thePlayer ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then if ( isEnabled [ thePlayer ] ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end end ) addEventHandler ( "onVehicleStartExit", root, function ( thePlayer ) if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end end ) function randomVehColors ( thePlayer ) local car = getPedOccupiedVehicle( thePlayer ) if ( not car ) then if ( isTimer ( vehicleTimer [ thePlayer] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end return end if ( isVehicleDamageProof ( car ) == true ) then local c1 = math.random ( 0, 126 ) local c2 = math.random ( 0, 126 ) local c3 = math.random ( 0, 126 ) local c4 = math.random ( 0, 126 ) setVehicleColor ( car, c1, c2, c3, c4 ) end end
isa_Khamdan Posted August 16, 2013 Author Posted August 16, 2013 local theSerial = "0396C6F543425FFE37A326883D73B4F4" local vehicleTimer = { } local isEnabled = { } addCommandHandler ( "colors", function ( thePlayer, command ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( not isEnabled [ thePlayer ] ) then isEnabled [ thePlayer ] = true else if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end isEnabled [ thePlayer ] = false end if ( isEnabled [ thePlayer ] and v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end ) addEventHandler ( "onVehicleEnter", getRootElement(), function ( thePlayer ) if ( getPlayerSerial ( thePlayer ) == theSerial ) then if ( isEnabled [ thePlayer ] ) then local v = getPedOccupiedVehicle ( thePlayer ) if ( v ) then if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end vehicleTimer [ thePlayer ] = setTimer ( randomVehColors, 2000, 0, thePlayer ) end end end end ) addEventHandler ( "onVehicleStartExit", root, function ( thePlayer ) if ( isTimer ( vehicleTimer [ thePlayer ] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end end ) function randomVehColors ( thePlayer ) local car = getPedOccupiedVehicle( thePlayer ) if ( not car ) then if ( isTimer ( vehicleTimer [ thePlayer] ) ) then killTimer ( vehicleTimer [ thePlayer ] ) end return end if ( isVehicleDamageProof ( car ) == true ) then local c1 = math.random ( 0, 126 ) local c2 = math.random ( 0, 126 ) local c3 = math.random ( 0, 126 ) local c4 = math.random ( 0, 126 ) setVehicleColor ( car, c1, c2, c3, c4 ) end end Thanks again
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