[Ajuda] Salvar administrador ~
#1

Bom, eu dou admin para alguem, e ela reloga as vezes ainda estб com adm, e as vezes nгo '-' .

sabe o que pode ser ? os codes abaixo ...

pawn Код:
forward AdmsVaga();
forward LoadAdm();
forward SaveAdm();
pawn Код:
enum Admin
{
gMembro[MAX_PLAYER_NAME],AdminVaga,
};
pawn Код:
new AdmInfo[31][Admin];
pawn Код:
public AdmCheck(playerid){new idx = 0;while(idx < sizeof(AdmInfo))
{
if(strcmp(AdmInfo[idx][gMembro],PlayerName(playerid), true ) == 0 )
{
return true;
}idx++;
}
return 0;
}

public AdmsVaga()
{
new storedcopname[64];
new File: file = fopen("BrasilPL/Admins.cfg", io_read);
if (file)
{
new valtmp[MAX_PLAYER_NAME];
while (fread(file, valtmp) > 0){strmid(storedcopname, valtmp, 0, strlen("Vazio"), 255);
if ((strcmp(storedcopname, "Vazio", true, strlen("Vazio")) == 0) && (strlen("Vazio") == strlen(storedcopname)))
{
fclose(file);VagaSobrando = 1;return true;}}}fclose(file);VagaSobrando = 0;
return 0;
}

public SaveAdm()
{
new idx;new File: file2;
while (idx < sizeof(AdmInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%s,%d\n",AdmInfo[idx][gMembro],AdmInfo[idx][AdminVaga]);
if(idx == 0)
{
file2 = fopen("BrasilPL/Admins.cfg", io_write);
}
else
{
file2 = fopen("BrasilPL/Admins.cfg", io_append);
}
fwrite(file2, coordsstring);idx++;fclose(file2);
}
return true;
}

public LoadAdm()
{
new arrCoords[2][64];
new strFromFile2[256];
new File: file = fopen("BrasilPL/Admins.cfg", io_read);
if (file){new idx = 0;
while(idx < sizeof(AdmInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
strmid(AdmInfo[idx][gMembro], arrCoords[0], 0, strlen(arrCoords[0]), 255);
AdmInfo[idx][AdminVaga] = strval(arrCoords[1]);idx++;
}
}
fclose(file);
return true;
}
pawn Код:
pAdmin // <--- ja estб definido :D
pawn Код:
if(strcmp(cmd, "/daradmin", true) ==0 )
    {
        GetPlayerName(playerid, sendername, 256);
        if (strcmp(sendername,"peido_jubileu",true)==0 || strcmp(sendername,"Star_Away",true)==0)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USE: /daradmin [ id ] [Level 0 б 1341]");
                return true;
            }
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            GetPlayerName(playerid, sendername, 256);
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        PlayerInfo[para1][pAdmin] = level;
                        printf("ADMIN CMD: %s has promoted %s to a level %d admin.", sendername, giveplayer, level);
                        format(string, sizeof(string), "   Voce foi promovido para level  %d de Admin - Por %s", level, sendername);
                        SendClientMessage(para1, COLOR_LIGHTBLUE, string);
                        format(string, sizeof(string), "   Voce promoveu o(a) %s Para o level %d de Admin.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                        format(string, sizeof(string), "%s Promoveu %s a adm level %d ",sendername,giveplayer,level);
                    }
                }
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "[BML]: Voce nгo esta autorizado a usar este comando!");
            }
        }
        return true;
    }
pawn Код:
public OnPlayerConnect(playerid) // nessa callback (acho que й esse o nome) tem os seguintes codes.
PlayerInfo[playerid][pAdmin] = 0;
pawn Код:
public OnPlayerRegister(playerid, password[])
format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);

public OnPlayerLogin(playerid,password[])

if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }

//========================Ainda no On‌PlayerLogin===========================================
if (AdmCheck(playerid) == 0 && PlayerInfo[playerid][pAdmin] > 0)//teste adminfo
        {
            PlayerInfo[playerid][pAdmin] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "[BHW]: Vocк nгo й mais um Administrador.");
        }
