Sistema Regali

Per la prima volta eseguiamo questa query:

Codice:
CREATE TABLE `surprisebox` (
`id`  int(5) NOT NULL AUTO_INCREMENT ,
`openorclose`  int(5) NOT NULL ,
`box1`  int(8) NULL DEFAULT NULL ,
`box2`  int(8) NULL DEFAULT NULL ,
`box3`  int(8) NULL DEFAULT NULL ,
`box4`  int(8) NULL DEFAULT NULL ,
`box5`  int(8) NULL DEFAULT NULL ,
`date`  varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ,
`hour`  varchar(20) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL ,
PRIMARY KEY (`id`)
)
ENGINE=MyISAM
DEFAULT CHARACTER SET=latin1 COLLATE=latin1_swedish_ci
AUTO_INCREMENT=47
CHECKSUM=0
ROW_FORMAT=DYNAMIC
DELAY_KEY_WRITE=0
;
Dopo eseguiamo questa query:
Codice:
INSERT INTO `surprisebox` (`openorclose`,`box1`,`box2`,`box3`,`box4`,`box5`,`date`,`hour`) VALUES (1, ITEM_ID_1, ITEM_ID_2, ITEM_ID_3, ITEM_ID_4, ITEM_ID_5, '<date>', '<hour>');
Dove c'è Item_ID_X qui inserire ID del item che volete regalare

Codice:
quest thsgiftdev begin
    state start begin
        when login begin
            cmdchat("zetsugfsys "..q.getcurrentquestindex())
        end
        
        function giverandomitem()
            local random_nr = number(1,5)
            chat("I: The box it's opening") -- Opening 
            if random_nr==1 then
                pc.give_item2(tonumber(mysql_query('SELECT box1 from player.surprisebox WHERE openorclose=1 LIMIT 1;').box1[1]))
            elseif random_nr==2 then
                pc.give_item2(tonumber(mysql_query('SELECT box2 from player.surprisebox WHERE openorclose=1 LIMIT 1;').box2[1]))
            elseif random_nr==3 then
                pc.give_item2(tonumber(mysql_query('SELECT box3 from player.surprisebox WHERE openorclose=1 LIMIT 1;').box3[1]))
            elseif random_nr==4 then
                pc.give_item2(tonumber(mysql_query('SELECT box4 from player.surprisebox WHERE openorclose=1 LIMIT 1;').box4[1]))
            elseif random_nr==5 then
                pc.give_item2(tonumber(mysql_query('SELECT box5 from player.surprisebox WHERE openorclose=1 LIMIT 1;').box5[1]))
            end
            pc.setqf("giftsystemuse", get_time()+60*60*12) -- 12 HRS  
            cmdchat("giftsyshide")
        end


        when button or info begin
            if pc.getqf("giftsystemuse") <= get_time() then
                thsgiftdev.giverandomitem() -- yeah..function -_- don't try to bind that condition with this..
            else
                chat("W: You have no gift. Try after 12 hours") -- Played 
            end
        end
    end
end
Adesso Installiamo sul Client
Apriamo game.py e cerchiamo:

Codice:
self.playerGauge = None
Dopo aggiungiamo:
Codice:
self.GiftBox = ui.Button()
self.GiftBox.SetUpVisual("d:/ymir work/ui/present.tga")
self.GiftBox.SetOverVisual("d:/ymir work/ui/present.tga")
self.GiftBox.SetDownVisual("d:/ymir work/ui/present.tga")
self.GiftBox.SetText(" ")
self.GiftBox.SetToolTipText("Open the box!")
self.GiftBox.SetPosition(10, int(wndMgr.GetScreenHeight())-126)
self.GiftBox.SetEvent(self.ZetsuGiftSystem__deff__)
self.GiftBox.Show()
Cerchiamo:
Codice:
def OnUpdate(self):
Dopo Aggiungiamo:
Codice:
 ## Z #############################################################################
        if app.IsPressed(app.DIK_P) and app.IsPressed(app.DIK_LSHIFT):
            if self.GiftBox.IsShow():
                self.GiftBox.Hide()
            else:
                self.GiftBox.Show()
        ## Z #############################################################################
Cerchiamo:
Codice:
def __ServerCommand_Build(self):
Dopo Aggiungiamo:
Codice:
## Begin LuckyBoxes system
            "zetsugfsys"                            : self.ZetsuGiftSystem__init__,
            "giftsysshow" : self.ZetsuGiftSystem__show__,
            "giftsyshide" : self.ZetsuGiftSystem__hide__,
            ## End LuckyBoxes
Infine aggiungiamo:

Codice:
## Begin LuckyBoxes system
    def ZetsuGiftSystem__init__(self, index):   
        constInfo.GIFTSYS = index # if doesn't work replace with:   constInfo.GIFTSYS = int(index) # But it's impossible
    def ZetsuGiftSystem__deff__(self):
        import event
        event.QuestButtonClick(int(constInfo.GIFTSYS))
    ## End LuckyBoxes
    # Warning!! Let the last row empty!! ##
    def ZetsuGiftSystem__show__(self):
        self.GiftBox.Show()
    def ZetsuGiftSystem__hide__(self):
        self.GiftBox.Hide()
Schiudete e salvate game.py e dopo apriamo costinfo.py

All'inizio del file aggiungiamo questo:

Codice:
GIFTSYS = 1
Questo è tutto, aggiungiamo il bottone:

Codice:
(Etc.epk/eix)D:/ymir work/ui