15.11.2009, 15:32
Well after using SetTimerEx, parameters are set to 0.. Why?
Here is my code:
Here is my code:
pawn Код:
if(!strcmp(cmdtext, "/fill", true))
{
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, RED, "Vous n'кtes conducteur d'aucun vйhicule.");
return 1;
}
new fuelstation = GetPlayerFuelStation(playerid);
if(fuelstation == 0)
{
SendClientMessage(playerid, RED, "Vous n'кtes pas prиs d'une station essence en service.");
return 1;
}
new car = GetPlayerVehicleID(playerid);
new price = 100 - floatround(CarInfo[car][cFuel]);
if(GetPlayerMoney(playerid) < price)
{
SendClientMessage(playerid, RED, "Vous n'avez pas les moyens de faire le plein.");
return 1;
}
GameTextForPlayer(playerid, "~w~Plein en cours...", 5000, 3);
printf("DEBUG: playerid: %d, car: %d, price: %d", playerid, car, price); //Here everything is alright
SetTimerEx("FillCar",5000, false, "i", playerid, "i", car, "i", price);
return 1;
}
forward FillCar(playerid, car, price);
public FillCar(playerid, car, price)
{
if(!GetPlayerFuelStation(playerid)) return 1;
GameTextForPlayer(playerid, "~g~Plein effectue", 3000, 3);
SafeGivePlayerMoney(playerid, -price);
CarInfo[car][cFuel] = 100;
new string[36];
format(string, sizeof(string), "Vous avez fait le plein pour $%d.", price);
SendClientMessage(playerid, YELLOW2, string);
format(string, 36, "FillCar(%d, %d, %d)", playerid, car, price);
print(string); // but here car and price are equal to 0
return 1;
}