[Ajuda] Sistema de VIP
#1

Tipo esse bug sу acontece as vezes.. quando a pessoa й vip e desloga do server e conecta novamente ela perde o vip, mas isso sу acontece as vezes, e quando uma pessoa loga no server ela ganha vip automaticamente acontece as vezes tambem, sendo que nem setei vip pra ela atraves do comando /darvip


OnPlayerConnect
pawn Код:
// SISTEMA DE VIP
    new arquivei[34], nomepv[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nomepv, sizeof(nomepv));
    format(arquivei, sizeof(arquivei), "Vips/%s", nomepv);
    pVip[playerid][Vip] = DOF2_GetInt(arquivei, "Vip");
OnPlayerDisconnect
pawn Код:
// SISTEMA DE VIP
    new arquives[34], nomevip[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nomevip, sizeof(nomevip));
    format(arquives, sizeof(arquives), "Vips/%s", nomevip);

    if(DOF2_FileExists(arquives))
    {
        DOF2_SetInt(arquives, "Vip", pVip[playerid][Vip]);
        DOF2_SaveFile();
    }
    else
    {
        DOF2_CreateFile(arquives);
        DOF2_SetInt(arquives, "Vip", pVip[playerid][Vip]);
        DOF2_SaveFile();
    }
Reply
#2

pera vou colocar em stocks й ate melhor para mim
Reply
#3

Cara eu acho que funcionar assim como eu fiz, Sempre salvar as coisas certinho assim

PHP код:

stock SetarVip
(playerid)
{
    new 
file[100];
    
format(filesizeof(file), "Vips/%s.ini"Nome(playerid));
    
pVip[playerid][Vip] = DOF2::GetInt(file"Vip");
    
DOF2::SaveFile();
    return 
1;
}
stock SalvarVip(playerid)
{
    new 
file[100];
    
format(filesizeof(file), "Vips/%s.ini"Nome(playerid));
    
DOF2::CreateFile(file);
    
DOF2::SetInt(file"Vip"pVip[playerid][Vip]);
    
DOF2::SaveFile();
    return 
1;
}
stock Nome(playerid)
{
    new 
Nome[MAX_PLAYER_NAME+1];
    
GetPlayerName(playeridNomeMAX_PLAYER_NAME);
    return 
Nome;

Reply
#4

DOF2::CreateFile(file); ?
Reply
#5

PHP код:
stock GetName(playerid)
{
        static 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        return 
name;
}

stock PegarConta(playerid)
{
        static 
arquivo[30];
        
format(arquivosizeof(arquivo), "Vips/%s.sav"GetName(playerid));
        return 
arquivo;
}

stock SalvarConta(playerid)
{
        
DOF2_SetInt(PegarConta(playerid), "VIP"pVip[playerid][Vip]);
        
DOF2_SaveFile();
}

stock CarregarConta(playerid)
{
        if(
DOF2_FileExists(PegarConta(playerid)))
        {
                
pVip[playerid][Vip] = DOF2_GetInt(PegarConta(playerid), "VIP");
        }

Reply
#6

Tб mas eu tenho q colocar PegarConta(playerid); em qual public?
Reply
#7

Use CarregarConta(playerid) em OnPlayerSpawn ou OnPlayerRequestSpawn , e SalvarConta(playerid) em OnPlayerDisconnect
Reply
#8

OnPlayerConnect

PHP код:
        if(!DOF2_FileExists(PegarConta(playerid)))
        {
            
//Se o VIP Nгo Existe
        
}
        else
        {
            
//Se o VIP Existe
        

no comando VIP
PHP код:
DOF2_CreateFile(PegarConta(playerid));
DOF2_GetInt(PegarConta(playerid), "VIP"pVip[playerid][Vip]);
SalvarConta(playerid); 
Reply
#9

Entгo no caso a stock pegarvip nгo precisa ser usada pois ela estб sendo chamada pela SalvarConta e CarregarConta?
Reply
#10

Comando /darvip ficou assim, estб certo?

pawn Код:
CMD:darvip(playerid, params[])
{
    new id, vip, string[256], ganhouvip[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAD0000AA, "{FF0000}[x] Vocк nгo estб autorizado a usar este comando!");
    if(sscanf(params, "ud", id, vip)) return SendClientMessage(playerid, 0xAD0000AA, "[ > ] Uso correto: /darvip [id] 1 (1 para ativar, 0 para desativar)");
    if (vip < 1 || vip > 2) return SendClientMessage(playerid, 0xFF0000FF, "[x] Level invбlido! Use de 0 a 1");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xAD0000AA, "[x] Este jogador nгo estб online.");
    GetPlayerName(id, ganhouvip, sizeof(ganhouvip));
    format(string, sizeof(string), "[ > ] Vocк deu vip level %s para o %s", LevelVip(vip), ganhouvip);
    SendClientMessage(playerid, 0x00F6F6AA, string);
    pVip[id][Vip] =  vip;
    DOF2_CreateFile(PegarVip(playerid));
    DOF2_GetInt(PegarVip(playerid), "VIP", pVip[playerid][Vip]);
    SalvarVip(playerid);
    return 1;
}
E o tirar vip tem que colocar tambйm ne? porem tirar o createfile?


pawn Код:
CMD:tirarvip(playerid, params[])
{
    new id, string[256], string1[256], admintirou[MAX_PLAYER_NAME], ganhouvip[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "[x] Vocк nгo estб autorizado a usar este comando!");
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, YELLOW, "[ > ] Uso correto: /tirarvip [ID]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xAD0000AA, "[X] Este jogador nгo estб online!");
    GetPlayerName(id, ganhouvip, sizeof(ganhouvip));
    GetPlayerName(id, admintirou, sizeof(admintirou));
    format(string, sizeof(string), "[ > ] Vocк tirou o vip do jogador %s", ganhouvip);
    SendClientMessage(playerid, 0x00F6F6AA, string);
    format(string1, sizeof(string1), "[ > ] %s tirou o seu vip (parece que os dias acabaram, compre mais um mкs indo ao fуrum)", admintirou);
    SendClientMessage(playerid, 0x00F6F6AA, string1);
    pVip[id][Vip] =  0;
    DOF2_GetInt(PegarVip(playerid), "Vip", pVip[playerid][Vip]);
    SalvarVip(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)