06.03.2010, 11:20
Hello. I have been working on a makeadmin command. First when i type makeadmin it shows a dialog where you need to input the playerid of the player who you want to make admin, and after that the second dialog shows up and you should input the admin level. Heres the code that i made:
It outputs the player names, it saves the admin level in the file, and everything works fine, but when i login it wont read the adminlevel.
Hope you can help me.
pawn Код:
//OnPlayerCommandText
if(strcmp(cmdtext, "/makeadmin", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
ShowPlayerDialog(playerid, MAKEADMIN_DIALOG, DIALOG_STYLE_INPUT, "Type the playerid to make admin","","Select","Cancel");
return 1;
}
}
pawn Код:
//OnPlayerDialogResponse
if(dialogid == MAKEADMIN_DIALOG)
{
if(response)
{
new targetid = ReturnUser(inputtext);
if(targetid == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, RED, "That player is not connected");
return 1;
}
else if(targetid != INVALID_PLAYER_ID)
{
ShowPlayerDialog(playerid, 5564, DIALOG_STYLE_INPUT,"Chose the adminlevel of the player","","Select","Cancel");
return 1;
}
pawn Код:
if(dialogid == 5564)
{
if(response)
{
new giveplayerid;
new giveplayername[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, name, sizeof(name));
format(s, sizeof(s),"Accounts/%s.ini", name);
PlayerInfo[playerid][AdminLevel] = strval(inputtext);
dini_Set(s, "AdminLevel", inputtext);
format(s, sizeof(s), "Administrator %s has made you an level %s administrator",name, inputtext);
SendClientMessage(giveplayerid, LIGHTBLUE, s);
format(s, sizeof(s), "Administrator %s has made %s an admin level %s", name, giveplayername, inputtext);
SendClientMessageToAll(RED, s);
}
return 1;
}
pawn Код:
//And when i login i puted
format(s, sizeof(s),"Accounts/%s.ini",name);
dini_Get(s, "AdminLevel");
Hope you can help me.