Jump to content

Car Light Colors and Car Colors


BabY

Recommended Posts

https://wiki.multitheftauto.com/wiki/Set ... LightColor

https://wiki.multitheftauto.com/wiki/SetVehicleColor

it depends how are you gonna make it. it can be client side only, it can be server side only, it can be both client and server side :)

if you want to save this things - you will need server anyway.

generally:

if you want to change this same for everyone - clientside is enough

if you want this to be changeable by users - serverside is enough (via commands)

if you want this to be changeable by users with gui - client+server should be done (although its possible to make it only clientside, but its better to be client-server scripts)

Link to comment

All What I Want is To make a Randomly Changing Lights and Car Colors ... for all Cars ...

Like By Using "math.random(0,255)" ...

and I'am Using the Debug Script , I Sucks ... and Hard

Look at This :

  
funcion lights () 
        setVehicleHeadLightColor (math.random(0,255), math.random(0,255), math.random(0,255)) 
end 
        setTimer ( lights, 200, 0 ) 
  
addEventHandler ("onResourceStart", root, lights) 
  

Link to comment
function consoleSetVehicleColor ( playerSource, commandName, col1, col2, col3, col4 ) 
    -- If a player triggered this in-game 
    if ( playerSource ) then 
        -- Get the player's vehicle 
        playerVehicle = getPlayerOccupiedVehicle ( playerSource ) 
        -- If the player is in a vehicle and we've got at least 1 parameter 
        if ( playerVehicle and col1 ) then 
            -- Get the vehicle's existing color and use it if fewer than 4 arguments were passed 
            exCol1, exCol2, exCol3, exCol4 = getVehicleColor ( playerVehicle ) 
  
            if not col2 then col2 = exCol2 end 
            if not col3 then col3 = exCol3 end 
            if not col4 then col4 = exCol4 end 
  
            -- Set the vehicle's color 
            setVehicleColor ( playerVehicle, col1, col2, col3, col4 ) 
        else 
            -- If we didn't get at least 1 parameter or the player doesn't have a vehicle, display some help text 
            outputConsole ( "This function will set your current vehicle's colors. A vehicle can have up to 4 colors.", playerSource ) 
            outputConsole ( "Syntax: set_vehicle_color color1 [ color2 color3 color4 ]", playerSource ) 
            outputConsole ( "You must be in a vehicle to use this function.", playerSource ) 
        end 
    end 
end 
  
-- Register the command handler and attach it to the consoleSetVehicleColor function 
addCommandHandler ( "set_vehicle_color", consoleSetVehicleColor ) 

