Jump to content

Script for group


Albinix

Recommended Posts

Posted

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.

Posted

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.

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

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

Posted (edited)
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
Posted
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 ?

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

Posted
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

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

  • 1 month later...
Posted

can u make like if you have two teams like red and green, if you are in red your car is red ans if you is in green your car is green?

Posted

Yes, you can. You just check what team the player is in when he enters the vehicle and change the colour to whatever team colour is.

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