RAINBOW CAR
Command
else if ( cmd == "rcar" )
{
if ( !player.IsSpawned ) MessagePlayer( "[#EE3B3B]You have to be spawned to use this command", player );
else if ( !player.Vehicle ) MessagePlayer( "[#FFFFFE]Error: [#EE3B3B]You must be in a vehicle to use this command", player );
else if ( !text ) MessagePlayer( "[#FFFFFE]Syntax:- /" + cmd + "[#EE3B3B] <on/off>", player );
else if ( text == "on" )
{
if ( status[player.ID].rambow==true) MessagePlayer("[#F0F0F0]Rambow Car Is Already Enabled",player);
else
{
status[player.ID].rambow=true;
MessagePlayer( "[#66CD00]You have Enabled Rambow Car", player );
}
}
else if ( text == "off" )
{
if ( status[player.ID].rambow==false) MessagePlayer("[#F0F0F0]Rambow Car Is Already Disabled",player);
else{
MessagePlayer( "[#66CD00]You have Disabled Rambow Car", player );
status[player.ID].rambow=false;
}
}
else MessagePlayer( "[#FFFFFE]Syntax:- /" + cmd + "[#EE3B3B] <on/off>", player );
}
Function
function randcarcolor()
{
for(local i = 0; i < GetMaxPlayers(); i++)
{
local player = FindPlayer( i );
if ( player )
{
if (player.Vehicle && status[player.ID].rambow==true)
{
player.Vehicle.Colour1 = (rand()%96);
player.Vehicle.Colour2 = (rand()%96);
}
}
}
}
main.nut
class PlayerStats
{
rambow = false;
}
onScriptLoad()
{
NewTimer("randcarcolor", 500,0);
}
//An Events to avoid lag
function onPlayerExitVehicle( player, vehicle )
{
if (status[player.ID].rambow==true) status[player.ID].rambow=false;
}
TESTED Edit: Array removed, Timer Fixed
good but you can also do the same without array.
player.Vehicle.Colour1 = (rand()%60);
other then that good :)
This can be implemented better but nonetheless good job.
Good Job ^^
Quote from: Sk on Mar 21, 2015, 04:02 PMgood but you can also do the same without array.
player.Vehicle.Colour1 = (rand()%60);
other then that good :)
Thanks :) i wasn't remember about that
what this function do any screen shot coz when i do in car /rcar on nothing happen just say Rambow car enable
Quote from: Finch on Mar 22, 2015, 04:16 AMwhat this function do any screen shot coz when i do in car /rcar on nothing happen just say Rambow car enable
This system will randomly change your car colour after every 500miliseconds... it will not be effected on some cars such as Sabre Turbo
it will work on stinger?
NewTimer("randcarcolor", 500,1);
To NewTimer("randcarcolor", 500,0);
Quote from: MatheuS on Mar 22, 2015, 09:17 AMNewTimer("randcarcolor", 500,1);
To NewTimer("randcarcolor", 500,0);
Yes, but why? You need to explain why you made that suggestion.
what is difference between
NewTimer( "randcarcolor", 500,0):
and
NewTimer( "randcarcolor", 500,1);
Quote from: Finch on Mar 22, 2015, 09:32 AMwhat is difference between
NewTimer( "randcarcolor", 500,0):
and
NewTimer( "randcarcolor", 500,1);
It is the repeat time 0 means infinite and thanks for point the value was wrong i'd fixed it
as explained just above, when using value 0 is repeated endlessly, using 1 it runs only one time. ;)
nice
work now fine
You could enhance this with something like what I did in one of my snippets (http://forum.vc-mp.org/?topic=60.0). The one that changes the player skin automatically after a specified period of time. You could do the same for the car color and make things more interesting.
thanks is working in my server