[HELP] Place / Admins in Dialog
#1

Guys, Today I came here to ask if you help me put my / admins in Dialog!

My / admins:


Код:
if(!strcmp(cmdtext, "/admins", true))
{
new count=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)){
if(admin[i]){
new str[256];
new pname[24];
GetPlayerName(i, pname, 24);
format(file2, sizeof(file2), PASTA_CONTAS, pname);
if(pAdmin[i] == 1){
format(str,sizeof(str),"{21E000}%s (%d) :: {21E000}[Tutor]", pname,i);
}
if(pAdmin[i] == 2){
format(str,sizeof(str),"{3838FF}%s (%d) :: {3838FF}[Administrador]", pname,i);
}
if(pAdmin[i] == 3){
format(str,sizeof(str),"{E5FF00}%s (%d) :: {E5FF00}[Administrador Senior]", pname,i);
}
if(pAdmin[i] == 4){
format(str,sizeof(str),"{7418FF}%s (%d) :: {7418FF}[Sub-Dono]", pname,i);
}
if(pAdmin[i] == 5){
format(str,sizeof(str),"{F80018}%s (%d) :: {F80018}[Dono]", pname,i);
}
SendClientMessage(playerid, 0x0080FFAA, str);
count++;
}
}
}
if(count == 0)
{
SendClientMessage(playerid, Vermelho, "(ERRO) Nгo hб administradores online no momento");
}
return 1;
}
Who can help me thank !
Reply
#2

You can try declaring a long string (I usually use 2048 to 3072 so as to contain as many characters as possible) like this:
pawn Код:
new string[2048] = "";//Initialisation is important here
You have to know that dialogs use \n to create a new line. So you can concatenate the string using format like this, as I see you have some integers and strings in your code:
pawn Код:
format(string, sizeof(string), "%sBlaBlaBla(name or something)\n", string, (your parameters) );
If you do that by searching all the players and check if they are admins, you can simply do the job. After that you can show the dialog:
pawn Код:
ShowPlayerDialog(playerid, dialog id, dialog style(I like DIALOG_STYLE_LIST but DIALOG_STYLE_MSGBOX is also possible), caption/title , content of the dialog (you string), button1, button2);
Check it out in the SA-MP wiki:
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
https://sampwiki.blast.hk/wiki/OnDialogResponse

Finally I suggest you to use "switch" to replace those "if(pAdmin[i] blablabla": https://sampwiki.blast.hk/wiki/Control_Structures#switch_2
and also changing those '24's for pname into MAX_PLAYER_NAME. When the name length changes after SA-MP releases a new update, you don't need to modify that much to support it.
Reply
#3

Well as I'm Newbie What you do not understand this much explaining to me how you would help me make the Code?
Reply
#4

pawn Код:
if(!strcmp(cmdtext, "/admins", true))
{
new count=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)){
if(admin[i]){
new str[256];
new pname[24];
GetPlayerName(i, pname, 24);
format(file2, sizeof(file2), PASTA_CONTAS, pname);
if(pAdmin[i] == 1){
format(str,sizeof(str),"{21E000}%s (%d) :: {21E000}[Tutor]", pname,i);
}
if(pAdmin[i] == 2){
format(str,sizeof(str),"{3838FF}%s (%d) :: {3838FF}[Administrador]", pname,i);
}
if(pAdmin[i] == 3){
format(str,sizeof(str),"{E5FF00}%s (%d) :: {E5FF00}[Administrador Senior]", pname,i);
}
if(pAdmin[i] == 4){
format(str,sizeof(str),"{7418FF}%s (%d) :: {7418FF}[Sub-Dono]", pname,i);
}
if(pAdmin[i] == 5){
format(str,sizeof(str),"{F80018}%s (%d) :: {F80018}[Dono]", pname,i);
}
ShowPlayerDialog(playerid,16, DIALOG_STYLE_MSGBOX, "{FF0000}Online Admins:",str, "OK", "Cancel");
count++;
}
}
}
if(count == 0)
{
SendClientMessage(playerid, Vermelho, "(ERRO) Nгo hб administradores online no momento");
}
return 1;
}
Try this.It may work
Reply
#5