else if(PlayerInfo[playerid][pAdmin] > 0)
        {
            format(string2, sizeof(string2), "[BHW]: Vocк Logou Como Administrador Level [%d].",PlayerInfo[playerid][pAdmin]);
            SendClientMessage(playerid, COLOR_YELLOW,string2);
        }
pawn Код:
OnPlayerUpdate(playerid)

format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
pawn Код:
forward OnPlayerSave(playerid);
public OnPlayerSave(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid])
        {
            new string3[64];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "Contas/%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                new var[32];
                format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
            }
        }
    }
    return true;
}
pawn Код:
stock ChecarAdmin(playerid)
{
    new viptipo[128];
    if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pAdmin] == 0)
    {
        format(viptipo,sizeof(viptipo),"Jogador");
    }
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        format(viptipo,sizeof(viptipo),"Administrador");
    }
    if(PlayerInfo[playerid][pHelper] >= 1)
    {
        format(viptipo,sizeof(viptipo),"Helper");
    }
    return viptipo;
}

Fico lendo esse code, varias e varias vezes, tentando entender cada palavra, eu atй entendo, mas parece tudo normal, para salvar.

nгo sei se tem ligaзгo mas o /infoadm tambйm nгo funciona.
ele fica todo estranho
vou postar ele tb
pawn Код:
if (strcmp(cmd, "/infoadm", true) == 0 || strcmp(cmd, "/infoadmin", true) == 0 || strcmp(cmd, "/infoadmins", true) == 0)
    {
        if(PlayerInfo[playerid][pAdmin] < 1)
        {
            SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo tem autorizaзгo para usar esse comando.");
            return true;
        }
        new lol = 0;
        new arquivo[128];
        SendClientMessage(playerid, COLOR_WHITE, "|______________[ Admins do Server ]______________|");
        while (lol < sizeof(AdmInfo))
        {
            if(lol == 0)
            {
                format(string, sizeof(string), "Dono: %s", AdmInfo[0][gMembro]);
                SendClientMessage(playerid, COLOR_AZULBB, string);
            }
            else
            {
                if(strcmp(AdmInfo[lol][gMembro],"Vazio",true) != 0)
                {
                    if(PlayerInfo[playerid][pAdmin] == DONO)
                    {
                        format(arquivo, sizeof(arquivo), "Contas/%s.ini",AdmInfo[lol][gMembro]);
                        format(string, sizeof(string), "Vaga %d: %s, Cargo: %d", lol, AdmInfo[lol][gMembro],dini_Int(arquivo,"AdminLevel"));
                        SendClientMessage(playerid, COLOR_AZULBB, string);
                    }
                    else
                    {
                        format(arquivo, sizeof(arquivo), "Contas/%s.ini",AdmInfo[lol][gMembro]);
                        format(string, sizeof(string), "Vaga %d: %s", lol, AdmInfo[lol][gMembro]);
                        SendClientMessage(playerid, COLOR_AZULBB, string);
                    }
                }
            }
            lol++;
        }
        return true;
    }
vou atй postar o Admins.cfg

pawn Код:
1
,0
,0
Vazio,0
peido_jubileu,0
Star_Away,0
Star_Away,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
Vazio,0
E tem uns 7 administradores.

obg, eu tentei fazer um sistema de adm ... dificil, sу quero arrumar isso ;3
nгo precisa fazer, apenas me instrua .
obg ~

cumpts,
Reply
#2

Geralmente, na pasta scriptfiles vem um arquivo .cfg pra cada conta criada. Lб deve ter adminlevel=
Procura tambйm pelo arquivo admins.cfg
Abrax!
Reply
#3

Poste o OnPlayerDiconnect, pois quando o player/admin sai do servidor, tem que salvar.
Reply
#4

verdade ... nгo tinha pensado nisso ainda e a ъnica coisa no onPlayerDisconnect sobre admin й a msg quando sai .

