[FilterScript] Sistema Vip
#1

Introduзгo:
Й 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;
} 
ScreenShot:


Crйditos:
DanDRT
Agradecimentos ao Willian_Luigi.

Observaзхes:
Serб necessбria a pasta vips na scriptfiles.
Reply
#2

Muito bom,

Parabйns.
Reply
#3

eppaaaa

Os tutoriais do ipsBruno ja estao dando resultados...

bom trabalho...

@ edit

tens 1 erro na 1Є linha logo, mas e coisa simples olha so:

pawn Код:
/* Include's */                                                                                                                        */
Reply
#4

Quote:
Originally Posted by iSmirnoff
Посмотреть сообщение
Muito bom,

Parabйns.
Obrigado :3

Quote:
Originally Posted by PT
Посмотреть сообщение
eppaaaa

Os tutoriais do ipsBruno ja estao dando resultados...

bom trabalho...

@ edit

tens 1 erro na 1Є linha logo, mas e coisa simples olha so:

pawn Код:
/* Include's */                                                                                                                        */
Obrigado, o erro eu percebi agora, corrigido!
Reply
#5

Dб pra melhorar, mas como vocк tб no inicio tб fazendo boas postagens.

Parabйns.
Reply
#6

Atualizado, obrigado Willian
Reply
#7

Oque mudou?
Reply
#8

Quote:
Originally Posted by iSmirnoff
Посмотреть сообщение
Oque mudou?
stock convertnumber... deixou o codigo mais limpo..
Reply
#9

Quote:
Originally Posted by DanDRT
Посмотреть сообщение
stock convertnumber... deixou o codigo mais limpo..
ata

+2
Reply
#10

Dan, estou impressionado com este seu cуdigo!

Reputaзгo +7.


(Nгo quer se envolver em uma das melhores equipes de programaзгo ? \/ ).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)