SA-MP Forums Archive
Time controlled variable help - 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: Time controlled variable help (/showthread.php?tid=449459)



Time controlled variable help - Aerotactics - 08.07.2013

I'm writing a script where I need a variable only to be changed at 22:00, and that variable decides what a store can sell. This way isn't working:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid==753 && response)
    {
        ShowPlayerDialog(playerid, 754, DIALOG_STYLE_LIST, "What would you like to do?","Sell this item I'm holding\nTrade this item for a new item\nPawn this item\nDonate this item\nBrowse what's for sale\nHelp and Info", "Continue", "Leave");
        return 1;
    }
    if(dialogid==754 && response)
    {
        switch(listitem)
        {
            case 0:
            {
                return 1;
            }
            case 1:
            {
                return 1;
            }
            case 2:
            {
                return 1;
            }
            case 3:
            {
                ShowPlayerDialog(playerid, 770, DIALOG_STYLE_MSGBOX, "Donating your weapon...","Are you sure you want to donate this?","Yes","No");
                return 1;
            }
            case 4:
            {
                new Hour, Minute, Second;
                gettime(Hour, Minute, Second);
                if (Hour==22)
                {
                    new stor;
                    stor=random(4);
                    return 1;
                }
                if (stor==0)
                {
                    ShowPlayerDialog(playerid, 762, DIALOG_STYLE_LIST, "What would you like to purchase?","Stuff", "Continue", "Leave");
                    return 1;
                }
                else if (stor==1)
                {
                    ShowPlayerDialog(playerid, 763, DIALOG_STYLE_LIST, "What would you like to purchase?","Stuff2", "Continue", "Leave");
                    return 1;
                }
                else if (stor==2)
                {
                    ShowPlayerDialog(playerid, 764, DIALOG_STYLE_LIST, "What would you like to purchase?","Stuff3", "Continue", "Leave");
                    return 1;
                }
                else if (stor==3)
                {
                    ShowPlayerDialog(playerid, 765, DIALOG_STYLE_LIST, "What would you like to purchase?","Stuff4", "Continue", "Leave");
                    return 1;
                }
                else if (stor==4)
                {
                    ShowPlayerDialog(playerid, 766, DIALOG_STYLE_LIST, "What would you like to purchase?","Stuff5", "Continue", "Leave");
                    return 1;
                }
                else
                {
                    ShowPlayerDialog(playerid, 767, DIALOG_STYLE_MSGBOX, "Inventory is empty...","There is nothing for sale right now, please come back after 22:00.","Continue", "Leave");
                    return 1;
                }
            }



Re: Time controlled variable help - [MG]Dimi - 08.07.2013

You want when it's 22h in game? gettime is used for realtime.


Re: Time controlled variable help - DaRk_RaiN - 08.07.2013

It's because you returned after checking the hour
Try it without the return.
pawn Код:
if (Hour==22)
                {
                    new stor;
                    stor=random(4);
                    //return 1;
                }



Re: Time controlled variable help - Aerotactics - 08.07.2013

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
It's because you returned after checking the hour
Try it without the return.
pawn Код:
if (Hour==22)
                {
                    new stor;
                    stor=random(4);
                    //return 1;
                }
Alright, so here are my errors so far. Pretty much anytime "stor" is written:

Quote:

C:\Users\Aerotactics' PC\Desktop\SAMP\filterscripts\PawnShop.pwn(123) : warning 204: symbol is assigned a value that is never used: "stor"
C:\Users\Aerotactics' PC\Desktop\SAMP\filterscripts\PawnShop.pwn(123 -- 125) : error 017: undefined symbol "stor"
C:\Users\Aerotactics' PC\Desktop\SAMP\filterscripts\PawnShop.pwn(130) : error 017: undefined symbol "stor"
C:\Users\Aerotactics' PC\Desktop\SAMP\filterscripts\PawnShop.pwn(135) : error 017: undefined symbol "stor"
C:\Users\Aerotactics' PC\Desktop\SAMP\filterscripts\PawnShop.pwn(140) : error 017: undefined symbol "stor"
C:\Users\Aerotactics' PC\Desktop\SAMP\filterscripts\PawnShop.pwn(145) : error 017: undefined symbol "stor"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase




Re: Time controlled variable help - Aerotactics - 08.07.2013

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
You want when it's 22h in game? gettime is used for realtime.
It actually checks server time, as a matter of fact.


Re: Time controlled variable help - ReVo_ - 08.07.2013

You want to fix the errors, or the way to change the value of the variable only if are the 22h?

Anyway, you should declare "new stor" up

Код:
           case 4:
            {
new stor;
                new Hour, Minute, Second;
                gettime(Hour, Minute, Second);
                if (Hour==22)
                {
                    
                    stor=random(4);
                }



Re: Time controlled variable help - Aerotactics - 08.07.2013

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
You want to fix the errors, or the way to change the value of the variable only if are the 22h?

Anyway, you should declare "new stor" up

Код:
           case 4:
            {
new stor;
                new Hour, Minute, Second;
                gettime(Hour, Minute, Second);
                if (Hour==22)
                {
                    
                    stor=random(4);
                }
That compiled successfully, now to test it.


Re: Time controlled variable help - Aerotactics - 08.07.2013

It seems to be working, but further testing will have to be done, thank you guys for your help.