28.09.2011, 20:04
Здравствуйте, вот хотел сделать так чтобы если двигатель транспорта заведен, и игрока в нем нету, чтобы бензин заканчивался, вот код:
а это то что сделал я:
но не работает, подскажите какую проверку можно поставить?
PHP код:
public CheckGas()
{
new string[256];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(i);
if(Gas[vehicle] >= 1)
{
if(Gas[vehicle] <= 10)
{
PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
if(gGas[i] == 1) {
GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel is low",5000,3);
}
}
if(gGas[i] == 1) {
if(IsAPlane(vehicle) || IsABoat(vehicle) || IsABike(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle))
{
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ N/A");
}
else
{
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %.1f",Gas[vehicle]);
}
GameTextForPlayer(i,string,20500,3); }
if(IsAPlane(vehicle) || IsABoat(vehicle) || IsABike(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle) || engineOn[vehicle] == 0) { }
else { Gas[vehicle] -= 0.1; }
}
else
{
NoFuel[i] = 1;
TogglePlayerControllable(i, 0);
GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle",1500,3);
}
}
}
}
return 1;
}
PHP код:
public CheckGas()
{
new string[256];
//for(new i=0;i<MAX_PLAYERS;i++)
for(new i=0;i<MAX_VEHICLES;i++)
{
if(IsPlayerConnected(i))
{
//if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
if(engineOn[GetPlayerVehicleID(playerid)])
{
new vehicle = GetPlayerVehicleID(i);
if(Gas[vehicle] >= 1)
{
if(Gas[vehicle] <= 10)
{
PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
if(gGas[i] == 1) {
GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel is low",5000,3);
}
}
if(gGas[i] == 1) {
if(IsAPlane(vehicle) || IsABoat(vehicle) || IsABike(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle))
{
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ N/A");
}
else
{
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %.1f",Gas[vehicle]);
}
GameTextForPlayer(i,string,20500,3); }
if(IsAPlane(vehicle) || IsABoat(vehicle) || IsABike(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle) || engineOn[vehicle] == 0) { }
else { Gas[vehicle] -= 0.1; }
}
else
{
NoFuel[i] = 1;
TogglePlayerControllable(i, 0);
GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle",1500,3);
}
}
}
}
return 1;
}