/server dialog help, [SIMPLE]
#1

Greetings,



Hi, well today I was trying to make a /server command and it open a DIALOG_STYLE_LIST with differents rcon commands like: "exit", "reloadbans" (for me momment).
Okay, but when I complie all that I get this errors

pawn Код:
C:\Users\usuario\Sa-Mp\filterscripts\sql&cmd.pwn(606) : error 031: unknown directive
C:\Users\usuario\Sa-Mp\filterscripts\sql&cmd.pwn(613) : error 017: undefined symbol "DIALOG_SERVER"
C:\Users\usuario\Sa-Mp\filterscripts\sql&cmd.pwn(656) : warning 217: loose indentation
C:\Users\usuario\Sa-Mp\filterscripts\sql&cmd.pwn(657) : error 017: undefined symbol "DIALOG_SERVER"
C:\Users\usuario\Sa-Mp\filterscripts\sql&cmd.pwn(682) : error 030: compound statement not closed at the end of file (started at line 644)
This is my script

pawn Код:
#definfe DIALOG_SERVER
CMD:server(playerid, params[])
{
    if(gPlayerInfo[playerid][pAdmin] >= 4)
    {
        if(!sscanf(params, "u", params[0]))
        {
            ShowPlayerDialog(playerid, DIALOG_SERVER, DIALOG_STYLE_LIST, "[0.3x] ..::DisturBed Games::.. - server 1","Server exit\n Server ReloadBans","SEND","EXIT");
            new string[128];
            format(string, sizeof(string), "ADMINS: %s has entred the main operator server system", GetName(playerid));
            SendMessageToAdmins(COL_ORANGE, string);
        }
    } else SendClientMessage(playerid, -1, "SERVER: You are not allowed to use this command");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[24], str[128];
    GetPlayerName(playerid, pName, 24);

    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            SendClientMessage(playerid, -1, "{FFAE00}SERVER: You have registred this account");
            mysql_real_escape_string(inputtext, inputtext,TuberiasMySQL);
            format(str,128, "INSERT INTO users (username, password) VALUES ('%s', '%s')",pName, inputtext);
            mysql_function_query(TuberiasMySQL, str, false, "OnQueryFinish", "iis", 0,playerid,inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You must register before to spawn");
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            GetPlayerName(playerid, pName, 24);
            mysql_real_escape_string(inputtext, inputtext, TuberiasMySQL);
            format(str, sizeof(str), "SELECT * FROM users WHERE username='%s'", pName);
            mysql_function_query(TuberiasMySQL, str, true, "OnQueryFinish", "iis", 0,playerid, inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You need to login to play here");
            Kick(playerid);
        }
    {
    if(dialogid == DIALOG_SERVER)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    SendRconCommand("exit");
                    new string[128];
                    format(string, sizeof(string), "SERVER: Administrator %s has shutted down the server", GetName(playerid));
                    SendClientMessageToAll(-1, string);
                }
                case 1:
                {
                    SendRconCommand("reloadbans");
                    new string[128];
                    format(string, sizeof(string), "ADMINS: Administrator %s has reloaded the bans", GetName(playerid));
                    SendMessageToAdmins(-1, string);
                }
            }
        }
    }
    return 1;
}

And this are the lines:

pawn Код:
#definfe DIALOG_SERVER  //606

ShowPlayerDialog(playerid, DIALOG_SERVER, DIALOG_STYLE_LIST, "[0.3x] ..::DisturBed Games::.. - server 1","Server exit\n Server ReloadBans","SEND","EXIT"); //613

