Jump to content

Help


Norhy

Recommended Posts

Posted

I'm here, again :/.

So, i'm going to open a new Race server, and i wanted to created a Vehicle color changer. I will explain.. So i created a Team, everyone in the team is Admin, so the resource check if everyone is admin, then it will set the player's who's in the Team and admin a Green color (86). ON the VEHICLE.

function setAdminVehicleColor() 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
        setVehicleColor ( theVehicle, 86, 86, 86, 86 ) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),setAdminVehicleColor) 

Well, it isn't working.. Some help? :/

PS: Is there a function that will check if you are in the Team.. Not if you are a Admin?

Posted

where theVehicle come from in setVehicleColor?

try this, it give you the color (86) when you are in team called "Admin".

it's not tested.

function setAdminVehicleColor() 
    local theVehicle = getPedOccupiedVehicle(source) 
    local adminTeam = getTeamName(source) 
    if (adminTeam == "Admin") then 
        setVehicleColor (theVehicle, 86, 86, 86, 86) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),setAdminVehicleColor) 

Posted
function setAdminVehicleColor() 
    for i, car in ipairs( getElementsByType( "vehicle" ) ) do 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    local color = {} 
     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 
end 
addEventHandler("onPlayerLogin",getRootElement(),setAdminVehicleColor) 

Updated !

Posted
local uVehicles = { } 
  
function fAdminVehicleColor( ) 
    if isObjectInACLGroup( 'user.' .. getAccountName( getPlayerAccount( source ) ), aclGetGroup 'Admin' ) then 
        uVehicles[ source ] = { } 
        for _, uVehicle in ipairs( getElementsByType 'vehicle' ) do 
            uVehicles[ source ][ uVehicle ] = { } 
            uVehicles[ source ][ uVehicle ][ 1 ] = math.random( 0,255 ) 
            uVehicles[ source ][ uVehicle ][ 2 ] = math.random( 0,255 ) 
            uVehicles[ source ][ uVehicle ][ 3 ] = math.random( 0,255 ) 
            setVehicleColor ( uVehicle, uVehicles[ source ][ uVehicle ][ 1 ], uVehicles[ source ][ uVehicle ][ 2 ],  
            uVehicles[ source ][ uVehicle ][ 3 ] ) 
        end 
    end 
end 
addEventHandler( 'onPlayerLogin',root ,AdminVehicleColor ) 
  
addEventHandler( 'onPlayerQuit',root, 
    function( ) 
        uVehicles[ source ] = nil 
    end 
)    
  
  

Updated again.

Evil-Cod3r,You code wrong :lol:

Posted

setVehicleColor have 4 optional arguments.

You use 5.

Syntax in 1.1 and higher.

bool setVehicleColor ( vehicle theVehicle, int r1, int g1, int b1, [int r2, int g2, int b2,] [int r3, int g3, int b3,] [int r4, int g4, int b4] ) 

I add example on wiki.

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...