03.09.2011, 22:01
Este й o meu sistema de salvamento, o ъnico problema й que nao salva o nivel de Admin quando desligo e volto a ligar o servidor. alguma ajuda ?
dou +rep.
Aqui estб o enum do Player.
public OnPlayerDisconnect(playerid)
public onplayerconnect(playerid)
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
public LoadUser_data(playerid,name[],value[])
COMMAND:makeadmin(playerid, params[])
dou +rep.
Aqui estб o enum do Player.
pawn Код:
enum pInfo
{
Password,
Cash,
Kills,
Deaths,
Adminlevel
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
{
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
case 0: format(string, sizeof(string), " %s abandonou o servidor. (perda de sinal)", pname);
case 1: format(string, sizeof(string), " %s abandonou o servidorr. (saiu por vontade)", pname);
case 2: format(string, sizeof(string), " %s abandonou o servidor. (Kickado/Banido)", pname);
}
SendClientMessageToAll(COLOR_GREY, string);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Kills",PlayerInfo[playerid][Kills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][Deaths]);
INI_WriteInt(File,"Adminlevel",PlayerInfo[playerid][Adminlevel]);
INI_Close(File);
return 1;
}
pawn Код:
{
new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s entrou no servidor.", pname);
SendClientMessageToAll(COLOR_GREY, string);
for(new chat = 0; chat <= 100; chat++)
{
SendClientMessage(playerid,COLOR_WHITE," ");
}
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""#COL_ORANGE":: "#COL_WHITE"Entrada", "\t\t"#COL_EASY"aaaaaaa "#COL_DGREEN"V "#COL_EASY"1\n\n"#COL_WHITEaaaaa, \naaaaaa", "Entrar", "Sair");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""#COL_ORANGE":: "#COL_WHITE"Registo" , "\t\t"#COL_EASY"aaaaaa"#COL_DGREEN"V "#COL_EASY"1\n\n"#COL_WHITE"aaaaaa, \naaaaaa!", "Registar", "Sair");
}
return 1;
}
pawn Код:
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""#COL_ORANGE":: "#COL_WHITE"aaaa" , "\t\t"#COL_EASY"aaaaa"#COL_DGREEN"V "#COL_EASY"1\n\n"#COL_WHITE"aaaaa, \naaaaa", "Registar", "Sair");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Adminlevel",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SetTimer("limparchat", 2000, 0);
SpawnPlayer(playerid);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][Password])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""#COL_ORANGE":: "#COL_WHITE"aaaa", "\t\t"#COL_EASY"aaaaaa"#COL_DGREEN"V "#COL_EASY"1\n\n"#COL_WHITE"aaaaa, \naaaaa!", "Entrar", "Sair");
}
return 1;
}
}
}
return 1;
}
pawn Код:
{
INI_Int("Password",PlayerInfo[playerid][Password]);
INI_Int("Cash",PlayerInfo[playerid][Cash]);
INI_Int("Kills",PlayerInfo[playerid][Kills]);
INI_Int("Deaths",PlayerInfo[playerid][Deaths]);
INI_Int("AdminLevel",PlayerInfo[playerid][Adminlevel]);
return 1;
}
pawn Код:
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
new id, lvl;
if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Level]");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid ID");
else if(lvl > 5) return SendClientMessage(playerid, COLOR_WHITE, "Administrator level only can be 5 ");
else
{
PlayerInfo[id][Adminlevel] = lvl;
}
return 1;
}