29.07.2015, 02:53
all my textdraw disappeared any how to fix this?
http://pastebin.com/3vVsAu7j
http://pastebin.com/3vVsAu7j
#include <a_samp>
#define MAX_FUEL 100 // Change this to the MAX Amount of fuel you want. (Default:100)
#define SpeedCheck(%0,%1,%2,%3,%4) floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.6)
forward SpeedTimer();
forward FuelTimer();
new PlayerText:Fuel[MAX_PLAYERS];
new PlayerText:Speed[MAX_PLAYERS];
new CarFuel[MAX_VEHICLES] = 0;
new checkgastimer;
new speedtimer;
stock GetPlayerSpeed(playerid, get3d)
{
new Float:x, Float:y, Float:z;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
}
else
{
GetPlayerVelocity(playerid, x, y, z);
}
return SpeedCheck(x, y, z, 100.0, get3d);
}
stock SetGasString(playerid, string[])
{
if(IsPlayerConnected(playerid))
{
PlayerTextDrawSetString(playerid, Fuel[playerid], string);
}
}
stock SetSpeedString(playerid, string[])
{
if(IsPlayerConnected(playerid))
{
PlayerTextDrawSetString(playerid, Speed[playerid], string);
}
}
public OnGameModeInit()
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
CarFuel[v] = MAX_FUEL; // This sets the fuel
}
checkgastimer = SetTimer("FuelTimer", 25000, 1);
speedtimer = SetTimer("SpeedTimer",1000,1);
return 1;
}
public OnGameModeExit()
{
KillTimer(checkgastimer);
KillTimer(speedtimer);
return 1;
}
public OnPlayerDeath(playerid,killerid,reason)
{
PlayerTextDrawHide(playerid,Fuel[playerid]);
return 1;
}
public OnPlayerConnect(playerid)
{
Fuel[playerid] = CreatePlayerTextDraw(playerid, 330.000000, 415.000000, " ");
PlayerTextDrawAlignment(playerid,Fuel[playerid], 2);
PlayerTextDrawBackgroundColor(playerid,Fuel[playerid], 255);
PlayerTextDrawFont(playerid,Fuel[playerid], 2);
PlayerTextDrawLetterSize(playerid,Fuel[playerid], 0.259999, 1.200000);
PlayerTextDrawColor(playerid,Fuel[playerid], -1);
PlayerTextDrawSetOutline(playerid,Fuel[playerid], 1);
PlayerTextDrawSetProportional(playerid,Fuel[playerid], 1);
PlayerTextDrawShow(playerid,Fuel[playerid]);
Speed[playerid] = CreatePlayerTextDraw(playerid,330.000000, 430.000000, " ");
PlayerTextDrawAlignment(playerid,Speed[playerid], 2);
PlayerTextDrawBackgroundColor(playerid,Speed[playerid], 255);
PlayerTextDrawFont(playerid,Speed[playerid], 2);
PlayerTextDrawLetterSize(playerid,Speed[playerid], 0.259999, 1.200000);
PlayerTextDrawColor(playerid,Speed[playerid], -1);
PlayerTextDrawSetOutline(playerid,Speed[playerid], 1);
PlayerTextDrawSetProportional(playerid,Speed[playerid], 1);
return 1;
}
public FuelTimer()
{
new string[128];
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(i);
if(CarFuel[vehicle] >= 1 && CarFuel[vehicle] <= 100)
{
format(string, sizeof(string), "Current Fuel: %d%",CarFuel[vehicle]);
SetGasString(i,string);
CarFuel[vehicle]--;
}
if(CarFuel[vehicle] == 0)
{
CarFuel[vehicle] = 0;
TogglePlayerControllable(i, 0);
SetGasString(i,"~r~[WARNING]: ~w~No fuel in vehicle!");
}
}
else
{
SetGasString(i," ");
}
}
return 1;
}
public SpeedTimer()
{
new string[128];
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
format(string, sizeof(string), "SPEED: ~g~%d MPH",GetPlayerSpeed(i,1));
SetSpeedString(i,string);
}
else
{
SetSpeedString(i," ");
}
}
return 1;
}
(106) : warning 217: loose indentation
public FuelTimer() { new string[128]; for(new i = 0; i < GetMaxPlayers(); i++) { if(GetPlayerState(i) == PLAYER_STATE_DRIVER) { new vehicle = GetPlayerVehicleID(i); if(CarFuel[vehicle] >= 1 && CarFuel[vehicle] <= 100) { format(string, sizeof(string), "Current Fuel: %d%",CarFuel[vehicle]); SetGasString(i,string); CarFuel[vehicle]--; } if(CarFuel[vehicle] == 0) { CarFuel[vehicle] = 0; TogglePlayerControllable(i, 0); SetGasString(i,"~r~[WARNING]: ~w~No fuel in vehicle!"); } } else { SetGasString(i," "); } } return 1; }
public FuelTimer()
{
new string[128];
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(i);
if(CarFuel[vehicle] >= 1 && CarFuel[vehicle] <= 100)
{
format(string, sizeof(string), "Current Fuel: %d%",CarFuel[vehicle]);
SetGasString(i,string);
CarFuel[vehicle]--;
}
if(CarFuel[vehicle] == 0)
{
CarFuel[vehicle] = 0;
TogglePlayerControllable(i, 0);
SetGasString(i,"~r~[WARNING]: ~w~No fuel in vehicle!");
}
}
else
{
SetGasString(i," ");
}
}
return 1;
}