Norhy Posted February 29, 2012 Share Posted February 29, 2012 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? Link to comment
Evil-Cod3r Posted February 29, 2012 Share Posted February 29, 2012 debugscript 3/ errors ?? Link to comment
Sparrow Posted February 29, 2012 Share Posted February 29, 2012 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) Link to comment
Norhy Posted February 29, 2012 Author Share Posted February 29, 2012 Ha! Didn't work . NO errors. Link to comment
Evil-Cod3r Posted February 29, 2012 Share Posted February 29, 2012 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 ! Link to comment
Kenix Posted February 29, 2012 Share Posted February 29, 2012 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 Link to comment
Evil-Cod3r Posted February 29, 2012 Share Posted February 29, 2012 Why my code is worng explane it for me please Link to comment
Kenix Posted February 29, 2012 Share Posted February 29, 2012 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. 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