19.10.2014, 04:28
I have used the symbol "OnDialogResponse" two time in two different commands and it is giving me error. Tell me what to do?
#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. } |
#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"); } |
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.
|
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.
}
ah...
EDIT: Is it important to return on OnDialogResponse? pawn Код:
|