}
CMD:daradmin(playerid, params[])
{
static
userid,
level;
if (PlayerData[playerid][pAdmin] < 5)
return SendErrorMessage(playerid, "Vocк nгo estб autorizado a utilizar este comando.");
if (sscanf(params, "ud", userid, level))
return SendSyntaxMessage(playerid, "/daradmin [playerid/nome] [nivel]");
if (userid == INVALID_PLAYER_ID)
return SendErrorMessage(playerid, "O jogador espeficicado й invбlido ou estб offline.");
if (level < 0 || level > 7)
return SendErrorMessage(playerid, "O nнvel de administrador deve varia entre 0 (nenhum) 7 (HoD).");
if (level > PlayerData[userid][pAdmin])
{
SendServerMessage(playerid, "Vocк promoveu %s para administrador nнvel %d.", PlayerData[userid][pNomeOOC], level);
SendServerMessage(userid, "Vocк foi promovido por %s para administrador nнvel %d.", PlayerData[playerid][pNomeOOC], level);
}
else
{
SendServerMessage(playerid, "Vocк rebaixou %s para administrador nнvel %d.", PlayerData[userid][pNomeOOC], level);
SendServerMessage(userid, "Vocк foi rebaixado por %s para administrador nнvel %d.", PlayerData[playerid][pNomeOOC], level);
}
new arquivo[128];
format(arquivo, sizeof(arquivo), "admin/%s.txt",PlayerData[userid][pUsername]);
PlayerData[userid][pAdmin] = level;
if(!DOF2_FileExists(arquivo)) //Verifica se a pasta existe
{
DOF2_CreateFile(arquivo);
DOF2_SetInt(arquivo, "level",level);
DOF2_SaveFile();
}
else
{
DOF2_SetInt(arquivo, "level",level);
DOF2_SaveFile();
}
Log_Write("logs/admin_log.txt", "[%s] %s setou para %s o nнvel de admin %d.", ReturnDate(), ReturnName(playerid, 0), ReturnName(userid, 0), level);
return 1;
[15:33:27] [debug] Server crashed while executing gm.amx [15:33:27] [debug] AMX backtrace: [15:33:27] [debug] #0 native fclose () from samp-server.exe [15:33:27] [debug] #1 0000cbac in ?? (15444932, 15183568) from gm.amx [15:33:27] [debug] #2 0015e424 in public cmd_daradmin (0, 15183552) from gm.amx [15:33:27] [debug] #3 native CallLocalFunction () from samp-server.exe [15:33:27] [debug] #4 00016c18 in public OnPlayerCommandText (0, 15183496) from gm.amx [15:33:27] [debug] Native backtrace: [15:33:27] [debug] #0 0049932b in ?? () from samp-server.exe [15:33:27] [debug] #1 004056cd in ?? () from samp-server.exe [15:33:27] [debug] #2 6f5562ca in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #3 6f558b28 in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #4 6f5509c7 in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #5 6f55631a in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #6 6e5251b9 in ?? () from plugins\streamer.dll [15:33:27] [debug] #7 0047469e in ?? () from samp-server.exe [15:33:27] [debug] #8 004010b6 in ?? () from samp-server.exe [15:33:27] [debug] #9 6f5562ca in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #10 6f558b28 in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #11 6f5509c7 in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #12 6f55631a in ?? () from plugins\crashdetect.dll [15:33:27] [debug] #13 6e5251b9 in ?? () from plugins\streamer.dll [15:33:27] [debug] #14 0046dcf0 in ?? () from samp-server.exe [15:33:27] [debug] #15 00452270 in ?? () from samp-server.exe [15:33:27] [debug] #16 0049ee89 in ?? () from samp-server.exe
new arquivo[32];
new arquivo2[32];
format(arquivo, sizeof(arquivo), "admin/%s.txt",PlayerData[playerid][pUsername]);
if(DOF2_FileExists(arquivo)) //Verifica se a pasta existe
{
PlayerData[playerid][pAdmin] = DOF2_GetInt(arquivo, "level");
}
else
{
PlayerData[playerid][pAdmin] = 0;
}
if(PlayerData[playerid][pAdmin] == 7)
{
PlayerData[playerid][pAdminHide] = 1; // Funзгo para setar quando o cara logar e passar pelo dialog de login, spawnando.
CMD:setadmin(playerid, params[])
{
// Etc. Etc. etc.
Player[userid][pAdmin] = level;
return 1;
}
// OnPlayerDisconnect
new file[155];
format(file, 155, "contas/%s.ini", teste);
DOF2::SetInt(file, "Admin", Player[playerid][pAdmin]);
DOF2::SaveFile();
|
Jб tentou deixa apenas o Player[userid][pAdmin] = level; no final ? tirando esse DOF2 do comando atй pode funciona mais vocк tem que por no OnPlayerDisconnect o if(DOF2::FileExists(file)) ser vocк tive jб nem precisava por no comando
ex: pawn Код:
|
//OnPlayerDisconnect
new arquivo[128], level;
format(arquivo, sizeof(arquivo), "admin/%s.txt", PlayerData[playerid][pUsername]);
PlayerData[playerid][pAdmin] = level;
DOF2_SetInt(arquivo, "level",level);
DOF2_SaveFile();
//Funзгo ao logar
new arquivo[32];
new arquivo2[32];
format(arquivo, sizeof(arquivo), "admin/%s.txt",PlayerData[playerid][pUsername]);
if(DOF2_FileExists(arquivo)) //Verifica se a pasta existe
{
PlayerData[playerid][pAdmin] = DOF2_GetInt(arquivo, "level");
}
else
{
PlayerData[playerid][pAdmin] = 0;
|
Funcionou parcialmente, eu vн que ao deslogar ele cria o .ini com o Nome do jogador e com a seguinte variavel: level = 0; ele simplesmente formata para 0 o level ao invйs de salvar no nнvel em que o jogador estava, poderia me ajudar a resolver?
Код:
//OnPlayerDisconnect
new arquivo[128], level;
format(arquivo, sizeof(arquivo), "admin/%s.txt", PlayerData[playerid][pUsername]);
PlayerData[playerid][pAdmin] = level;
DOF2_SetInt(arquivo, "level",level);
DOF2_SaveFile();
//Funзгo ao logar
new arquivo[32];
new arquivo2[32];
format(arquivo, sizeof(arquivo), "admin/%s.txt",PlayerData[playerid][pUsername]);
if(DOF2_FileExists(arquivo)) //Verifica se a pasta existe
{
PlayerData[playerid][pAdmin] = DOF2_GetInt(arquivo, "level");
}
else
{
PlayerData[playerid][pAdmin] = 0;
|
// Colocar no OnPlayerDisconnect sу SalvarP(playerid);
stock SalvarP(playerid)
{
new file[155];
format(file, 155, "contas/%s.ini", Name);
DOF2::SetInt(file, "Admin", Player[playerid][pAdmin]);
DOF2::SaveFile();
return 1;
}
// Sу por SetarP(playerid); no OnPlayerConnect ou na Dialog Registro
stock SetarP(playerid)
{
new file[155];
format(file, 155, "contas/%s.ini", Name);
if(DOF2::FileExists(file))
{
Player[playerid][pAdmin] = DOF2::GetInt(file, "Admin");
DOF2::SaveFile();
}
return 1;
}