Quando seto o vip, fica Dias = 1 '-'
PHP Code:
#include a_samp
#include DOF2
#include sscanf2
#include zcmd
public OnFilterScriptExit()
{
DOF2_Exit();
return 1;
}
enum PlayerInfo
{
Vip,
Dias
}
new pInfo[MAX_PLAYERS][PlayerInfo];
public OnPlayerSpawn(playerid)
{
if(gettime() >= pInfo[playerid][Dias])
{
pInfo[playerid][Vip] = 0;
pInfo[playerid][Dias] = 0;
}
return 1;
}
public OnPlayerConnect(playerid)
{
if(!DOF2_FileExists(Contas(playerid)))
{
DOF2_CreateFile(Contas(playerid));
DOF2_SaveFile();
return 1;
}
CarregarConta(playerid);
return 1;
}
CMD:setarvip(playerid, params[])
{
new id, dias, str[128];
if(sscanf(params, "ui", id, dias)) return SendClientMessage(playerid, -1, "| ERRO | Digite: /SetarVIP [ Id ] [ Dias ]");
format(str, 128, "| VIP | Você ganhou vip do Admin %s", PlayerName(playerid));
SendClientMessage(id, -1, str);
pInfo[id][Vip] = 1;
pInfo[id][Dias] = DOF2_SetInt(Contas(id), "Dias", (gettime() + (dias *86400)));
return 1;
}
static PlayerName(playerid)
{
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, 44);
return Nome;
}
static Contas(playerid)
{
new file[44], nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, 44);
format(file, 44, "/Contas/%s.ini", nome);
return file;
}
public OnPlayerUpdate(playerid)
{
SetTimer("AtualizarConta", 100, true);
return 1;
}
forward AtualizarConta(playerid);
public AtualizarConta(playerid)
{
DOF2_SetInt(Contas(playerid), "Vip", pInfo[playerid][Vip]);
DOF2_SetInt(Contas(playerid), "Dias", pInfo[playerid][Dias]);
DOF2_SaveFile();
return 1;
}
forward CarregarConta(playerid);
public CarregarConta(playerid)
{
pInfo[playerid][Vip] = DOF2_GetInt(Contas(playerid), "Vip");
pInfo[playerid][Dias] = DOF2_GetInt(Contas(playerid), "Dias");
return 1;
}