Dialog problem -
Dan. - 24.07.2012
I have this code under OnDialogResponse:
pawn Код:
//
case D_SHOP:
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) >= 2500)
{
GivePlayerMoney(playerid, -2500);
SetPlayerHealth(playerid, 100);
SCM(playerid, C_LGREEN, "Health refilled! It cost $2500!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 1)
if(GetPlayerMoney(playerid) >= 3000)
{
GivePlayerMoney(playerid, -3000);
SetPlayerArmour(playerid, 100);
SCM(playerid, C_LGREEN, "Armour refilled! It cost $3000!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 2)
{
if(GetPlayerMoney(playerid) >= 500)
{
GivePlayerMoney(playerid, -500);
GivePlayerWeapon(playerid, 4, 1);
SCM(playerid, C_LGREEN, "You bought a knife! It cost $500!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 3)
{
if(GetPlayerMoney(playerid) >= 1000)
{
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid, 9, 1);
SCM(playerid, C_LGREEN, "You bought a chainsaw! It cost $1000!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 4)
{
if(GetPlayerMoney(playerid) >= 1500)
{
GivePlayerMoney(playerid, -1500);
GivePlayerWeapon(playerid, 24, 50);
SCM(playerid, C_LGREEN, "You bought a Deagle! It cost $1500!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 5)
{
if(GetPlayerMoney(playerid) >= 3500)
{
GivePlayerMoney(playerid, -3500);
GivePlayerWeapon(playerid, 27, 50);
SCM(playerid, C_LGREEN, "You bought a Combat Shotgun! It cost $3500!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 6)
{
if(GetPlayerMoney(playerid) >= 2000)
{
GivePlayerMoney(playerid, -1500);
GivePlayerWeapon(playerid, 29, 50);
SCM(playerid, C_LGREEN, "You bought a MP5! It cost $1500!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 7)
{
if(GetPlayerMoney(playerid) >= 3500)
{
GivePlayerMoney(playerid, -3500);
GivePlayerWeapon(playerid, 31, 50);
SCM(playerid, C_LGREEN, "You bought a M4! It cost $3500!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
if(listitem == 8)
{
if(GetPlayerMoney(playerid) >= 1000)
{
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid, 8, 1);
SCM(playerid, C_LGREEN, "You bought a Katana! It cost $1000!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
}
}
}
return 1;
}
If I remove that case D_SHOP, no errors at all, everything fine.
If I keep the code there:
pawn Код:
Desktop\SA-MP\Battlefield Server 1.2\gamemodes\GM.pwn(1083) : warning 217: loose indentation
Desktop\SA-MP\Battlefield Server 1.2\gamemodes\GM.pwn(1155) : warning 209: function "OnDialogResponse" should return a value
Desktop\SA-MP\Battlefield Server 1.2\gamemodes\GM.pwn(1156) : error 010: invalid function or declaration
Added comments after error lines.
Re: Dialog problem -
newbienoob - 24.07.2012
pawn Код:
if(listitem == 1)
{
if(GetPlayerMoney(playerid) >= 3000)
{
GivePlayerMoney(playerid, -3000);
SetPlayerArmour(playerid, 100);
SCM(playerid, C_LGREEN, "Armour refilled! It cost $3000!");
}
else return SendClientMessage(playerid, C_RED, "Not enough money!");
}
(Sorry about bad indentations)
Re: Dialog problem -
leonardo1434 - 24.07.2012
just indent the line 1083, ondialogresponse lacks of return in the end of the function. if you don't know how to do, post here the whole dialog response showing the lines of erro as you have done.
Re: Dialog problem -
Kindred - 24.07.2012
You cannot return 1; at the end of OnDialogResponse (if I am correct) so return 0 where you have return 1;
Also, add return 1; to the end of your dialog, considering you must return a value.
Re: Dialog problem -
Dan. - 24.07.2012
Just fixed the line 1083, and Kindred, I have always return 1; in the end of OnDialogResponse and it works.