Quote:
Originally Posted by xRuffles
Посмотреть сообщение
Well as I'm Newbie What you do not understand this much explaining to me how you would help me make the Code?
I won't make you the code as you'll just simply copy and paste my code and learn nothing. If you create the original code, I'm pretty sure you can do it. What you need to do is to create a string that contains all the admins' name, ID and their level. Then you can simply pass the string to the dialog code. You can have a look here to learn how to create and process a dialog: https://sampwiki.blast.hk/wiki/OnDialogResponse

Quote:
Originally Posted by Gamer_007
Посмотреть сообщение
pawn Код:
if(!strcmp(cmdtext, "/admins", true))
{
new count=0;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)){
if(admin[i]){
new str[256];
new pname[24];
GetPlayerName(i, pname, 24);
format(file2, sizeof(file2), PASTA_CONTAS, pname);
if(pAdmin[i] == 1){
format(str,sizeof(str),"{21E000}%s (%d) :: {21E000}[Tutor]", pname,i);
}
if(pAdmin[i] == 2){
format(str,sizeof(str),"{3838FF}%s (%d) :: {3838FF}[Administrador]", pname,i);
}
if(pAdmin[i] == 3){
format(str,sizeof(str),"{E5FF00}%s (%d) :: {E5FF00}[Administrador Senior]", pname,i);
}
if(pAdmin[i] == 4){
format(str,sizeof(str),"{7418FF}%s (%d) :: {7418FF}[Sub-Dono]", pname,i);
}
if(pAdmin[i] == 5){
format(str,sizeof(str),"{F80018}%s (%d) :: {F80018}[Dono]", pname,i);
}
ShowPlayerDialog(playerid,16, DIALOG_STYLE_MSGBOX, "{FF0000}Online Admins:",str, "OK", "Cancel");
count++;
}
}
}
if(count == 0)
{
SendClientMessage(playerid, Vermelho, "(ERRO) Nгo hб administradores online no momento");
}
return 1;
}
Try this.It may work
I'm sure this will go wrong as you haven't concatenate the string and show the whole string at once. This code will result in showing only one admin per dialog, but not all.
Reply
#6

This Code did not work, it only appears in / admins First guy I seto I configured if I'll be just another after the first

Please someone help me?
Reply
#7

Alright then, seems that you can't understand my bad explanation, I'll do the most of the work for you with explanation.
pawn Код:
#define DIALOG_ADMINS 1000 //Put this somewhere before this command. The best is the top of your script.

//The above define is to make a proper name for the dialog. We will use this when we create a dialog,
//so that we can give it an ID that is needed by SA-MP.
if(!strcmp(cmdtext, "/admins", true))
{
    new count=0;
    new str[2048];//Put these outside the loop as we need to use the same string inside the loop.
    //We need a long string so that we can put all the names together.
    new pname[MAX_PLAYER_NAME];//Using MAX_PLAYER_NAME can prevent any problem
    //if SA-MP changes the maximum allowed length of player's name.
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
            if(admin[i])
            {              
                GetPlayerName(i, pname, MAX_PLAYER_NAME);
                format(file2, sizeof(file2), PASTA_CONTAS, pname);//I don't know what this is, so I leave it as it is.
                switch(pAdmin[i])
                {
                    case 1: format(str,sizeof(str),"%s{21E000}%s (%d) :: {21E000}[Tutor]",str,pname,i);
                    case 2: format(str,sizeof(str),"%s{3838FF}%s (%d) :: {3838FF}[Administrador]",str,pname,i);
                    //Do the same thing for the remaining 3 levels.
                }
            }
            count++;
        }
    }
    if(count == 0)
    {
        SendClientMessage(playerid, Vermelho, "(ERRO) Nao ha administradores online no momento");
    }
    else
    {
        //Use either DIALOG_STYLE_MSGBOX or DIALOG_STYLE_LIST below. I use DIALOG_STYLE_MSGBOX as an example.
        //If you think the message box is too small for 1024x768, you may use DIALOG_STYLE_LIST.
        ShowPlayerDialog(playerid,DIALOG_ADMINS,DIALOG_STYLE_MSGBOX,"(Your title)",str,"Button1","Button2(leave this blank if you only want 1 button)");
    }
}
return 1;
}
Hope you understand this time, and you won't just copy and paste without asking why it work.
Reply
#8

eu Fiz aqui mбs deu erro ;"(
Reply
#9

make it with sscanf+zcmd
Reply
#10

So, can you do it now? I can't read Portuguese without ****** lol.
If you have any compiler errors, feel free to post it here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)