Link to comment
funcion lights () 
for i,v in pairs (getElementsByType("vehicle") do 
        setVehicleHeadLightColor (v, math.random(0,255), math.random(0,255), math.random(0,255)) 
end 
setTimer ( lights, 200, 0 ) 
end 
addEventHandler ("onResourceStart", root, lights) 

try that.

Link to comment

omg, this will add new infinite-times timer every 200ms

this is better and wont kill the server:

  
funcion lights () 
  for i,v in pairs (getElementsByType("vehicle") do 
    setVehicleHeadLightColor (v, math.random(0,255), math.random(0,255), math.random(0,255)) 
  end 
end 
function startTimer() 
  setTimer ( lights, 200, 0 ) 
end 
addEventHandler ("onResourceStart", root, startTimer) 
  

Link to comment
  • 3 weeks later...
function lights () 
        for i,v in pairs (getElementsByType ("vehicle") [color=#ff0000]do[/color] 
        setVehicleHeadLightColor (v, math.random(0,255), math.random(0,255), math.random(0,255)) 
        end 
end 
function lightt() 
        setTimer ( lights, 800, 0 ) 
end 
addEventHandler ("onResourceStart", root, lightt) 

faaast.png

Theres a Problem in the Command 'do' :roll:

Link to comment

LoL

This what I Added, Made a New Problem ...

  
function startclient () 
    outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
    outputChatBox ( " " , 0 , 0 , 0 , true ) 
    outputChatBox ( "#ff0000Happy #0000f0New #00ff002011 #ff00ffYear" , 0 , 0 , 0 , true ) 
    outputChatBox ( " ",0,0,0,true) 
    outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
    setSkyGradient ( 50 , 255 , 255 , 65 , 100 , 25 ) 
    setWaterColor ( 50 , 60 , 100 ) 
    setTime ( 1 , 0 ) 
    setWaveHeight ( 0.5 ) 
    setBlurLevel ( 5 ) 
    setWeather ( 99 ) 
     
     
    Marker1 = createMarker ( 4182.88671875, -2876.1853027344, 1062.5003662109, "corona", 7, 0, 0, 255, 200) 
    Marker2 = createMarker ( 4703.38525390, -2239.5251464844, 1609.0306396484, "corona", 10, 255, 55, 55, 200) 
    addEventHandler ( "onMarkerHit", Marker1, markerHit) 
    addEventHandler ( "onMarkerHit", Marker2, markerHit) 
     
end 
  
  
function warp (player) 
  
  
if source == Marker1 then  -- First Marker 
    if isPedInVehicle(player) then 
        local vehicle=getPedOccupiedVehicle(player)  
            setElementPosition (vehicle , 4154.0571289063, -2392.6955566406, 1608.3810302734 ) 
            setElementRotation (vehicle , 0,0,310.5) 
            setVehicleFrozen ( vehicle , true ) 
            setTimer( setVehicleFrozen, 300, 1, vehicle, false ) 
            setWeather ( 99 ) 
            setTime ( 00 , 0 ) 
            setBlurLevel ( 0 ) 
             
        end 
end 
  
  
  
if source == Marker2 then  -- Second Marker 
    if isPedInVehicle(player) then 
        local vehicle=getPedOccupiedVehicle(player) 
            setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 )   
            setElementRotation (vehicle , 0, 0, 0 ) 
            setVehicleFrozen ( vehicle , true ) 
            setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
            setTime ( 00, 0 ) 
            setBlurLevel (20 ) 
            setGameSpeed ( 1.2 ) 
            setWeather ( 99 ) 
function randomVehColors()  --LOOOOOL ... FINALLY I MADE THIS SCRIPT !!!! xDDDD 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
        local color = {} 
        color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 
        color[2] = math.random(0,126) 
        color[3] = math.random(0,126) 
        color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors 
        setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle 
    end 
end 
  
function loll ()  -- Mario World 
            setSkyGradient (math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255)) 
            setWaterColor (math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
            setTimer (loll, 800, 0) 
            setTimer( randomVehColors, 800, 0 ) 
    end 
function lights () 
        for i,v in pairs (getElementsByType ("vehicle")) do 
        setVehicleHeadLightColor (v, math.random(0,255), math.random(0,255), math.random(0,255)) 
        end 
end 
function lightt() 
        setTimer ( lights, 800, 0 ) 
end 
addEventHandler ("onResourceStart", root, lightt) 
  
end 
             
  
  
  
function markerHit(thePlayer,dimension) 
  
  
  if (dimension and thePlayer==getLocalPlayer()) then 
            local sound = playSound("files/warp.mp3") -- Sound Isn't Working 
        end 
  
end 
end 
  
  
addEventHandler( "onClientResourceStart", resourceRoot, startclient, loll ) 
addEventHandler( "onClientMarkerHit", getRootElement(), warp ) 

Look at line 18 and 19

It Says bad Argument ...

Link to comment

because you've lost your "end"s again, try at least use indents, right now it's a mess.

you can't just take a part of the code and stick it anywhere expecting it to work.

function startclient () 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  outputChatBox ( " " , 0 , 0 , 0 , true ) 
  outputChatBox ( "#ff0000Happy #0000f0New #00ff002011 #ff00ffYear" , 0 , 0 , 0 , true ) 
  outputChatBox ( " ",0,0,0,true) 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  setSkyGradient ( 50 , 255 , 255 , 65 , 100 , 25 ) 
  setWaterColor ( 50 , 60 , 100 ) 
  setTime ( 1 , 0 ) 
  setWaveHeight ( 0.5 ) 
  setBlurLevel ( 5 ) 
  setWeather ( 99 ) 
  Marker1 = createMarker ( 4182.88671875, -2876.1853027344, 1062.5003662109, "corona", 7, 0, 0, 255, 200) 
  Marker2 = createMarker ( 4703.38525390, -2239.5251464844, 1609.0306396484, "corona", 10, 255, 55, 55, 200) 
  addEventHandler("onMarkerHit", Marker1, warp) 
  addEventHandler("onMarkerHit", Marker2, warp) 
  setTimer(lights, 800, 0) -- this way your timers will start at resource start 
  setTimer(loll, 800, 0) 
  setTimer(randomVehColors, 800, 0)   
end 
   
function warp(player) 
  if isPedInVehicle(player) then 
    if source == Marker1 then  -- First Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4154.0571289063, -2392.6955566406, 1608.3810302734 ) 
      setElementRotation (vehicle , 0,0,310.5) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 300, 1, vehicle, false ) 
      setWeather ( 99 ) 
      setTime ( 00 , 0 ) 
      setBlurLevel ( 0 ) 
    elseif source == Marker2 then  -- Second Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 )  
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
      setTime ( 00, 0 ) 
      setBlurLevel (20 ) 
      setGameSpeed ( 1.2 ) 
      setWeather ( 99 ) 
    end           
  end   
