02.10.2013, 15:14
(
Последний раз редактировалось DanDRT; 02.10.2013 в 19:31.
)
Introduзгo:
Й um sistema vip simples que eu fiz para testar a funзгo #emit e resolvi postar aqui.
ScreenShot:
Crйditos:
DanDRT
Agradecimentos ao Willian_Luigi.
Observaзхes:
Serб necessбria a pasta vips na scriptfiles.
Й um sistema vip simples que eu fiz para testar a funзгo #emit e resolvi postar aqui.
PHP код:
/* Include's */
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <DOF2>
/* New's */
new PlayerVip[MAX_PLAYERS];
/* Public's */
main(){}
public OnFilterScriptInit() return 1;
public OnFilterScriptExit() { DOF2_Exit(); return 1; }
public OnPlayerConnect(playerid)
{
new string[80];
format(string, sizeof(string), "/vips/%s.ini", GetName(playerid));
if(DOF2_FileExists(string))
{
PlayerVip[playerid] = DOF2_GetInt(string,"VipExpira");
if(gettime() > PlayerVip[playerid])
{
DOF2_RemoveFile(string);
PlayerVip[playerid] = 0;
SendClientMessage(playerid, 0xF6FF00AA, "* Seu vip expirou!");
}
else
{
format(string, sizeof(string), "* Seu vip expira em %s.", convertNumber(PlayerVip[playerid]-gettime()));
SendClientMessage(playerid, 0xF6FF00AA, string);
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if(PlayerVip[playerid] > 0)
{
if(gettime() > PlayerVip[playerid])
{
new string[40];
format(string, sizeof(string), "/vips/%s.ini", GetName(playerid));
DOF2_RemoveFile(string);
PlayerVip[playerid] = 0;
SendClientMessage(playerid, 0xF6FF00AA, "* Seu vip expirou!");
}
else
{
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
}
}
return 1;
}
/* Stock's */
stock ConvertDays(dias)
{
new
valueday = 86400*dias,
daysconvert,
gtime = gettime()
;
#emit LOAD.S.PRI gtime
#emit LOAD.S.ALT valueday
#emit ADD
#emit STOR.S.PRI daysconvert
return daysconvert;
}
stock convertNumber(n)
{
new dia, hr, mn, seg, resto;
resto = n;
seg = resto % 60;
resto /= 60;
mn = resto % 60;
resto /= 60;
hr = resto % 24;
resto /= 24;
dia = resto;
new str[50];
format(str, sizeof(str), "%ddias, %02dh %02dm %02ds", dia, hr, mn, seg);
return str;
}
stock GetName(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
/* Command's */
CMD:vips(playerid)
{
new string[85];
new count;
SendClientMessage(playerid, 0x33AAFFFF, "** Todos os jogadores VIP online:");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerVip[i] > 0)
{
if(IsPlayerConnected(i))
{
format(string, sizeof(string), "Vip %s (%d) [%s]", GetName(i), i, convertNumber(PlayerVip[i]-gettime()));
SendClientMessage(playerid, 0xE3E3E3FF, string);
count++;
}
}
}
if(count == 0)
return SendClientMessage(playerid, 0xD8D8D8FF, "Nгo tem nenhum jogador vip on-line!");
return true;
}
CMD:setvip(playerid, params[])
{
new id, days, string[70];
if(!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, 0xFF0000AA, "ERRO: Vocк precisa estar logado na RCON para usar este comando!");
if(sscanf(params, "ud", id, days))
return SendClientMessage(playerid, -1, "Modo de uso: /setvip [id] [dias]");
if(days < 0)
{
return SendClientMessage(playerid, 0xFF0000AA, "ERRO: Este jogador nгo estб online!");
}
else
{
if(!IsPlayerConnected(id))
return SendClientMessage(playerid, 0xFF0000AA, "ERRO: Este jogador nгo estб online!");
else
{
PlayerVip[id] = ConvertDays(days);
format(string, sizeof(string), "** Vocк deu %d dias de VIP para %s.", days, GetName(id));
SendClientMessage(playerid, 0x33AAFFFF, string);
format(string, sizeof(string), "** Vocк recebeu %d dias de VIP.", days);
SendClientMessage(playerid, 0x33AAFFFF, string);
format(string, sizeof(string), "/vips/%s.ini", GetName(id));
DOF2_CreateFile(string);
DOF2_SetInt(string,"VipExpira", PlayerVip[id]);
DOF2_SaveFile();
}
}
return true;
}
Crйditos:
DanDRT
Agradecimentos ao Willian_Luigi.
Observaзхes:
Serб necessбria a pasta vips na scriptfiles.