22.01.2015, 18:10
Hey.
So i was working on a car respray system. What i wanted to do is, After car enters a garage and the owner uses the command /respray, Gates of the garage gets closed, then while the gates are closed, the car gets resprayed, and after that the gates are opened again.
I wrote a script, but its not working... Gives me no errors, so i cant figure out what wrong. The gates are not closing, the color is not changed etc....
So i was working on a car respray system. What i wanted to do is, After car enters a garage and the owner uses the command /respray, Gates of the garage gets closed, then while the gates are closed, the car gets resprayed, and after that the gates are opened again.
I wrote a script, but its not working... Gives me no errors, so i cant figure out what wrong. The gates are not closing, the color is not changed etc....
PHP код:
new GTimer[MAX_PLAYERS];
new CountG = 10;
forward GaateTimer(playerid);
public GaateTimer(playerid)
{
new i = GetPVarInt(playerid, "PlayerCars");
new g = GetPVarInt(playerid, "CREVEH");
CountG--;
if(CountG == 9)
{
MoveObject(TuneGate1, 1813, -1068.8, 21.5, 1);//Gates closing
}
if(CountG == 5)
{
ChangeVehicleColor(g, CarInfo[i][cColor][0], CarInfo[i][cColor][1]);
new query[128];
format(query,sizeof(query),"UPDATE "TABLE_CARS" SET colors = '%d, %d' WHERE id = '%d'", CarInfo[i][cColor][0], CarInfo[i][cColor][1], i);
mysql_query(query);
}
if(CountG == 0)
{
MoveObject(TuneGate1, 1813, -1068.8, 24.7, 1);//Gates opening
KillTimer(GTimer[playerid]);
}
return 1;
}
CMD:respray(playerid, params[])
{
if(PlayerLogged[playerid] == 0) return 1;
new Float:x,Float:y,Float:z;
if(GetPlayerCar(playerid) == 0) return SendClientMessage(playerid, COLOR_GREY, YouDoNotHaveAnyCar);
new i = GetPVarInt(playerid, "CREVEH");
GetVehiclePos(i,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,10.0,x,y,z)) return SendClientMessage(playerid, COLOR_GREY, PlayerIsNotAtCar);
if(!IsPlayerInRangeOfPoint(playerid,10.0,1825.9583,-1082.3091,23.8466)) return SendClientMessage(playerid, COLOR_GREY, "You need to be at the respray place");
if(IsPlayerInRangeOfPoint(playerid,10.0,1825.9583,-1082.3091,23.8466)){
new color[2];
if(sscanf(params, "iI(-1)", color[0], color[1]))
{
return SendClientMessage(playerid, 0xFF0000FF, "Piemers: /Respray [color1] [color2]");
}
if(color[1] == -1) color[1] = color[0]; // If color2 was left out, set it the same as color 1
new szSuccess[44];
format(szSuccess, sizeof(szSuccess), "Your cars color was changed to: {FFFFFF}%i un %i.", color[0], color[1]);
GiveMoney(playerid, -30000);
SendClientMessage(playerid, 0x00FF00FF, szSuccess);
CarInfo[i][cColor][0]= color[0];
CarInfo[i][cColor][1]= color[1];
KillTimer(GTimer[playerid]);
GTimer[playerid] = SetTimerEx("GaateTimer", 1000, 1, "i", playerid);
}
return 1;
}