Nгo seja ignorante otimizaзгo sempre й bom desde que entendam, estamos aqui para somar e nгo para julgar belo FS parabйns !
PHP Code:
#include < a_samp >
#include < Pawn.CMD >
#include < a_zones >
#define Combustivel_Max (100)
new TimerComb, Timer_Veloo, Velooc[MAX_PLAYERS], SemComb[MAX_PLAYERS], Abastecendo[MAX_PLAYERS], Gas[MAX_VEHICLES], PlayerText:Velocimetro[4];
new Float:Postos[][] = {
{1004.0070,-939.3102,42.1797},
{1944.3260,-1772.9254,13.3906},
{1400.6882,-1680.5344,42.4339},
{1496.5316,-1544.0677,23.5481},
{2737.3364,-1774.2123,43.7973},
{-90.5515,-1169.4578,2.4079},
{-1609.7958,-2718.2048,48.5391},
{-2029.4968,156.4366,28.9498},
{-2408.7590,976.0934,45.4175},
{1380.4712,462.7467,20.1107},
{1385.0475,460.5417,20.1068},
{1383.5532,457.1286,19.9561},
{1379.1952,459.1295,19.9587},
{-2243.9629,-2560.6477,31.8841},
{-1676.6323,414.0262,6.9484},
{2202.2349,2474.3494,10.5258},
{614.9333,1689.7418,6.6968},
{-1328.8250,2677.2173,49.7665},
{70.3882,1218.6783,18.5165},
{677.1299,-2866.3892,13.0944},
{-1327.7218,2678.8723,50.0625}
};
public OnFilterScriptInit() {
for(new c = 0; c < MAX_VEHICLES; c++) Gas[c] = Combustivel_Max;
TimerComb = SetTimer("CheckGas", 20000, 1);
return 1;
}
public OnFilterScriptExit() {
KillTimer(TimerComb);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate) {
if(newstate == PLAYER_STATE_DRIVER) Timer_Veloo = SetTimerEx("Atualizar_Velocimetro", 300, 1, "i", playerid);
else if(oldstate == PLAYER_STATE_DRIVER) {
if(Velooc[playerid] == 1) {
for(new i = 0; i < sizeof(Velocimetro); ++i) PlayerTextDrawHide(playerid, Velocimetro[i]);
Velooc[playerid] = 0;
KillTimer(Timer_Veloo);
}
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason) {
if(Velooc[playerid] == 1) {
for(new i = 0; i < sizeof(Velocimetro); ++i) PlayerTextDrawHide(playerid, Velocimetro[i]); PlayerTextDrawDestroy(playerid, Velocimetro[i])
Velooc[playerid] = 0;
KillTimer(Timer_Veloo);
}
return 1;
}
public OnPlayerConnect(playerid) {
Velooc[playerid] = 0;
SemComb[playerid] = 0;
Abastecendo[playerid] = 0;
Criar_TD_Velocimetro(playerid);
return 1;
}
Criar_TD_Velocimetro(playerid) {
Velocimetro[0] = CreatePlayerTextDraw(playerid, 641.555541, 433.571105, "usebox");
PlayerTextDrawLetterSize(playerid, Velocimetro[0], 0.000000, 1.397902);
PlayerTextDrawTextSize(playerid, Velocimetro[0], -2.000000, 0.000000);
PlayerTextDrawAlignment(playerid, Velocimetro[0], 1);
PlayerTextDrawColor(playerid, Velocimetro[0], 0);
PlayerTextDrawUseBox(playerid, Velocimetro[0], 1);
PlayerTextDrawBoxColor(playerid, Velocimetro[0], 102);
PlayerTextDrawSetShadow(playerid, Velocimetro[0], 0);
PlayerTextDrawSetOutline(playerid, Velocimetro[0], 0);
PlayerTextDrawFont(playerid, Velocimetro[0], 0);
Velocimetro[1] = CreatePlayerTextDraw(playerid, 3.111108, 431.573333, " ");//Localizacao
PlayerTextDrawLetterSize(playerid, Velocimetro[1], 0.312222, 1.739378);
PlayerTextDrawAlignment(playerid, Velocimetro[1], 1);
PlayerTextDrawColor(playerid, Velocimetro[1], 0xFF4D00FF);
PlayerTextDrawSetShadow(playerid, Velocimetro[1], 0);
PlayerTextDrawSetOutline(playerid, Velocimetro[1], 1);
PlayerTextDrawBackgroundColor(playerid, Velocimetro[1], 51);
PlayerTextDrawFont(playerid, Velocimetro[1], 1);
PlayerTextDrawSetProportional(playerid, Velocimetro[1], 1);
Velocimetro[2] = CreatePlayerTextDraw(playerid,296.888824, 432.568878, " ");//KM/H
PlayerTextDrawLetterSize(playerid, Velocimetro[2], 0.314888, 1.659733);
PlayerTextDrawAlignment(playerid, Velocimetro[2], 1);
PlayerTextDrawColor(playerid, Velocimetro[2], 0x0080FFFF);
PlayerTextDrawSetShadow(playerid, Velocimetro[2], 0);
PlayerTextDrawSetOutline(playerid, Velocimetro[2], 1);
PlayerTextDrawBackgroundColor(playerid, Velocimetro[2], 51);
PlayerTextDrawFont(playerid, Velocimetro[2], 1);
PlayerTextDrawSetProportional(playerid, Velocimetro[2], 1);
Velocimetro[3] = CreatePlayerTextDraw(playerid,526.667053, 432.568908, " ");//Combustivel
PlayerTextDrawLetterSize(playerid, Velocimetro[3], 0.372666, 1.560178);
PlayerTextDrawAlignment(playerid, Velocimetro[3], 1);
PlayerTextDrawColor(playerid, Velocimetro[3], 0x8000FFFF);
PlayerTextDrawSetShadow(playerid, Velocimetro[3], 0);
PlayerTextDrawSetOutline(playerid, Velocimetro[3], 1);
PlayerTextDrawBackgroundColor(playerid, Velocimetro[3], 51);
PlayerTextDrawFont(playerid, Velocimetro[3], 1);
PlayerTextDrawSetProportional(playerid, Velocimetro[3], 1);
}
ReturnPlayerZone(playerid) {
new location[MAX_ZONE_NAME];
GetPlayer2DZone(playerid, location, MAX_ZONE_NAME);
return location;
}
NoPosto(playerid) {
for(new i = 0; i < sizeof (Postos); ++ i) {
if(IsPlayerInRangeOfPoint(playerid, 7.0, Postos[i][0], Postos[i][1], Postos[i][2]))
return 1;
}
return 0;
}
GetPlayerSpeed(playerid) {
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
return floatround(ST[3]);
}
forward Atualizar_Velocimetro(playerid);
public Atualizar_Velocimetro(playerid) {
if(Velooc[playerid] == 0)
{
for(new i = 0; i < sizeof(Velocimetro); ++i) PlayerTextDrawShow(playerid, Velocimetro[i]);
Velooc[playerid] = 1;
}
new str[256];
format(str, sizeof(str), "Localizacao: ~w~%s", ReturnPlayerZone(playerid));
PlayerTextDrawSetString(playerid, Velocimetro[1], str);
format(str, sizeof(str), "KM/H: ~w~%i", GetPlayerSpeed(playerid));
PlayerTextDrawSetString(playerid, Velocimetro[2], str);
format(str, sizeof(str), "Combustivel: ~w~%d", Gas[GetPlayerVehicleID(playerid)]);
PlayerTextDrawSetString(playerid, Velocimetro[3], str);
}
forward Abastecimento();
public Abastecimento()
{
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
new string[256], Abbs = Combustivel_Max - Gas[VID];
Abbs *= 4;
if(Abastecendo[i] == 1) {
if(GetPlayerMoney(i) >= Abbs + 4) {
Gas[GetPlayerVehicleID(i)] = 100;
GivePlayerMoney(i, - Abbs);
Abastecendo[i] = 0;
}
TogglePlayerControllable(i, 1);
format(string,sizeof(string), GetPlayerMoney(i) >= Abbs + 4 ? " Vocк reabasteceu seu veнculo, por: R$%d." : " Voce nao tem dinheiro suficiente para encher o tanque, custo: $%d." ,Abbs);
SendClientMessage(i, -1, string);
}
}
}
}
forward CheckGas();
public CheckGas()
{
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(GetPlayerState(i) == PLAYER_STATE_DRIVER) {
new vehicle = GetPlayerVehicleID(i), VehicleModel = GetVehicleModel(vehicle);
if(VehicleModel == 509 || VehicleModel == 481 || VehicleModel == 510) return 1;
if(Gas[vehicle] >= 1) {
if(Gas[vehicle] <= 10){}
Gas[vehicle]--;
} else {
SemComb[i] = 1;
TogglePlayerControllable(i, 0);
SendClientMessage(i,-1,"Sem combustivel Use /sair Para sair do veiculo");
SendClientMessage(i,-1, "O motor do veнculo apagou por falta de combustнvel");
}
}
}
}
return 1;
}
CMD:abastecer(playerid) {
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Vocк nгo estб em um veнculo!");
if(Gas[GetPlayerVehicleID(playerid)] >= 100) return SendClientMessage(playerid,-1,"Tanque jб estб cheio.");
if(!NoPosto(playerid)) return SendClientMessage(playerid,-1,"Vocк nгo estб em um posto");
GameTextForPlayer(playerid,"Abastecendo...",5000,3);
SetTimerEx("Abastecimento",5000,0, "i", playerid);
TogglePlayerControllable(playerid, 0);
Abastecendo[playerid] = 1;
return 1;
}
CMD:sair(playerid) {
TogglePlayerControllable(playerid, 1);
RemovePlayerFromVehicle(playerid);
return 1;
}