Jump to content

easy help


Stylez

Recommended Posts

Posted

Hey, guys need some help :P

function cham(thePlayer, cmdName, r,g,b) 
local Vehicle = getPedOccupiedVehicle(thePlayer) 
    if isPedInVehicle(thePlayer) then 
    local r,g,b = math.random(0,255) 
    outputChatBox(tonumber(r,g,b)) 
    end 
end 
addCommandHandler("cham", cham) 

This is my script, and i want it to output to chabox 3 colors like that "12 57 96" not just 1 color "154" as it does now. :roll:

Posted
function cham(thePlayer, cmdName) 
local Vehicle = getPedOccupiedVehicle(thePlayer) 
    if isPedInVehicle(thePlayer) then 
    local r = math.random(0,255) 
    local g = math.random(0,255) 
    local b = math.random(0,255) 
    outputChatBox(tostring(r)..","..tostring(g)..","..tostring(b)) 
    end 
end 
addCommandHandler("cham", cham) 

EDITED

I think you want to choose random color ids?

Posted

well.. i dont understand what is wrong here. debug keeps saying bad argument @ isPedInVehicle

I am trying to make a car color change script.. where color of the car changes slowly..

function cham(thePlayer) 
    if isPedInVehicle(thePlayer) then 
        local vehicle = getPedOccupiedVehicle(thePlayer) 
        if vehicle then 
            local r,g,b = math.random(255), math.random(255), math.random(255) 
            setVehicleColor(vehicle, r,g,b) 
        end 
    end 
end 
addCommandHandler("cham", cham) 
setTimer(cham, 5000, 0) 
  

Posted

if this is client-sided, then the 'thePlayer' var isn't a player, it's the command name, use

localPlayer 

instead.

Here:

function cham() 
    if isPedInVehicle(localPlayer) then 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        if vehicle then 
            local r,g,b = math.random(255), math.random(255), math.random(255) 
            setVehicleColor(vehicle, r,g,b) 
        end 
    end 
end 
addCommandHandler("cham", cham) 
setTimer(cham, 5000, 0) 

Posted

You are getting this error because of the timer, it doesn't give a player element to the function.

If you really want to do it on server-side then do it so:

function cham( thePlayer ) 
    if isPedInVehicle( thePlayer ) then 
        local vehicle = getPedOccupiedVehicle( thePlayer ) 
        if vehicle then 
            local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
            setVehicleColor(vehicle, r, g, b) 
        end 
    end 
end 
addCommandHandler("cham", cham) 
setTimer( 
    function() 
        for i, v in ipairs( getElementsByType( "player" ) ) do 
            cham( v ) 
        end 
    end, 5000, 0 ) 

Posted

Try this:

function cham( thePlayer ) 
    if isPedInVehicle( thePlayer ) then 
        local vehicle = getPedOccupiedVehicle( thePlayer ) 
        if vehicle then 
            local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
            setVehicleColor(vehicle, r, g, b) 
        end 
    end 
end 
addCommandHandler("cham", cham) 
setTimer( 
    function() 
        for i, v in ipairs( getElementsByType( "player" ) ) do 
            cham( v ) 
        end 
    end, math.random(1,5)*1000, 0 ) 

that will give a random number instead of always choosing 5secs

Posted

No, you dont get it. i want the color of the car to change slowly, just like in FFS when you buy that(i dont know what its called.)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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