{  //656
if(dialogid == DIALOG_SERVER) //657

*I don`t have line 682 in my script*
If anyone can help me


Regards,
Pablo.
Reply
#2

#definfe DIALOG_SERVER

should be

#define DIALOG_SERVER 1 // change 1 to an unused dialogid.
Reply
#3

Do what Tyler said and then paste this. (I'll just add the correct #define too.)

pawn Код:
#define DIALOG_SERVER 1
//change 1 to whatever is unused.
CMD:server(playerid, params[])
{
    if(gPlayerInfo[playerid][pAdmin] >= 4)
    {
        if(!sscanf(params, "u", params[0]))
        {
            ShowPlayerDialog(playerid, DIALOG_SERVER, DIALOG_STYLE_LIST, "[0.3x] ..::DisturBed Games::.. - server 1","Server exit\n Server ReloadBans","SEND","EXIT");
            new string[128];
            format(string, sizeof(string), "ADMINS: %s has entred the main operator server system", GetName(playerid));
            SendMessageToAdmins(COL_ORANGE, string);
        }
    } else SendClientMessage(playerid, -1, "SERVER: You are not allowed to use this command");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[24], str[128];
    GetPlayerName(playerid, pName, 24);

    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            SendClientMessage(playerid, -1, "{FFAE00}SERVER: You have registred this account");
            mysql_real_escape_string(inputtext, inputtext,TuberiasMySQL);
            format(str,128, "INSERT INTO users (username, password) VALUES ('%s', '%s')",pName, inputtext);
            mysql_function_query(TuberiasMySQL, str, false, "OnQueryFinish", "iis", 0,playerid,inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You must register before to spawn");
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            GetPlayerName(playerid, pName, 24);
            mysql_real_escape_string(inputtext, inputtext, TuberiasMySQL);
            format(str, sizeof(str), "SELECT * FROM users WHERE username='%s'", pName);
            mysql_function_query(TuberiasMySQL, str, true, "OnQueryFinish", "iis", 0,playerid, inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You need to login to play here");
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_SERVER)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    SendRconCommand("exit");
                    new string[128];
                    format(string, sizeof(string), "SERVER: Administrator %s has shutted down the server", GetName(playerid));
                    SendClientMessageToAll(-1, string);
                }
                case 1:
                {
                    SendRconCommand("reloadbans");
                    new string[128];
                    format(string, sizeof(string), "ADMINS: Administrator %s has reloaded the bans", GetName(playerid));
                    SendMessageToAdmins(-1, string);
                }
            }
        }
    }
    return 1;
}
Reply
#4

Guys you just changed the

pawn Код:
#define DIALOG_SERVER

to

#define DIALOG_SERVER 1
Btw, it works, thanks but please answer me this post I want to know
Reply
#5

EDIT: Just re-read what you posted. That's what Tyler basically changed but it still wouldn't compile unless you used the code i gave you as there was a misplaced bracket that was "{" instead of "}".


What exactly do you want to know? What was changed?

I changed: (marked with //line i changed.
pawn Код:
if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            GetPlayerName(playerid, pName, 24);
            mysql_real_escape_string(inputtext, inputtext, TuberiasMySQL);
            format(str, sizeof(str), "SELECT * FROM users WHERE username='%s'", pName);
            mysql_function_query(TuberiasMySQL, str, true, "OnQueryFinish", "iis", 0,playerid, inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You need to login to play here");
            Kick(playerid);
        }
    {//line i changed - reason: You just got the bracket mixed up. You were suppose to close it ('}').
Also; you had
pawn Код:
#definfe DIALOG_SERVER
not
pawn Код:
#define DIALOG_SERVER
Reply
#6

You need to enter a dialogid. It requires a integer such as 1,2,87 etc.

Example you're using this.

pawn Код:
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_MSGBOX, "Hello", "This is a Dialog.", "OK", "");
In this code your dialogid 4 is the msgbox. If you want to do something with OnDialogResponse you need to enter this 4 for MSGBOX, when the player press OK.

pawn Код:
if(dialogid == 4)
But there is a easy way to keep the ID's on your mind. In fact definition of Dialog IDs.

pawn Код:
#define DIALOG_MSG 4
Now you can use this definition instead of 4.

Example.

pawn Код:
if(dialogid == DIALOG_MSG)
Reply
#7

I triyed with bot case:

pawn Код:
if(dialogid == DIALOG_SERVER)

&

if(dialogid == 4)
I don`t get any error and nothing, It`s just that I can not open the dialog in the server when I use /server I don`t know why. Take a look:

pawn Код:
#define DIALOG_SERVER 3
CMD:server(playerid, params[])
{
    if(gPlayerInfo[playerid][pAdmin] >= 4)
    {
        if(!sscanf(params, "u", params[0]))
        {
            ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "[0.3x] ..::DisturBed Games::.. - server 1","Server exit\nServer reloadBans\nServer reload filterscripts\nChange rcon password ","SEND","EXIT");
            new string[128];
            format(string, sizeof(string), "ADMINS: %s has entred the main operator server system", GetName(playerid));
            SendMessageToAdmins(COL_ORANGE, string);
        }
    } else SendClientMessage(playerid, -1, "SERVER: You are not allowed to use this command");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[24], str[128];
    GetPlayerName(playerid, pName, 24);

    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            SendClientMessage(playerid, -1, "{FFAE00}SERVER: You have registred this account");
            mysql_real_escape_string(inputtext, inputtext,TuberiasMySQL);
            format(str,128, "INSERT INTO users (username, password) VALUES ('%s', '%s')",pName, inputtext);
            mysql_function_query(TuberiasMySQL, str, false, "OnQueryFinish", "iis", 0,playerid,inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You must register before to spawn");
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            GetPlayerName(playerid, pName, 24);
            mysql_real_escape_string(inputtext, inputtext, TuberiasMySQL);
            format(str, sizeof(str), "SELECT * FROM users WHERE username='%s'", pName);
            mysql_function_query(TuberiasMySQL, str, true, "OnQueryFinish", "iis", 0,playerid, inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You need to login to play here");
            Kick(playerid);
        }
    }
    if(dialogid == 3)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    SendRconCommand("exit");
                    new string[128];
                    format(string, sizeof(string), "SERVER: Administrator %s has shutted down the server", GetName(playerid));
                    SendClientMessageToAll(-1, string);
                }
                case 1:
                {
                    SendRconCommand("reloadbans");
                    new string[128];
                    format(string, sizeof(string), "ADMINS: Administrator %s has reloaded the bans", GetName(playerid));
                    SendMessageToAdmins(-1, string);
                }
                case 2:
                {
                    SendRconCommand("reloadfs");
                    new string[128];
                    format(string, sizeof(string), "SERVER: Administrator %s has re-loaded all filterscripts", GetName(playerid));
                    SendClientMessageToAll(-1, string);
                }
            }
        }
    }
    return 1;
}
All my code ^^
Reply
#8

