SA-MP Forums Archive
Help in dialog - 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: Help in dialog (/showthread.php?tid=395985)



Help in dialog - AMEENAMEEN - 28.11.2012

Alright so this is my dialog
pawn Код:
new ammupickup1;
pawn Код:
#define DIALOG_AMMU 80
pawn Код:
ammupickup1 = CreateDynamicPickup(1317, 1, 308.2660,-141.4643,999.6016 , -1, -1, -1, 100.0);
pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(pickupid == ammupickup1)
    {
        ShowPlayerDialog(playerid,DIALOG_AMMU,DIALOG_STYLE_LIST ,"Ammu Nation","Deagle 2000$ (30 Time In LS)\nShotgun 1500$(10 Time In LS)\nColt 1000$ ( 10 Time In LS)\nRifle 1500$\nUZI 1000$\nAK-47 6000$","Ok","Cancel");
        return 1;
    }
    return 1;
}

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_AMMU)
    {
        if (response == 1)
        {
            switch(listitem)
            {
                case 0:
                if(GetPlayerPCash(playerid)>=2000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,24,100);
                    GivePlayerPCash(playerid, - 2000);
                }
                else
                {
                    SendClientMessage(playerid,COLOR_LIGHTRED,"You do not have enough money Or Time In LS");
                }
                case 1:
                {
                if(GetPlayerPCash(playerid)>=3000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,25,50);
                    GivePlayerPCash(playerid, - 3000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 2:
                {
                if(GetPlayerPCash(playerid)>=1000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,22,150);
                    GivePlayerPCash(playerid, - 1000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 3:
                {
                if(GetPlayerPCash(playerid)>=1000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,33,60);
                    GivePlayerPCash(playerid, - 1000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 4:
                {
                if(GetPlayerPCash(playerid)>=1000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,32,200);
                    GivePlayerPCash(playerid, - 1000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 5:
                {
                if(GetPlayerPCash(playerid)>=6000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,30,250);
                    GivePlayerPCash(playerid, - 6000);
                    TogglePlayerControllable(playerid,true);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
            }
        }
    }

So my problem is when player goes to pickup the dialong keep re showing every 1 second even if i press cancel , what would be the fix


Re: Help in dialog - NumbSkull - 28.11.2012

set a pvar to to not show it like
pawn Код:
if(dialogid == DIALOG_AMMU&&GetPVarInt(playerid,"ammudialog")!=1)
    {
        SetPVarInt(playerid,"ammudialog",1);
        if (response == 1)
(rest of script)
then set a timer on cancel to reset/delete the pvar so they have time to get away and have time to wait if they want to get it again
cuz they are standing on the pickup so it keeps picking it up
or posably change pickup type to 19


Re: Help in dialog - AMEENAMEEN - 28.11.2012

Where should i place the timer , Sorry i am not too familiar with dialogs


Re: Help in dialog - NumbSkull - 28.11.2012

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_AMMU)
    {
        if (response == 1)
        {
            switch(listitem)
            {
                case 0:
                if(GetPlayerPCash(playerid)>=2000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,24,100);
                    GivePlayerPCash(playerid, - 2000);
                }
                else
                {
                    SendClientMessage(playerid,COLOR_LIGHTRED,"You do not have enough money Or Time In LS");
                }
                case 1:
                {
                if(GetPlayerPCash(playerid)>=3000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,25,50);
                    GivePlayerPCash(playerid, - 3000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 2:
                {
                if(GetPlayerPCash(playerid)>=1000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,22,150);
                    GivePlayerPCash(playerid, - 1000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 3:
                {
                if(GetPlayerPCash(playerid)>=1000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,33,60);
                    GivePlayerPCash(playerid, - 1000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 4:
                {
                if(GetPlayerPCash(playerid)>=1000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,32,200);
                    GivePlayerPCash(playerid, - 1000);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
                case 5:
                {
                if(GetPlayerPCash(playerid)>=6000 && PlayerInfo[playerid][pConnectTime] > 15)
                {
                    GivePlayerWeaponEx(playerid,30,250);
                    GivePlayerPCash(playerid, - 6000);
                    TogglePlayerControllable(playerid,true);
                }
                else return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this item!");
                }
            }
        }
        else SetPVarInt(playerid,"ammuvar",SetTimerEx("DeleteAmmuvar", 5000, false, "i", playerid);
    }
then you need the forward and public DeleteAmmuvar(playerid) to delete the pvar and killtimer(GetPVarInt(playerid,"ammuvar")) **i always kill timers just incase**


Re: Help in dialog - AMEENAMEEN - 28.11.2012

Like this ?
pawn Код:
forward DeleteAmmuvar(playerid);
public DeleteAmmuvar(playerid)
{
    killtimer(GetPVarInt(playerid,"ammuvar"))
    return 1;
    }
    return 1;
}
still get errors


Re: Help in dialog - NumbSkull - 28.11.2012

pawn Код:
forward DeleteAmmuvar(playerid);
public DeleteAmmuvar(playerid)
{
    killtimer(GetPVarInt(playerid,"ammuvar"))
    DeletePVar(playerid,"ammudialog");
}
what errors do you get now?


Re: Help in dialog - AMEENAMEEN - 28.11.2012

So i edited my public to
pawn Код:
forward DeleteAmmuvar(playerid);
public DeleteAmmuvar(playerid)
{
    killtimer(GetPVarInt(playerid,"ammuvar"))
    DeletePVar(playerid,"ammudialog");
    return 1;
    }
    return 1;
}
(44520) : error 017: undefined symbol "killtimer"
(44524) : error 010: invalid function or declaration
(44593) : error 001: expected token: ",", but found ";"
here is the lines
44520
pawn Код:
killtimer(GetPVarInt(playerid,"ammuvar"))
44524
pawn Код:
return 1;
44593
pawn Код:
else SetPVarInt(playerid,"ammuvar",SetTimerEx("DeleteAmmuvar", 5000, false, "i", playerid);