[FilterScript] Random Car Color By Phyzic
#1

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]);
       
    }
}
Reply
#2

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

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

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!
Reply
#5

Nice!! Keep it up
Reply
#6

from seeing i can tell dat the timer is bugged...
Reply
#7

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
Reply
#8

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.
Reply
#9

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...
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)