01.08.2014, 13:00
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 -
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]);
}
}