PanBob Posted March 22, 2017 Share Posted March 22, 2017 The console pops up: WARNING: discoswiatla/server.lua:26: Bad argument @ 'setVehicleHeadLightColor' [Expected vehicle at argument 1] server.lua: local discoTimer = {} local discoState = {} function vehicleLights( player, command, lig1, lig2, lig3 ) lig1 = lig1 or math.random( 0, 255 ) lig2 = lig2 or math.random( 0, 255 ) lig3 = lig3 or math.random( 0, 255 ) local vehicle = getPedOccupiedVehicle( player ) if ( vehicle ) then setVehicleHeadLightColor( vehicle, lig1, lig2, lig3 ) outputChatBox("Your Car Have now another Light!", player, 0, 255, 0 ) else outputChatBox("you must have a vehicle for doing this!", player, 255, 0, 0 ) end end addCommandHandler("lights",vehicleLights) -- Change your VehicleLights function Disco(player,command) local vehicle = getPedOccupiedVehicle(player) if (vehicle) then if discoState[player] == false then discoState[player] = true discoTimer[player] = setTimer( function ( playerVehicle ) setVehicleHeadLightColor( playerVehicle, math.random(0,255), math.random(0,255), math.random(0,255) ) end , 100, 0, vehicle ) outputChatBox( "!!Disco-Fever!!", player, 0, 255, 0 ) else if discoTimer[player] then killTimer( discoTimer[player] ) discoTimer[player] = nil discoState[player] = false setVehicleHeadLightColor( vehicle, 255, 255, 255 ) end end else outputChatBox( "!!You have to sit in a Car/Bike!!", player, 255, 0, 0 ) end end addCommandHandler("disco",Disco)--Disco ((((:)))) function reset(player, command ) local vehicle = getPedOccupiedVehicle(player) local r,g,b = getVehicleHeadLightColor(vehicle) if (vehicle) then if not (r==255) and not (g==255) and not (b==255) then setVehicleHeadLightColor( vehicle, 255,255,255) end end end addCommandHandler("reset",reset) function setStateOnStart() for _, players in ipairs( getElementsByType( "player" ) ) do discoState[players] = false end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), setStateOnStart ); function setStateOnJoin() discoState[source] = false end addEventHandler( "onPlayerJoin", getRootElement(), setStateOnJoin ) function removeStateOnQuit() discoState[source] = nil end addEventHandler( "onPlayerQuit", getRootElement(), setStateOnJoin ) Link to comment
NeXuS™ Posted March 22, 2017 Share Posted March 22, 2017 (edited) Can you put the code between <> tags? Edited March 22, 2017 by NeXuS™ Link to comment
PanBob Posted March 22, 2017 Author Share Posted March 22, 2017 2 hours ago, NeXuS™ said: Can you put the code between <> tags? Oh... sorry. here: local discoTimer = {} local discoState = {} function vehicleLights( player, command, lig1, lig2, lig3 ) lig1 = lig1 or math.random( 0, 255 ) lig2 = lig2 or math.random( 0, 255 ) lig3 = lig3 or math.random( 0, 255 ) local vehicle = getPedOccupiedVehicle( player ) if ( vehicle ) then setVehicleHeadLightColor( vehicle, lig1, lig2, lig3 ) outputChatBox("Your Car Have now another Light!", player, 0, 255, 0 ) else outputChatBox("you must have a vehicle for doing this!", player, 255, 0, 0 ) end end addCommandHandler("lights",vehicleLights) -- Change your VehicleLights function Disco(player,command) local vehicle = getPedOccupiedVehicle(player) if (vehicle) then if discoState[player] == false then discoState[player] = true discoTimer[player] = setTimer( function ( playerVehicle ) setVehicleHeadLightColor( playerVehicle, math.random(0,255), math.random(0,255), math.random(0,255) ) end , 100, 0, vehicle ) outputChatBox( "!!Disco-Fever!!", player, 0, 255, 0 ) else if discoTimer[player] then killTimer( discoTimer[player] ) discoTimer[player] = nil discoState[player] = false setVehicleHeadLightColor( vehicle, 255, 255, 255 ) end end else outputChatBox( "!!You have to sit in a Car/Bike!!", player, 255, 0, 0 ) end end addCommandHandler("disco",Disco)--Disco ((((:)))) function reset(player, command ) local vehicle = getPedOccupiedVehicle(player) local r,g,b = getVehicleHeadLightColor(vehicle) if (vehicle) then if not (r==255) and not (g==255) and not (b==255) then setVehicleHeadLightColor( vehicle, 255,255,255) end end end addCommandHandler("reset",reset) function setStateOnStart() for _, players in ipairs( getElementsByType( "player" ) ) do discoState[players] = false end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), setStateOnStart ); function setStateOnJoin() discoState[source] = false end addEventHandler( "onPlayerJoin", getRootElement(), setStateOnJoin ) function removeStateOnQuit() discoState[source] = nil end addEventHandler( "onPlayerQuit", getRootElement(), setStateOnJoin ) Link to comment
PanBob Posted March 22, 2017 Author Share Posted March 22, 2017 local discoTimer = {} local discoState = {} function vehicleLights( player, command, lig1, lig2, lig3 ) lig1 = lig1 or math.random( 0, 255 ) lig2 = lig2 or math.random( 0, 255 ) lig3 = lig3 or math.random( 0, 255 ) local vehicle = getPedOccupiedVehicle( player ) if ( vehicle ) then setVehicleHeadLightColor( vehicle, lig1, lig2, lig3 ) outputChatBox("Your Car Have now another Light!", player, 0, 255, 0 ) else outputChatBox("you must have a vehicle for doing this!", player, 255, 0, 0 ) end end addCommandHandler("lights",vehicleLights) -- Change your VehicleLights function Disco(player,command) local vehicle = getPedOccupiedVehicle(player) if (vehicle) then if discoState[player] == false then discoState[player] = true discoTimer[player] = setTimer( function ( playerVehicle ) setVehicleHeadLightColor( playerVehicle, math.random(0,255), math.random(0,255), math.random(0,255) ) end , 100, 0, vehicle ) outputChatBox( "!!Disco-Fever!!", player, 0, 255, 0 ) else if discoTimer[player] then killTimer( discoTimer[player] ) discoTimer[player] = nil discoState[player] = false setVehicleHeadLightColor( vehicle, 255, 255, 255 ) end end else outputChatBox( "!!You have to sit in a Car/Bike!!", player, 255, 0, 0 ) end end addCommandHandler("disco",Disco)--Disco ((((:)))) function reset(player, command ) local vehicle = getPedOccupiedVehicle(player) local r,g,b = getVehicleHeadLightColor(vehicle) if (vehicle) then if not (r==255) and not (g==255) and not (b==255) then setVehicleHeadLightColor( vehicle, 255,255,255) end end end addCommandHandler("reset",reset) function setStateOnStart() for _, players in ipairs( getElementsByType( "player" ) ) do discoState[players] = false end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), setStateOnStart ); function setStateOnJoin() discoState[source] = false end addEventHandler( "onPlayerJoin", getRootElement(), setStateOnJoin ) function removeStateOnQuit() discoState[source] = nil end addEventHandler( "onPlayerQuit", getRootElement(), setStateOnJoin ) 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