OnDialogueResponse requires you to return 0.

pawn Код:
#define DIALOG_SERVER 3
CMD:server(playerid, params[])
{
    if(gPlayerInfo[playerid][pAdmin] >= 4)
    {
        if(!sscanf(params, "u", params[0]))
        {
            ShowPlayerDialog(playerid, DIALOG_SERVER , DIALOG_STYLE_LIST, "[0.3x] ..::DisturBed Games::.. - server 1","Server exit\nServer reloadBans\nServer reload filterscripts\nChange rcon password ","SEND","EXIT");
            new string[128];
            format(string, sizeof(string), "ADMINS: %s has entred the main operator server system", GetName(playerid));
            SendMessageToAdmins(COL_ORANGE, string);
        }
    } else SendClientMessage(playerid, -1, "SERVER: You are not allowed to use this command");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[24], str[128];
    GetPlayerName(playerid, pName, 24);

    if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            SendClientMessage(playerid, -1, "{FFAE00}SERVER: You have registred this account");
            mysql_real_escape_string(inputtext, inputtext,TuberiasMySQL);
            format(str,128, "INSERT INTO users (username, password) VALUES ('%s', '%s')",pName, inputtext);
            mysql_function_query(TuberiasMySQL, str, false, "OnQueryFinish", "iis", 0,playerid,inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You must register before to spawn");
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_LOGIN)
    {
        if(response)
        {
            GetPlayerName(playerid, pName, 24);
            mysql_real_escape_string(inputtext, inputtext, TuberiasMySQL);
            format(str, sizeof(str), "SELECT * FROM users WHERE username='%s'", pName);
            mysql_function_query(TuberiasMySQL, str, true, "OnQueryFinish", "iis", 0,playerid, inputtext);
        }
        else
        {
            SendClientMessage(playerid, COL_RED, "KICKED: You need to login to play here");
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_SERVER )
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    SendRconCommand("exit");
                    new string[128];
                    format(string, sizeof(string), "SERVER: Administrator %s has shutted down the server", GetName(playerid));
                    SendClientMessageToAll(-1, string);
                }
                case 1:
                {
                    SendRconCommand("reloadbans");
                    new string[128];
                    format(string, sizeof(string), "ADMINS: Administrator %s has reloaded the bans", GetName(playerid));
                    SendMessageToAdmins(-1, string);
                }
                case 2:
                {
                    SendRconCommand("reloadfs");
                    new string[128];
                    format(string, sizeof(string), "SERVER: Administrator %s has re-loaded all filterscripts", GetName(playerid));
                    SendClientMessageToAll(-1, string);
                }
            }
        }
    }
    return 0;
}
Reply
#9

thanks for your answer!
Reply
#10

Np, did it work then?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)