new
Gas[MAX_VEHICLES],
Float:velokm[3],
Retirada[500]
;
#define VALOR_LITRO 2.0
#define RETIRAR_KM 3
SetTimer("AtualizarGasosa", 1000, 1);
forward AtualizarGasosa(playerid);
public AtualizarGasosa(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new carro = GetPlayerVehicleID(playerid);
new mot, lu, alar, por, cap, porma, ob;
GetVehicleVelocity(carro, velokm[0], velokm[1], velokm[2]);
if(floatround(((floatsqroot(((velokm[0] * velokm[0]) + (velokm[1] * velokm[1]) + (velokm[2] * velokm[2]))) * (170.0))) * 1) > 5)
{
if(Gas[carro] == 0)
{
GameTextForPlayer(playerid, "Acabou a gasolina", 3000, 1);
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
return 1;
}
if(Gas[carro] >= 1)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
Retirada[playerid]+=1;
if(Retirada[playerid] >= (RETIRAR_KM*13))
{
Gas[carro]--;
Retirada[playerid]=0;
}
}
}
return 1;
}
return 1;
}
CMD:abastecer(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COR_CINZA1, " Vocк nгo esta em um carro ");
if(!NoPosto(playerid))
return SendClientMessage(playerid, COR_CINZA1, " Vocк nгo estб em um Posto ");
ShowPlayerDialog(playerid,DGas,DIALOG_STYLE_INPUT,"Colocar Gasolina","Por favor digite a quantidade de litros para colocar \no Preзo atual da Gasolina й 2$ por litro","Sim","Nao");
return 1;
}
case DGas:
{
new sGasolinaT = strval(inputtext),quantia = sGasolinaT*floatround(VALOR_LITRO);
new mot, lu, alar, por, cap, porma, ob;
if(!response)
return SendClientMessage(playerid, COR_CINZA1, "Vocк nгo colocou gasolina");
if(GetPlayerMoneyEx(playerid) < quantia)
return SendClientMessage(playerid, COR_CINZA2, "Vocк nгo tem dinheiro para isto");
if(sGasolinaT > 101 || sGasolinaT <= 0)
return SendClientMessage(playerid, COR_CINZA3, "Quantia Invбlida");
new carid = GetPlayerVehicleID(playerid);
if(Gas[carid] + sGasolinaT >= 101)
return SendClientMessage(playerid, COR_CINZA, " Vocк nгo pode passar de 100 litros de combustнvel! ");
format(String,60, " Vocк abastaceu "AMARELO"%d "BRANCO2"Litros por $%d",sGasolinaT,quantia);
SendClientMessage(playerid, -1, String);
Gas[GetPlayerVehicleID(playerid)] = Gas[carid]+sGasolinaT;
GivePlayerMoneyEx(playerid,-quantia);
Retirada[playerid] = 0;
if(motor[playerid] == 0)
{
GetVehicleParamsEx(carid, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carid, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
return 1;
}
TogglePlayerControllable(playerid, true);
return 1;
}
CMD:abastecertodos(playerid, params[])
{
if(pInfo[playerid][pAdmin] < 1337)
return SendClientMessage(playerid, COR_CINZA1, "Vocк nгo tem permissгo para usar esse comando!");
if(AdminModo[playerid] == 0)
return SendClientMessage(playerid, COR_CINZA1, "Vocк nгo pode usar esse comando enquanto estб jogando!");
for(new dj = 0; dj < MAX_VEHICLES; dj++)
{
Gas[dj] = 52;
}
format(String, 60, " O Admin %s abasteceu todos veнculos ", gNome(playerid));
MensagemProAdmin(COR_AMARELO, String);
printf(" O admin %s abasteceu todos veнculos ", pNome(playerid));
return 1;
}
CMD:motoron(playerid, params[])
{
new carro = GetPlayerVehicleID(playerid);
new mot, lu, alar, por, cap, porma, ob;
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COR_CINZA1, " Vocк nгo estб em um carro ");
if(motor[playerid] == 0)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
SendClientMessage(playerid, COR_VERDEGRANA, " Carro ligado ");
}
return 1;
}
CMD:motoroff(playerid, params[])
{
new carro = GetPlayerVehicleID(playerid);
new mot, lu, alar, por, cap, porma, ob;
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COR_CINZA1, " Vocк nгo estб em um carro ");
if(motor[playerid] == 1)
{
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
motor[playerid] = 0;
SendClientMessage(playerid, COR_VERDEGRANA, " Carro desligado ");
}
return 1;
}
CMD:zerar(playerid, params[])
{
Gas[GetPlayerVehicleID(playerid)] = 0;
return 1;
}
CMD:zerar(playerid, params[])
{
new carro = GetPlayerVehicleID(playerid);
new mot, lu, alar, por, cap, porma, ob;
Gas[carro] = 0;
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
motor[playerid] = 0;
return 1;
}
CMD:zerar(playerid, params[])
{
new carro = GetPlayerVehicleID(playerid);
new mot, lu, alar, por, cap, porma, ob;
for(new car = 0; car < MAX_VEHICLES; car++) {
Gas[car] = 0;
}
for(new id = 0; id < GetMaxPlayers(); id++) {
motor[id] = 0;
}
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_OFF, lu, alar, por, cap, porma, ob);
return 1;
}
new
Float:Cos[MAX_PLAYERS][3],
Float:Gas[MAX_VEHICLES];
UpdateGas();
public UpdateGas()
{
for(new x = 0,y = GetMaxPlayers(); x != y; x++)
{
if(!IsPlayerConnected(x)) goto NEXT;
if(IsPlayerInAnyVehicle(x))
{
new
Float:Fts[3];
GetPlayerPos(x,Fts[0],Fts[1],Fts[2]);
if((floatsqroot(floatpower(Cos[x][0] - Fts[0],2) + floatpower(Cos[x][1] - Fts[1],2) + floatpower(Cos[x][2] - Fts[2],2))) >= 5) Gas[GetPlayerVehicleID(x)] -= 0.1;
if(Gas[GetPlayerVehicleID(x)] < 1.1)
//fazaqui
Cos[x][0] = Fts[0];
Cos[x][1] = Fts[1];
Cos[x][2] = Fts[2];
}
NEXT:
}
return 1;
}
CMD:zerar(playerid, params[])
{
Gas[GetPlayerVehicleID(playerid)] = -1;
return 1;
}
CMD:motoron(playerid, params[])
{
new carro = GetPlayerVehicleID(playerid);
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COR_CINZA1, " Vocк nгo estб em um carro ");
if(Gas[carro] < 1.1)
return SendClientMessage(playerid,255,"O carro tб sem gasolina fdp!!!!!!!!!!!!!!!!!!");
if(motor[playerid] == 0)
{
new mot, lu, alar, por, cap, porma, ob;
GetVehicleParamsEx(carro, mot, lu, alar, por, cap, porma, ob);
SetVehicleParamsEx(carro, VEHICLE_PARAMS_ON, lu, alar, por, cap, porma, ob);
motor[playerid] = 1;
SendClientMessage(playerid, COR_VERDEGRANA, " Carro ligado ");
}
return 1;
}
if(!IsPlayerConnected(x)) goto NEXT; |