code abaixo
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    RemovePlayerAttachedObject(playerid,3);
    RemovePlayerAttachedObject(playerid, 3);
    DisablePlayerCheckpoint(playerid);
    TextDrawDestroy(Text:FilaAtendimentoText[playerid]);
    TextDrawDestroy(Text:TempoAtendimento2Text[playerid]);
    KillTimer(timer[playerid]);
    FilaAtendimento[playerid] = 999;
    TempoAtendimento2[playerid] = 0;
    OnPlayerSave(playerid);
    KillTimer(tempotd[playerid]);
    new caller = Mobile[playerid];
    OnPlayerSave(playerid);
    if(usandolavacarro == playerid)
    {
        SetVehicleToRespawn(GetPlayerVehicleID(playerid));
        usandolavacarro = -1;
        Update3DTextLabelText(textoentrada, COR_AZULZAO, "Ninguйm estб usando o Lava Rбpido agora, o preзo й de R$ 20,00\n(/lavarcarro)");
    }
    if(caller != 255)
    {
        if(caller < 255)
        {
            SendClientMessage(caller,  COLOR_GRAD2, "A ligaзгo caiu...");
            CellTime[caller] = 0;
            CellTime[playerid] = 0;
            Mobile[caller] = 255;
        }
        Mobile[playerid] = 255;
        CellTime[playerid] = 0;
    }
    if(HireCar[playerid] > 0)
    {
        VTrancado[HireCar[playerid]] = 0;
        UnLockCar(HireCar[playerid]);
        SetVehicleToRespawn(HireCar[playerid]);
        HireCar[playerid] = 0;
    }
    if (PlayerInfo[playerid][pBarraca] != 0)
    {
        RemoveBarraca(playerid);
    }
    if (PlayerInfo[playerid][pParedao] != 0)
    {
        RemoveParedao(playerid);
    }
    if(pRoadblock[playerid] != 0)
    {
        RemoveRoadblock(playerid);
    }
    if(SpikeInfo[playerid][sCreated] != 0)
    {
        RemoveRoadPregos(playerid);
    }
    if(pRoadCones[playerid] != 0)
    {
        RemoveRoadCones(playerid);
    }
    switch(reason)
    {
        case 0: format(gstring, sizeof(gstring), "%s saiu do Servidor por erro de conexгo ou crash.", PlayerName(playerid));
        case 1: format(gstring, sizeof(gstring), "%s saiu por vontade propria.", PlayerName(playerid));
        case 2: format(gstring, sizeof(gstring), "%s Saiu do servidor kickado ou banido.", PlayerName(playerid));
    }
    ProxDetector(100.0, playerid, gstring,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);
    gActivePlayers[playerid]--;
    numplayers--;
    if(MudarSenhaAceito[playerid] == 1)
    {
        MudarSenhaAceito[playerid] = 0;
    }
    if(MudarNickAceito[playerid] == 1)
    {
        MudarNickAceito[playerid] = 0;
    }
    if(ProvocoCasarao[playerid] == 1)
    {
        GangZoneStopFlashForAll(GZCasarao);
        GangZoneShowForAll(GZCasarao, 0xFFFFFF96);
        GuerranoCasarao = 0;
        ProvocoCasarao[playerid] = 0;
        donocasarao = 0;
        Dominando[playerid] = 0;
        KillTimer(TempoGuerraCasarao);
    }
    if(ProvocoEstacao[playerid] == 1)
    {
        GangZoneStopFlashForAll(GZEstacao);
        GangZoneShowForAll(GZEstacao, 0xFFFFFF96);
        GuerranaEstacao = 0;
        ProvocoEstacao[playerid] = 0;
        donoestacao = 0;
        Dominando[playerid] = 0;
        KillTimer(TempoGuerraEstacao);
    }
    if(ProvocoFavela[playerid] == 1)
    {
        GangZoneStopFlashForAll(GZFavela);
        GangZoneShowForAll(GZFavela, 0xFFFFFF96);
        GuerranaFavela = 0;
        ProvocoFavela[playerid] = 0;
        donoFavela = 0;
        Dominando[playerid] = 0;
        KillTimer(TempoGuerraFavela);
    }
    if(ProvocoSkate[playerid] == 1)
    {
        GangZoneStopFlashForAll(GZSkate);
        GangZoneShowForAll(GZSkate, 0xFFFFFF96);
        GuerranoSkate = 0;
        ProvocoSkate[playerid] = 0;
        donoskate = 0;
        Dominando[playerid] = 0;
        KillTimer(TempoGuerraSkate);
    }
    if(ProvocoAero[playerid] == 1)
    {
        GangZoneStopFlashForAll(GZAero);
        GangZoneShowForAll(GZAero, 0xFFFFFF96);
        GuerranoAero = 0;
        ProvocoAero[playerid] = 0;
        donoaero = 0;
        Dominando[playerid] = 0;
        KillTimer(TempoGuerraAero);
    }
    if(ProvocoPark[playerid] == 1)
    {
        GangZoneStopFlashForAll(GZPark);
        GangZoneShowForAll(GZPark, 0xFFFFFF96);
        GuerranoPark = 0;
        ProvocoPark[playerid] = 0;
        donopark = 0;
        Dominando[playerid] = 0;
        KillTimer(TempoGuerraPark);
    }

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(TaxiAccepted[i] < 999)
            {
                if(TaxiAccepted[i] == playerid)
                {
                    TaxiAccepted[i] = 999;
                    GameTextForPlayer(i, "~w~O Cliente~n~~r~Saiu do jogo", 5000, 1);
                    TaxiCallTime[i] = 0;
                    DisablePlayerCheckpoint(i);
                }
            }
            else if(CopsrondaAccepted[i] < 999)
            {
                if(CopsrondaAccepted[i] == playerid)
                {
                    CopsrondaAccepted[i] = 999;
                    GameTextForPlayer(i, "~w~Policial o player~n~~r~Deixou o jogo", 5000, 1);
                    CopsrondaCallTime[i] = 0;
                    DisablePlayerCheckpoint(i);
                }
            }
            else if(MedicAccepted[i] < 999)
            {
                if(MedicAccepted[i] == playerid)
                {
                    MedicAccepted[i] = 999;
                    GameTextForPlayer(i, "~w~O Cliente~n~~r~Saiu do jogo", 5000, 1);
                    MedicCallTime[i] = 0;
                    DisablePlayerCheckpoint(i);
                }
            }
            else if(MechanicAccepted[i] < 999)
            {
                if(MechanicAccepted[i] == playerid)
                {
                    MechanicAccepted[i] = 999;
                    GameTextForPlayer(i, "~w~O Cliente~n~~r~Saiu do jogo", 5000, 1);
                    MechanicCallTime[i] = 0;
                    DisablePlayerCheckpoint(i);
                }
            }
            else if(BusAccepted[i] < 999)
            {
                if(BusAccepted[i] == playerid)
                {
                    BusAccepted[i] = 999;
                    GameTextForPlayer(i, "~w~O Cliente~n~~r~Saiu do jogo", 5000, 1);
                    BusCallTime[i] = 0;
                    DisablePlayerCheckpoint(i);
                }
            }
        }
    }
    if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
    {
        if(IsPlayerConnected(TransportDriver[playerid]))
        {
            TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
            TransportTime[TransportDriver[playerid]] = 0;
            TransportCost[TransportDriver[playerid]] = 0;
            format(gstring, sizeof(gstring), "~w~Passageiro saiu~n~~g~ganhou R$%d",TransportCost[playerid]);
            GameTextForPlayer(TransportDriver[playerid], gstring, 5000, 1);
        }
    }
    if(GotHit[playerid] > 0)
    {
        if(GetChased[playerid] < 999)
        {
            if(IsPlayerConnected(GetChased[playerid]))
            {
                SendClientMessage(GetChased[playerid], COLOR_YELLOW, "Seu contrato saiu do servidor.");
                GoChase[GetChased[playerid]] = 999;
            }
        }
    }

    if(HireCar[playerid] != 299)
    {
        gLastDriver[HireCar[playerid]] = 300;
        VTrancado[HireCar[playerid]] = 0;
        UnLockCar(HireCar[playerid]);
    }
    if (gLastCar[playerid] > 0)
    {
        gLastDriver[gLastCar[playerid]] = 300;
        if(PlayerInfo[playerid][pPHousekey] != gLastCar[playerid]-1)
        {
            VTrancado[gLastCar[playerid]] = 0;
            UnLockCar(gLastCar[playerid]);
        }
    }
    if(PlayerBoxing[playerid] > 0)
    {
        if(Boxer1 == playerid)
        {
            if(IsPlayerConnected(Boxer2))
            {
                PlayerBoxing[Boxer2] = 0;
                SetPlayerPos(Boxer2, 765.8433,3.2924,1000.7186);
                SetPlayerInterior(Boxer2, 5);
                GameTextForPlayer(Boxer2, "~r~Luta interrompida", 5000, 1);
            }
        }
        else if(Boxer2 == playerid)
        {
            if(IsPlayerConnected(Boxer1))
            {
                PlayerBoxing[Boxer1] = 0;
                SetPlayerPos(Boxer1, 765.8433,3.2924,1000.7186);
                SetPlayerInterior(Boxer1, 5);
                GameTextForPlayer(Boxer1, "~r~Luta interrompida", 5000, 1);
            }
        }
        InRing = 0;
        RorndStarted = 0;
        Boxer1 = 255;
        Boxer2 = 255;
        TBoxer = 255;
    }
    if(TransportDuty[playerid] == 1)
    {
        TaxiDrivers -= 1;
    }
    else if(TransportDuty[playerid] == 2)
    {
        BusDrivers -= 1;
    }
    if(IsACop(playerid))
    {
        if(EmpregoDuty[playerid] == 2) { Copsronda -= 1; }
    }
    if(PlayerInfo[playerid][pMembro] == 4 || PlayerInfo[playerid][pLider] == 4)//1 daki pr baixo os 3
    {
        if(EmpregoDuty[playerid] == 2) { Medics -= 1; }
    }
    else if(IsAMec(playerid))
    {
        if(EmpregoDuty[playerid] == 2) { Mechanics -= 1; }
    }
    //CurrentMoney[playerid] = 0;
    OnPlayerSave(playerid);
    BusrouteEast[playerid][0] = 0;
    BusrouteWest[playerid][0] = 0;
    if((PlayerInfo[playerid][pAdmin] >= 1) && (PlayerInfo[playerid][pAdmin] <= MASTER_MAISMAIS))
        {
            new string[256];
            new AdminName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, AdminName, sizeof(AdminName));
            format(string, sizeof(string), "~y~%s: ~r~OFF", AdminName);

                for(new i=0; i<MAX_PLAYERS; i++)
                {
                GameTextForPlayer(i, string , 5000, 1);
                }
        }
}
Postei tudo para ver :3
Reply
#5

Jб tentou editar a pasta "contas"? Lб em "adminlevel"? Lб salva e nгo dб mais problema...
Reply
#6

Quote:
Originally Posted by TugaBR
Посмотреть сообщение
Jб tentou editar a pasta "contas"? Lб em "adminlevel"? Lб salva e nгo dб mais problema...
Sem salva vei :3
acabei de testar .
Reply
#7

Resolvido.

O problema era no OnPlayerLogin

sу desativei as seguintes linhas
pawn Код:
/*if (AdmCheck(playerid) == 0 && PlayerInfo[playerid][pAdmin] > 0)//teste adminfo
        {
            PlayerInfo[playerid][pAdmin] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "[BHW]: Vocк nгo й mais um Administrador.");
        }
era o que me dava essa dor de cabeзa (;
Reply
#8

Isso que da Usar Game Mode da Net
Reply
#9

Quote:
Originally Posted by iSmir
Посмотреть сообщение
Isso que da Usar Game Mode da Net
Nгo estou "usando gm da net"
Estou estudando amor.
bjs para seu post super ъtil.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)