Something wrong? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Something wrong? (
/showthread.php?tid=547327)
Something wrong? -
HY - 22.11.2014
I just wanna' know if you can use else under OnDialogResponse, like this:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CHOOSE)
{
if(response)
{
if(listitem == 0)
{
ClassInfo[playerid][Normal] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Jucator {15FF00} in echipa Romaniei !");
}
if(listitem == 1)
{
if(ClassInfo[playerid][Experienta] >= 10)
{
ClassInfo[playerid][Normal] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FFCC33}Sniper {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
if(listitem == 2)
{
if(ClassInfo[playerid][Experienta] >= 15)
{
ClassInfo[playerid][Assault] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Assault {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
if(listitem == 3)
{
if(ClassInfo[playerid][Experienta] >= 30)
{
ClassInfo[playerid][Killer] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}KILLER {15FF00} in echipa Romaniei !");
}
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
if(listitem == 4)
{
if(ClassInfo[playerid][VIPP] >= 1)
{
ClassInfo[playerid][Killer] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}VIP {15FF00} in echipa Romaniei !");
}
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
if(listitem == 5)
{
if(ClassInfo[playerid][Donator] >= 1)
{
ClassInfo[playerid][Killer] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Donator {15FF00} in echipa Romaniei !");
}
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
}
}
return 1;
}
Will work, if player doesn't have 10, 15, 30 experience, will get message from else?
Re: Something wrong? -
AndySedeyn - 22.11.2014
I don't think it will work like that.
Why don't you add the ELSE statement under the IF statement? (And I mean the ones under listitem)
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CHOOSE)
{
if(response)
{
if(listitem == 0)
{
ClassInfo[playerid][Normal] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Jucator {15FF00} in echipa Romaniei !");
}
if(listitem == 1)
{
if(ClassInfo[playerid][Experienta] >= 10)
{
ClassInfo[playerid][Normal] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FFCC33}Sniper {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
if(listitem == 2)
{
if(ClassInfo[playerid][Experienta] >= 15)
{
ClassInfo[playerid][Assault] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Assault {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
if(listitem == 3)
{
if(ClassInfo[playerid][Experienta] >= 30)
{
ClassInfo[playerid][Killer] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}KILLER {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
if(listitem == 4)
{
if(ClassInfo[playerid][VIPP] >= 1)
{
ClassInfo[playerid][Killer] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}VIP {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
if(listitem == 5)
{
if(ClassInfo[playerid][Donator] >= 1)
{
ClassInfo[playerid][Killer] = 1;
SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Donator {15FF00} in echipa Romaniei !");
}
else
{
SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
}
}
}
}
return 0;
}
Don't forget to return 0 in the OnDialogResponse function.
Re: Something wrong? -
dominik523 - 22.11.2014
Why would you do if(listitem == 2) and check under it for more listitems? If the listitem is 2, it don't have to check for i.e. listitem 3 under it.
Re: Something wrong? -
Vince - 22.11.2014
Use a switch, it's a much cleaner (and faster) solution.