Error in Defining a symbol Two Times
#1

I have used the symbol "OnDialogResponse" two time in two different commands and it is giving me error. Tell me what to do?
Reply
#2

Quote:
Originally Posted by Rissam
Посмотреть сообщение
I have used the symbol "OnDialogResponse" two time in two different commands and it is giving me error. Tell me what to do?
You should not call OnDialogResponse inside a command. You must use ShowPlayerDialog, which calls OnDialogResponse afterwards.
Reply
#3

Ok u see this.

Quote:

#define DIALOG_RULES 11

CMD:rules(playerid,params[])
{
ShowPlayerDialog(playerid,DIALOG_RULES,DIALOG_STYL E_LIST,"Server Rules","\nDonot use any hack in the server\nRespect the admins of the server","OK","");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_RULES)
{
if(response) // If they clicked 'Yes' or pressed enter
{
SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
}

return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}

return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}

and this:
Quote:

#define WEAP_DIALOG 10

CMDhop(playerid,params[])
{
ShowPlayerDialog(playerid,WEAP_DIALOG,DIALOG_STYLE _LIST,"Weapon Shop","\nSilenced Pistol(Ammo-500)-$500\nDeagle(Ammo 50) $650\nShotgun(Ammo 50) $2700\nSawn Of Shotgun(Ammo 50) $3000\nCombat Shotgun(Ammo 50) $3000\nMP5(Ammo 500) $1500\nAK 47(Ammo 500) $2500\nM4(Ammo 500) $3100\nCunt Rifle(Ammo 50) $2750\nSniper Rifle(Ammo 50) $4750","Buy","Close");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==WEAP_DIALOG)
{
if(response)
{
switch(listitem)
{
case 0:SellWeapon(playerid,500,23,250);
case 1:SellWeapon(playerid,650,24,50);
case 2:SellWeapon(playerid,2700,25,50);
case 3:SellWeapon(playerid,3000,26,50);
case 4:SellWeapon(playerid,3000,27,50);
case 5:SellWeapon(playerid,1500,29,500);
case 6:SellWeapon(playerid,2500,30,500);
case 7:SellWeapon(playerid,3100,31,500);
case 8:SellWeapon(playerid,2750,33,50);
case 9:SellWeapon(playerid,4750,34,50);
}
}
}
return 1;
}

stock SellWeapon(playerid,money,weapon,ammo)
{
new playermoney = GetPlayerMoney(playerid);
if(playermoney>money)
{
new string[80],weaponname[32];
GivePlayerMoney(playerid,-money);
GivePlayerWeapon(playerid,weapon,ammo);
GetWeaponName(weapon,weaponname,sizeof(weaponname) );
format(string,sizeof(string),"You bought %i ammo of weapon %s for $%i",ammo,weaponname,money);
return SendClientMessage(playerid,-1,string);
}
else return SendClientMessage(playerid,-1,"You don't have enough money");
}

Look "OnDialogResponse" is used two times and it is giving error for using it two times
Reply
#4

Help me please
Reply
#5

Lines?
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
You need to combine the two callbacks so you only use it once. Alternatively, use y_dialog so you don't need to worry about that callback as you can just use inlines instead.
ah...

EDIT: Is it important to return on OnDialogResponse?


pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_RULES)
    {
        if(response) // If they clicked 'Yes' or pressed enter
        {
            SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
    if(dialogid==WEAP_DIALOG)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:SellWeapon(playerid,500,23,250);
                case 1:SellWeapon(playerid,650,24,50);
                case 2:SellWeapon(playerid,2700,25,50);
                case 3:SellWeapon(playerid,3000,26,50);
                case 4:SellWeapon(playerid,3000,27,50);
                case 5:SellWeapon(playerid,1500,29,500);
                case 6:SellWeapon(playerid,2500,30,500);
                case 7:SellWeapon(playerid,3100,31,500);
                case 8:SellWeapon(playerid,2750,33,50);
                case 9:SellWeapon(playerid,4750,34,50);
            }
        }
        return 1;
    }
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Reply
#7

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
ah...

EDIT: Is it important to return on OnDialogResponse?


pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_RULES)
    {
        if(response) // If they clicked 'Yes' or pressed enter
        {
            SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
    if(dialogid==WEAP_DIALOG)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:SellWeapon(playerid,500,23,250);
                case 1:SellWeapon(playerid,650,24,50);
                case 2:SellWeapon(playerid,2700,25,50);
                case 3:SellWeapon(playerid,3000,26,50);
                case 4:SellWeapon(playerid,3000,27,50);
                case 5:SellWeapon(playerid,1500,29,500);
                case 6:SellWeapon(playerid,2500,30,500);
                case 7:SellWeapon(playerid,3100,31,500);
                case 8:SellWeapon(playerid,2750,33,50);
                case 9:SellWeapon(playerid,4750,34,50);
            }
        }
        return 1;
    }
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Thanks man its is working +rep
Reply
#8

Just copy the dialogid in your new command
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)