How to make an Rainbow System?
#1

I want an system like if we write /rainbow the car will flash like rainbow Means it will change colour again and again after 3 seconds This will make a cooller look to the car...

Anybody know how to make this system?
Reply
#2

https://sampwiki.blast.hk/wiki/Function:ChangeVehicleColor
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

pawn Код:
new On[MAX_VEHICLES]; // this is for checking if the vehicle is flashing
pawn Код:
public OnGameModeInit()
{
  SetTimer("Rainbow", 3000, true);
  return 1;
}
pawn Код:
forward Rainbow();
public Rainbow()
{
  for(new i = 0; i < MAX_VEHICLES; i ++)
  {
    if(On[i] == 1) ChangeVehicleColor(i, random(127), random(127));
  }
  return 1;
}
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/rainbow", true) == 0)
  {
    new
      vehid = GetPlayerVehicleID(playerid);

    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR, "You must be in a vehicle to use this command!");
    else if(On[vehid] == 1)
    {
      SendClientMessage(playerid, COLOR, "Rainbow mod disabled!");
      On[vehid] = 0;
    }
    else
    {
      SendClientMessage(playerid, COLOR, "Rainbow mod enabled!");
      On[vehid] = 1;
    }
    return 1;
  }
  return 0;
}
This is one of the many ways you could do this...
Reply
#4

Yep, that should work.
I was about to write one but you beat me too it.

However, why are you limiting the colours to only 127.
random(127)
There are a lot of other bright colours beyond 127, maybe stop it at 186.

[img width=341 height=768]http://i544.photobucket.com/albums/hh326/mansonh/carcolours.png[/img]
Reply
#5

I don't know, I just got them quickly from here, and I read that if you use an invalid color ID it will change after leaving an interior or something... he could change that anyway.
Reply
#6

Yah I have heard of that before, never seen it though, but if you look on that page below it identifies other colours.

I tested the range and it seems that colour goes from 0-255 then wraps around, so 256=0(binary wrap) ...

and if the colours always changing anyways

/shrug
Reply
#7

Thanks guys...
Reply
#8

And how do i make this when an player leaves his vehicle the rainbow mod stop
Reply
#9

Код:
public OnPlayerDisconnect(playerid)
{
 On[GetPlayerVehicleID(playerid)]=0;
}
Reply
#10

I am learning pawno
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)