end   
  
function randomVehColors()  --LOOOOOL ... FINALLY I MADE THIS SCRIPT !!!! xDDDD 
  for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
    local color = {} 
    color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 
    color[2] = math.random(0,126) 
    color[3] = math.random(0,126) 
    color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors 
    setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle 
  end 
end 
  
function loll() -- Mario World 
  setSkyGradient(math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255)) 
  setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
  
function lights() 
  for i,v in pairs (getElementsByType ("vehicle")) do 
    setVehicleHeadLightColor(v, math.random(0,255), math.random(0,255), math.random(0,255)) 
  end 
end 
  
function markerHitSound() 
  local sound = playSound("files/warp.mp3") -- Sound Isn't Working 
end 
  
addEventHandler( "onClientResourceStart", resourceRoot, startclient) 

Link to comment
edit it then to suit your needs. we won't make everything for you.

Joke ?

I Think Aibo Messed the Script Up ,

and I Don't Know how to Fix it ,

and the Debug Scripter Sucks ,

Look Guys ...

Thanks for Every Think

I Will Try to Post in Another Forum ...

Link to comment

Aiboforced didn't messed it up - you didn't explained your thoughs.

Debug script is fine - you can't use it.

And about posting in other forums - most of your posts are random spam.

Sad thing - those are facts :(

Hint for you to solve problem:

Look on line 17 in Aiboforcen code.

Just move it to marker hit handler function.

Link to comment

ok dude, you're way out of line here (like there are any other forums to post :D), try to behave yourself

the reason you markers wont work: "onMarkerHit" is server event. i didnt know whether this script is client or server side (hard to understand what you're saying), so i havent changed them to either side.

i've put timers on resource start because in that mess of a code you got it wasnt obvious where you want them to start (and again, your "explanations" not helping much).

and that is i've put a COMMENT in there to note how it will work.

you don't want to learn, you dont even want to understand, you just want that someone scripted it for you. well that way eventually noone will bother to help you, not with that attitude.

function startclient () 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  outputChatBox ( " " , 0 , 0 , 0 , true ) 
  outputChatBox ( "#ff0000Happy #0000f0New #00ff002011 #ff00ffYear" , 0 , 0 , 0 , true ) 
  outputChatBox ( " ",0,0,0,true) 
  outputChatBox ( "= = = = = = = = = =" , 255 , 255 , 0 , true ) 
  setSkyGradient ( 50 , 255 , 255 , 65 , 100 , 25 ) 
  setWaterColor ( 50 , 60 , 100 ) 
  setTime ( 1 , 0 ) 
  setWaveHeight ( 0.5 ) 
  setBlurLevel ( 5 ) 
  setWeather ( 99 ) 
  Marker1 = createMarker ( 4182.88671875, -2876.1853027344, 1062.5003662109, "corona", 7, 0, 0, 255, 200) 
  Marker2 = createMarker ( 4703.38525390, -2239.5251464844, 1609.0306396484, "corona", 10, 255, 55, 55, 200) 
  addEventHandler("onClientMarkerHit", Marker1, warp) 
  addEventHandler("onClientMarkerHit", Marker2, warp) 
end 
  
function warp(player) 
  if player == getLocalPlayer() and isPedInVehicle(player) then 
    if source == Marker1 then  -- First Marker 
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4154.0571289063, -2392.6955566406, 1608.3810302734 ) 
      setElementRotation (vehicle , 0,0,310.5) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 300, 1, vehicle, false ) 
      setWeather ( 99 ) 
      setTime ( 00 , 0 ) 
      setBlurLevel ( 0 ) 
    elseif source == Marker2 then  -- Second Marker 
      setTimer(lights, 800, 0)  
      setTimer(loll, 800, 0) 
      setTimer(randomVehColors, 800, 0)   
      markerHitSound() 
      local vehicle=getPedOccupiedVehicle(player) 
      setElementPosition (vehicle , 4169.7006835938, -2271.2592773438, 1111.0838623047 ) 
      setElementRotation (vehicle , 0, 0, 0 ) 
      setVehicleFrozen ( vehicle , true ) 
      setTimer( setVehicleFrozen, 700, 1, vehicle, false ) 
      setTime ( 00, 0 ) 
      setBlurLevel (20 ) 
      setGameSpeed ( 1.2 ) 
      setWeather ( 99 ) 
    end           
  end   
