Jump to content

Script for group


Albinix

Recommended Posts

Hello i wonder how to make this script work for only admins?

And how to add Headlightcolor to this script?

function randomVehColors()
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
 
setTimer( randomVehColors, 500, 0 )	-- timer changes all vehicles colors to random every 0.5 sec.

Link to comment

First of all, you didn't need to create these extra variables. You can just simplify things by doing

function randomVehColors()
for i, car in ipairs( getElementsByType( "vehicle" ) ) do
	setVehicleColor ( car, math.random(0,126), math.random(0,126), math.random(0,126), math.random(0,126) ) -- setting color to vehicle
end
end
 
setTimer( randomVehColors, 500, 0 )	-- timer changes all vehicles colors to random every 0.5 sec.

I hope this is a client-side script. :| It should be straight forward on how to create headlight colors. Only headlights only take 3 params, and they range from 0-255, RGB.

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

The MTA wiki pwns.

Link to comment
how to make it work for only one group? example admin

I don't know what you mean by that question.. The script changes headlight colours randomly.

like when a admin login it changes his car color to black for example, but when someone else login it dosen't changes his car to black.

Link to comment
how to make it work for only one group? example admin

I don't know what you mean by that question.. The script changes headlight colours randomly.

like when a admin login it changes his car color to black for example, but when someone else login it dosen't changes his car to black.

eh, something like

addEventHandler( 'onPlayerLogin', root,
function()
local veh = getPedOccupiedVehicle( source );
if veh and isObjectInACLGroup( 'user.'..getPlayerName( source ), aclGetGroup( 'Admin' ) ) then
setVehicleColor( veh, 0, 0, 0, 0 ); --color it with black
end;
end
);

Edited by Guest
Link to comment
Dosen't work, when i login nothing happends

Hmm, you must be in a car while login. Or you wanna change color of all existing vehicles on the server ?

No when i login as admin i want my car black. And it's on a racemod server so i always in a car.

Link to comment
No when i login as admin i want my car black. And it's on a racemod server so i always in a car.

the best thing is that after you hit the car change pickup it will change your color to random anyway :P

There is an event (onPlayerPickUpRacePickup) to prevent it from happening.

Link to comment
  • 1 month later...

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