Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: MacTavish on Mar 21, 2015, 03:06 PM

Title: [Snippet] RainBow Car ( Random Car Colour )
Post by: MacTavish on Mar 21, 2015, 03:06 PM
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
Title: Re: [Snippet] RamBow Car ( Random Car Colour )
Post by: Sk on Mar 21, 2015, 04:02 PM
good but you can also do the same without array.
player.Vehicle.Colour1 = (rand()%60);
other then that good :)
Title: Re: [Snippet] RamBow Car ( Random Car Colour )
Post by: DizzasTeR on Mar 21, 2015, 04:10 PM
This can be implemented better but nonetheless good job.
Title: Re: [Snippet] RamBow Car ( Random Car Colour )
Post by: MatheuS on Mar 21, 2015, 04:12 PM
Good Job ^^
Title: Re: [Snippet] RamBow Car ( Random Car Colour )
Post by: MacTavish on Mar 21, 2015, 04:48 PM
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
Title: Re: [Snippet] RamBow Car ( Random Car Colour )
Post by: Finch on Mar 22, 2015, 04:16 AM
what this function do any screen shot coz when i do in car /rcar on nothing happen just say Rambow car enable
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: MacTavish on Mar 22, 2015, 06:45 AM
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
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: Finch on Mar 22, 2015, 08:41 AM
it will work on stinger?
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: MatheuS on Mar 22, 2015, 09:17 AM
NewTimer("randcarcolor", 500,1); To NewTimer("randcarcolor", 500,0);
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: . on Mar 22, 2015, 09:20 AM
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.
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: Finch on Mar 22, 2015, 09:32 AM
what is difference between
NewTimer( "randcarcolor", 500,0):
and
NewTimer( "randcarcolor", 500,1);
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: MacTavish on Mar 22, 2015, 09:46 AM
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
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: MatheuS on Mar 22, 2015, 03:57 PM
as explained just above, when using value 0 is repeated endlessly, using 1 it runs only one time. ;)
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: Finch on Mar 22, 2015, 04:04 PM
nice
work now fine
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: . on Mar 23, 2015, 10:26 AM
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.
Title: Re: [Snippet] RainBow Car ( Random Car Colour )
Post by: Tiggyh55 on Aug 14, 2018, 05:10 AM
thanks is working in my server