SA-MP Forums Archive
[FilterScript] Random Car Color By Phyzic - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Random Car Color By Phyzic (/showthread.php?tid=529277)



Random Car Color By Phyzic - Phyzic - 01.08.2014

Random Car Color By Phyzic

Hello All! This is my first ever try to make a script.. I searched out ****** and wiki, learnt some basic functions and then coded this script from starting. Its a Basic script (Not Basic for me actually..). It changes the car color automatically and randomly after every 1 second.

It have 70 colors in it.
Two Commands - /carcolor to turn it on, /carcoloroff to turn it off.

No screen because this feature just changes the car color, cheers!
Please don't be rude on it.. Thats my First Release or Script ever.

Code -

pawn Код:
#include <a_samp>
forward color(playerid);

new CarColorChanger[MAX_PLAYERS];

new CarColors[70] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70
};

public OnFilterScriptInit()
{
    print("Random Car Colors made by Phyzic Loaded");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/carcolor", cmdtext, true, 10) == 0)
    {
      if(IsPlayerInAnyVehicle(playerid))
      {
        SetTimer("color", 1000, true);
        CarColorChanger[playerid]=1;
      }
      else SendClientMessage(playerid, -1, "Error! You need to be in a vehicle to use this command");
      return 1;
    }
    if (strcmp("/carcoloroff", cmdtext, true, 10) == 0)
    {
      if(CarColorChanger[playerid] == 1)
      {
        KillTimer(playerid);
        CarColorChanger[playerid]=0;
      }
      else SendClientMessage(playerid, -1, "Error! Car Color is already off..");
      return 1;
    }
    return 0;
}


public color(playerid)
{
    new vehicle;
    vehicle = GetPlayerVehicleID(playerid);
    if(vehicle > 0)
    {
        new r = random(sizeof(CarColors));
        ChangeVehicleColor(vehicle, CarColors[r], CarColors[r]);
       
    }
}



Re: Random Car Color By Phyzic - bustern - 01.08.2014

Nice, i like the idea.Awesome for first script, keep learning +REP


Re: Random Car Color By Phyzic - SilentSoul - 01.08.2014

Nice, but too long code! random(70) should do the job instead of creating array - read about "random" function


Re: Random Car Color By Phyzic - Phyzic - 01.08.2014

Quote:
Originally Posted by bustern
Посмотреть сообщение
Nice, i like the idea.Awesome for first script, keep learning +REP
Thank you.

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
Nice, but too long code! random(70) should do the job instead of creating array - read about "random" function
Thanks and wow.. didn't knew that..
Cheers!


Re: Random Car Color By Phyzic - GeekSiMo - 01.08.2014

Nice!! Keep it up


Re: Random Car Color By Phyzic - BroZeus - 01.08.2014

from seeing i can tell dat the timer is bugged...


Re: Random Car Color By Phyzic - Team_PRO - 01.08.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
from seeing i can tell dat the timer is bugged...
Yes its bug but you can fix it by your own just like i did i will try this


Re: Random Car Color By Phyzic - Phyzic - 01.08.2014

Quote:
Originally Posted by GeekSiMo
Посмотреть сообщение
Nice!! Keep it up
Thanks!
Quote:
Originally Posted by BroZeus
Посмотреть сообщение
from seeing i can tell dat the timer is bugged...
My First script and also, thanks for telling me again.

Quote:
Originally Posted by Team_PRO
Посмотреть сообщение
Yes its bug but you can fix it by your own just like i did i will try this
Thank you for your compromise.


Re: Random Car Color By Phyzic - BroZeus - 01.08.2014

Quote:
Originally Posted by Team_PRO
Посмотреть сообщение
Yes its bug but you can fix it by your own just like i did i will try this
ofc i know how to do it.......
i was just telling him...


Re: Random Car Color By Phyzic - iFarbod - 01.08.2014

Use random(256) to get a random nice color.