Hi guys, look the video and see the problem.
Problem: when I open a case, its go back to the first dialog...
Код:
if(pickupid == store)
{
ShowPlayerDialog(playerid, 1213, DIALOG_STYLE_LIST, "Store", "{FF0000}Buy/Change Skin {FFFFFF}$1.000.000\n{FF0000}Remove bought Skin\n{FF0000}Food{FFFFFF}/{FF0000}Drink", "Select", "Back");
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1213) //Skin and Cookies and Food/Drink (Shop/Store)
{
if(response)
{
if(listitem == 0)
{
ShowPlayerDialog(playerid, 550, DIALOG_STYLE_INPUT, "Store", "{FFFF00}All Skins at: www.wiki.sa-mp.com/wiki/Skins (Look before u buy)", "Buy", "Back");
}
if(listitem == 1)
{
ShowPlayerDialog(playerid,551,DIALOG_STYLE_LIST,"Store","{FF0000}Are you sure?","Yes","Back");
}
if(listitem == 2)
{
ShowPlayerDialog(playerid,552,DIALOG_STYLE_LIST,"Store","{FF0000}Beer + 100hp {FFFF00}$5000\n{FF0000}Pizza + 50hp {FFFF00}$2500\n{FF0000}Cola + 25hp {FFFF00}$1000","Buy","Back");
}
return 1;
}
}
if(dialogid == 550) //Skin and Cookies and Food/Drink (Shop/Store)
{
if(response)
{
new skinid, messagee[64];
skinid = strval(inputtext);
if(skinid < 0 || skinid > 299)
{
SendClientMessage(playerid, ROT, "SERVER: Skin id may be between 0 and 299.");
}
else
{
SetPlayerSkin(playerid, skinid);
GivePlayerMoney(playerid, -1000000);
format(messagee, sizeof(messagee), "| Store | You have bought skin id {FF0000}%d.", skinid);
SendClientMessage(playerid, BLAU, messagee);
}
if(!dini_Exists(PFile(playerid)))
{
dini_Create(PFile(playerid));
dini_IntSet(PFile(playerid),"Skin",GetPlayerSkin(playerid));
}
else if(dini_Exists(PFile(playerid)))
{
dini_IntSet(PFile(playerid),"Skin",GetPlayerSkin(playerid));
}
}
else{
ShowPlayerDialog(playerid, 1213, DIALOG_STYLE_LIST, "Store", "{FF0000}Buy/Change Skin {FFFFFF}$1.000.000\n{FF0000}Remove bought Skin\n{FF0000}Food{FFFFFF}/{FF0000}Drink", "Select", "Back");
}
}
if(dialogid == 551){
if(response){
if(!dini_Exists(PFile(playerid))) return SendClientMessage(playerid, ROT, "[ERROR]You dont have a skin");
dini_IntSet(PFile(playerid),"Skin",0);
dini_Remove(PFile(playerid));
SendClientMessage(playerid, GREEN, "You has sell your skin");
}
else
{
ShowPlayerDialog(playerid, 1213, DIALOG_STYLE_LIST, "Store", "{FF0000}Buy/Change Skin {FFFFFF}$1.000.000\n{FF0000}Remove bought Skin\n{FF0000}Food{FFFFFF}/{FF0000}Drink", "Select", "Back");
}
}
if(dialogid == 552)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) > 5000)
{
GivePlayerMoney(playerid,5000);
SetPlayerHealth(playerid, 100);
}
else
{
SendClientMessage(playerid,ROT, "| Fehler | Du hast nicht genug Geld!");
}
return 1;
}
case 1:
{
if(GetPlayerMoney(playerid) > 2500)
{
GivePlayerMoney(playerid,2500);
SetPlayerHealth(playerid, 50);
}
else
{
SendClientMessage(playerid,ROT, "| Fehler | Du hast nicht genug Geld!");
}
return 1;
}
case 2:
{
if(GetPlayerMoney(playerid) > 1000)
{
GivePlayerMoney(playerid,1000);
SetPlayerHealth(playerid, 25);
}
else
{
SendClientMessage(playerid,ROT, "| Fehler | Du hast nicht genug Geld!");
}
return 1;
}
}
}
return 0;
}
You are in area to show that dialog so while you standing inside code to show dialog gets executed again & again & again and so on. Make a var to see if dialog is already shown. On first enter set it to 1, then when he closes dialog set to 0 and show first dialog on entry ONLY if var is 0.
How to make the "var" pls help me to do it, I posted my code and u can see the code.