Time controlled variable help
#1

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;
                }
            }
Reply
#2

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

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;
                }
Reply
#4

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

Reply
#5

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.
Reply
#6

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);
                }
Reply
#7

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.
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)