Makeadmin dialog problem
#1

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:

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");
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.
Reply
#2

You have to use %d for numbers, not %s.
Thats what u need:
format(s, sizeof(s), "Administrator %s has made you an level %d administrator",name, inputtext);
SendClientMessage(giveplayerid, LIGHTBLUE, s);
format(s, sizeof(s), "Administrator %s has made %s an admin level %d", name, giveplayername, inputtext);
Reply
#3

@ikarus: inputtext is a string, so you need to convert it to integer if you want to use %d or %i for it.
Reply
#4

strval(inputtext);
Reply
#5

Quote:
Originally Posted by Don Correlli
@ikarus: inputtext is a string, so you need to convert it to integer if you want to use %d or %i for it.
Yea
Reply
#6

Quote:
Originally Posted by MenaceX^
strval(inputtext);
I dont get it?
Reply
#7

hey arent u an admin for awesome stuntages? me and my bro used to mess with you
i think
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)