[Snippet] RainBow Car ( Random Car Colour )

Started by MacTavish, Mar 21, 2015, 03:06 PM

Previous topic - Next topic

MacTavish

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

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Sk

good but you can also do the same without array.
player.Vehicle.Colour1 = (rand()%60);
other then that good :)

DizzasTeR

This can be implemented better but nonetheless good job.

MatheuS

if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

MacTavish

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

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Finch

what this function do any screen shot coz when i do in car /rcar on nothing happen just say Rambow car enable
Beztone is a scripter but he is too stupid

MacTavish

#6
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

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Finch

Beztone is a scripter but he is too stupid

MatheuS

NewTimer("randcarcolor", 500,1); To NewTimer("randcarcolor", 500,0);
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

.

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

Finch

what is difference between
NewTimer( "randcarcolor", 500,0):
and
NewTimer( "randcarcolor", 500,1);
Beztone is a scripter but he is too stupid

MacTavish

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

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

MatheuS

as explained just above, when using value 0 is repeated endlessly, using 1 it runs only one time. ;)
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Finch

Beztone is a scripter but he is too stupid

.

You could enhance this with something like what I did in one of my snippets. 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.
.