end   
  
function randomVehColors()  --LOOOOOL ... FINALLY I MADE THIS SCRIPT !!!! xDDDD 
  for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
    local color = {} 
    color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 
    color[2] = math.random(0,126) 
    color[3] = math.random(0,126) 
    color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors 
    setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle 
  end 
end 
  
function loll() -- Mario World 
  setSkyGradient(math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255)) 
  setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) 
end 
  
function lights() 
  for i,v in pairs (getElementsByType ("vehicle")) do 
    setVehicleHeadLightColor(v, math.random(0,255), math.random(0,255), math.random(0,255)) 
  end 
end 
  
function markerHitSound() 
  local sound = playSound("files/warp.mp3") -- Sound Isn't Working 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, startclient) 

Link to comment

I don't know if anyone know that wiki exists and it has examples for you as well...

https://wiki.multitheftauto.com/wiki/SetVehicleColor

Have you looked at the "Example 2"? I guess, you have, eventually.

I was also wondering what are client-side events doing in server-side script? Such scripts don't need to be client-side. It's best to do as much functionality in server-side script as possible. I personally love client-side scripting but I don't make client-side script for something that's possible to be made in a server-side script.

Link to comment

Thanks a Lot Aiboforcen,

I Just Deleted 'end' in the Line 47 and Made the Stuff work in the Marker :P

Thanks to all who Suffered from my Language :oops:

Special Thanks to dzek :D and Aiboforcen :D

and 50p

I Already Took the Script from the Wiki

But all This was About "setVehicleHeadLightColor" ...

and I Counldn't Find any Eamples to Change it Randomly

so,

Please Lock :D

70175311.gif

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...