enum SavePlayerPosEnum
{
Float:LastX,
Float:LastY,
Float:LastZ
}
new CheckGasTimer,
StoppedVehicleTimer,
BenzinUpdateTimer,
Gas[CAR_AMOUNT],
SavePlayerPos[50][SavePlayerPosEnum],
asp = 0,
PlayerInfo[MAX_PLAYERS][pInfo],
ServerInfo[1][sInfo],
file[128],
wep_init = 0,
gWeapons[MAX_WEAPONS][64],
gPlayers[MAX_PLAYERS][MAX_PLAYER_NAME+1];
forward BenzinUpdate();
forward Fillup();
forward StoppedVehicle();
forward CheckGas();
public BenzinUpdate()
{
for(new i=0;i<=MAX_PLAYERS;i++){
if(IsPlayerConnected(i)){
if(GetPlayerState(i)==PLAYER_STATE_DRIVER){
new vehicle=GetPlayerVehicleID(i);
if(GetPlayerState(i)==PLAYER_STATE_DRIVER){
if(Gas[vehicle]>=0&&Gas[vehicle]<=0)RemovePlayerFromVehicle(i);
if(PlayerInfo[Spawned]==0)GameTextForPlayerBottom(i,"\x10");
new string[256];if(Gas[vehicle]<6)format(string,sizeof(string),"~r~%d%",Gas[vehicle]);
if(Gas[vehicle]>=6)format(string,sizeof(string),"%d%",Gas[vehicle]);
GameTextForPlayerBottom(i,string);
}
}
else if(PlayerInfo[Spawned]==1)GameTextForPlayerBottom(i,"\x10");
}
}
return 1;
}
public CheckGas()
{
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)Gas[vehicle]--;
}
}
}
return 1;
}
public StoppedVehicle()
{
new Float:x,Float:y,Float:z;
for(new i=0;i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i)){
if(GetPlayerState(i)==PLAYER_STATE_DRIVER){
GetPlayerPos(i,x,y,z);
new Float:distance,value;
distance=floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[LastZ])),2));
value=floatround(distance*3600);
new VID=GetPlayerVehicleID(i);
if(value==0)Gas[VID]++;
SavePlayerPos[LastX]=x;
SavePlayerPos[LastY]=y;
SavePlayerPos[LastZ]=z;
}
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
BenzinUpdateTimer=SetTimer("BenzinUpdate",1000,1);
StoppedVehicleTimer=SetTimer("StoppedVehicle",120000,1);
CheckGasTimer=SetTimer("CheckGas",120000,1);
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(CheckGasTimer);
KillTimer(StoppedVehicleTimer);
KillTimer(BenzinUpdateTimer);
}
public OnGameModeInit()
{
for(new c=0;c<CAR_AMOUNT;c++) Gas[c] = GasMax; }