23.01.2018, 21:45
Quote:
Criei sim, Mais quando eu saio e entro dnv Seta na pasta 0, Pq isso mano? Rs.
|
PHP код:
#include <a_samp>
#include <DOF2>
#include <sscanf>
#include <streamer>
#include <zcmd>
enum PlayerGasolina
{
Gasolina,
Timer
}
new pGasolina[MAX_PLAYERS][PlayerGasolina];
new MostrarLitros[256];
public OnFilterScriptExit()
{
DOF2_Exit();
return 1;
}
public OnPlayerConnect(playerid)
{
if(!DOF2_FileExists(GasolinaPlayer(playerid)))
{
SendClientMessage(playerid, -1, "| INFO | Vocк acabou de ser registrado.");
DOF2_CreateFile(GasolinaPlayer(playerid));
DOF2_SetInt(GasolinaPlayer(playerid), "Gasolina", 100);
DOF2_SaveFile();
pGasolina[playerid][Gasolina] = 100;
}
else if(DOF2_FileExists(GasolinaPlayer(playerid)))
{
pGasolina[playerid][Gasolina] = DOF2_GetInt(GasolinaPlayer(playerid), "Gasolina");
format(MostrarLitros, sizeof(MostrarLitros), "| INFO | Vocк tem %d de Litros de Gasolina.", pGasolina[playerid][Gasolina]);
SendClientMessage(playerid, -1, MostrarLitros);
return 1;
}
return 1;
}
forward DiminuirGasolina(playerid);
public DiminuirGasolina(playerid)
{
pGasolina[playerid][Gasolina] --;
SalvarGasolina(playerid);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
pGasolina[playerid][Timer] = SetTimerEx("DiminuirGasolina", 1000, true, "d", playerid);
SendClientMessage(playerid, -1, "| INFO | Contar Gasolina On!");
return 1;
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
if(newstate == PLAYER_STATE_ONFOOT)
{
KillTimer(pGasolina[playerid][Timer]);
SendClientMessage(playerid, -1, "| INFO | Parou de diminuir a gasolina.");
}
return 1;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SalvarGasolina(playerid);
return 1;
}
SalvarGasolina(playerid)
{
if(DOF2_FileExists(GasolinaPlayer(playerid)))
{
DOF2_SetInt(GasolinaPlayer(playerid), "Gasolina", pGasolina[playerid][Gasolina]);
DOF2_SaveFile();
}
return 1;
}
GasolinaPlayer(playerid)
{
new gasolina[44], nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, 44);
format(gasolina, 44, "Gasolina/%s.ini", nome);
return gasolina;
}
CMD:litros(playerid)
{
new litros[256];
format(litros, sizeof(litros), "| INFO | Vocк tem %d de litros de gasolina.", pGasolina[playerid][Gasolina]);
SendClientMessage(playerid, -1, litros);
return 1;
}
CMD:abastecer(playerid, params[])
{
new gasolina, stg[256];
if(sscanf(params, "d", gasolina)) return SendClientMessage(playerid, -1, "/Abastecer [litros]");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "| ERRO | Vocк nгo estб em um veнculo");
pGasolina[playerid][Gasolina] += gasolina;
format(stg, sizeof(stg), "| INFO | Vocк abasteceu %d litros! Total agora: %d", gasolina, pGasolina[playerid][Gasolina]);
SendClientMessage(playerid, -1, stg);
return 1;
}