Guten Tag,
ich habe gestern die Slotmachine Fruits by ProfEnte eingefügt,
diese geht auch !
Das man mit Coins Spielen kann geht auch (Coins werden abgezogen und gegeben)
Jetzt zu meinem Problem.
Die Coins die man hat werden nicht angezeigt sondern nur das Yang (Credits)
Was muss ich ändern damit meine Coins angezeigt werden? (Mysql Spalte: coins_IS)
Bitte melden Sie sich an, um dieses Bild zu sehen.
Quest
Code
- quest slotmachine begin
- --- Autoplay Button
- --- Algo ueberlegen fuers gewinnen, sonst gewinnt man ja nie..
- state start begin
- when login begin
- cmdchat("SLOTMACHINE QID/"..q.getcurrentquestindex())
- end
- when 6412.chat."Slotmachine" begin
- cmdchat('SLOTMACHINE OPEN/'..SLOTMACHINE.MULTIPLIERS[9]..'#'..SLOTMACHINE.MULTIPLIERS[8]..'#'..SLOTMACHINE.MULTIPLIERS[7]..'#'..SLOTMACHINE.MULTIPLIERS[6]..'#'..SLOTMACHINE.MULTIPLIERS[5]..'#'..SLOTMACHINE.MULTIPLIERS[4]..'#'..SLOTMACHINE.MULTIPLIERS[3]..'#'..SLOTMACHINE.MULTIPLIERS[2]..'#'..SLOTMACHINE.MULTIPLIERS[1]..'/'..SLOTMACHINE.MAX_BET)
- setskin(NOWINDOW)
- end
- when button begin
- local cmd = slotmachine.client_command(getinput("SLOTMACHINE QUESTCMD"))
- if cmd[1] == 'GET_WINNING_ICONS' then
- local credits,slot = 0,{}
- if SLOTMACHINE.TAB_WIN_MODE then
- slot = slotmachine.tab_win_mode_check()
- else
- slot = {number(1,9),number(1,9),number(1,9)}
- end
- cmdchat('SLOTMACHINE SETSLOTICONS/'..(slot[1]-1)..'#'..(slot[2]-1)..'#'..(slot[3]-1))
- if slotmachine.check_multipliers(slot[1],slot[2],slot[3]) then
- credits = pc.getqf('BET')*SLOTMACHINE.MULTIPLIERS[slot[1]]
- pc.change_coins_IS(credits)
- notice_all('Glückwunsch '..pc.get_name()..' du hast '..credits..' Coins gewonnen!')
- else
- syschat('')
- end
- cmdchat('SLOTMACHINE SETCREDITSWON/'..credits)
- elseif cmd[1] == 'BET' then
- local bet = tonumber(cmd[2])
- if bet > pc.get_coins_IS() then return syschat'Error.' end
- if bet > SLOTMACHINE.MAX_BET then return syschat'Error' end
- pc.change_coins_IS(-bet)
- pc.setqf('BET',bet)
- cmdchat('SLOTMACHINE SPIN')
- end
- end
- function random_three_tab()
- while true do
- local r = {number(1,9),number(1,9),number(1,9)}
- if r[1] != r[2] and r[2] != r[3] then
- return r
- end
- end
- end
- function tab_win_mode_check()
- local tab = {
- {1,1,1},
- {2,2,2},
- {3,3,3},
- {4,4,4},
- {5,5,5},
- {6,6,6},
- {7,7,7},
- {8,8,8},
- {9,9,9},
- slotmachine.random_three_tab(),
- }
- local r = number(1,100)
- local winningTab = tab[10]
- for i = 1, table.getn(SLOTMACHINE.TAB_WIN_MODE_CHANCE) do
- if r <= SLOTMACHINE.TAB_WIN_MODE_CHANCE[i] then
- winningTab = tab[i]
- end
- end
- return winningTab
- end
- function check_multipliers(i1,i2,i3)
- if i1 == i2 and i2 == i3 then
- return i1
- end
- end
- function client_command(command_)
- return slotmachine.split_(command_,"#")
- end
- function split_(string_,delimiter)
- local result = { }
- local from = 1
- local delim_from, delim_to = string.find( string_, delimiter, from )
- while delim_from do
- table.insert( result, string.sub( string_, from , delim_from-1 ) )
- from = delim_to + 1
- delim_from, delim_to = string.find( string_, delimiter, from )
- end
- table.insert( result, string.sub( string_, from ) )
- return result
- end
- end
- end
Python
Python
- import ui
- import time
- import player
- import constInfo
- import chat
- import event
- from random import randrange
- delay = 0.1
- autoSpinDelay = 1.5
- spinTimesUntilQuestEvent = 75
- class Slotmachine(ui.ScriptWindow):
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.isLoaded = FALSE
- ##################################
- ## Create Ui Begin
- ##################################
- def __LoadScript(self):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, 'uiscript/slotmachine.py')
- except:
- import exception
- exception.Abort('test.__LoadScript.LoadObject')
- try:
- self.__LoadVariables()
- self.__LoadUi()
- self.__BindEvents()
- except:
- import exception
- exception.Abort('test.__LoadScript.BindObject')
- self.isLoaded = TRUE
- def __LoadVariables(self):
- slotmachinePath = "locale/de/ui/slotmachine/"
- self.slotIcons = [
- slotmachinePath + 'Cherry.sub',
- slotmachinePath + 'Lemon.sub',
- slotmachinePath + 'Orange.sub',
- slotmachinePath + 'Plum.sub',
- slotmachinePath + 'Melon.sub',
- slotmachinePath + 'Banana.sub',
- slotmachinePath + 'Bar.sub',
- slotmachinePath + 'Seven.sub',
- slotmachinePath + 'BigWin.sub'
- ]
- self.spin = {
- 'time' : 0,
- 'index' : [0,0,0],
- 'count' : 0,
- 'run' : FALSE,
- 'autoSpin' : FALSE,
- }
- def __LoadUi(self):
- self.board = self.GetChild('Board')
- self.titleBar = self.GetChild('TitleBar')
- ## Buttons
- self.buttonDict = {
- 'spin' : self.GetChild('SB_Spin_Button'),
- 'betMax' : self.GetChild('SB_BetMax_Button'),
- 'autoSpin' : self.GetChild('SB_AutoSpin_Button'),
- }
- ## Slots
- self.slotBoxDict = {
- 'slot_0' : self.GetChild('SM_Box_00'),
- 'slot_1' : self.GetChild('SM_Box_01'),
- 'slot_2' : self.GetChild('SM_Box_02'),
- }
- self.maxBetLabel = self.GetChild('SC_Box_01_Text_Label')
- ## Multiplier Ui
- self.multiplierDict = {
- 'text_0' : self.GetChild('SWM_Box_00_Text'),
- 'text_1' : self.GetChild('SWM_Box_01_Text'),
- 'text_2' : self.GetChild('SWM_Box_02_Text'),
- 'text_3' : self.GetChild('SWM_Box_03_Text'),
- 'text_4' : self.GetChild('SWM_Box_04_Text'),
- 'text_5' : self.GetChild('SWM_Box_05_Text'),
- 'text_6' : self.GetChild('SWM_Box_06_Text'),
- 'text_7' : self.GetChild('SWM_Box_07_Text'),
- 'text_8' : self.GetChild('SWM_Box_08_Text'),
- }
- ## Credits Ui
- self.creditsDict = {
- 'text_0' : self.GetChild('SC_Box_00_Text'),
- 'text_1' : self.GetChild('SC_Box_01_Text'),
- 'text_2' : self.GetChild('SC_Box_02_Text'),
- }
- def __BindEvents(self):
- self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
- ## Button Events
- self.buttonDict['spin'].SetEvent(self.OnClickSpin)
- self.buttonDict['betMax'].SetEvent(self.OnClickBetMax)
- self.buttonDict['autoSpin'].SetEvent(self.OnClickAutoSpin)
- ##################################
- ## Create Ui End
- ##################################
- ##################################
- ## Standart definitions Begin
- ##################################
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def Destroy(self):
- self.Hide()
- self.ClearDictionary()
- def Open(self, multipliers, maxBet):
- if FALSE == self.isLoaded:
- self.__LoadScript()
- self.SetTop()
- self.Show()
- self.maxBetLabel.SetText('Bet / Max = ' + maxBet)
- self.SetMultipliers(multipliers)
- self.SetCreditsWon(0)
- ## set credits bet = 0
- self.creditsDict['text_1'].SetText('0')
- self.maxBet = int(maxBet)
- self.creditsDict['text_1'].SetMax(self.maxBet)
- def Close(self):
- self.Hide()
- def SendSystemChat(self, text):
- chat.AppendChat(chat.CHAT_TYPE_INFO, "<System>: "+str(text))
- ##################################
- ## Standart definitions End
- ##################################
- ##################################
- ## On Click/Press Key Events Begin
- ##################################
- def OnClickSpin(self):
- if self.spin['run'] == FALSE:
- ## has enough money to spin?
- creditsInput = int(self.creditsDict['text_1'].GetText())
- maxBet = self.maxBet
- if creditsInput > maxBet:
- self.SendSystemChat('Der Max Bet Betrag liegt bei: '+str(maxBet)+' Credits.')
- #self.SendSystemChat('You do not have enough credits.')
- return
- if player.GetElk() < creditsInput:
- self.SendSystemChat('Du besitzt nicht genuegend Credits.')
- #self.SendSystemChat('You do not have enough credits.')
- return
- if creditsInput <= 0:
- self.SendSystemChat('Gib bitte mehr wie 0 Credits ein.')
- #self.SendSystemChat('Please input more than 0 credits')
- return
- self.SendCreditsBet()
- def OnClickAutoSpin(self):
- if self.spin['autoSpin'] == TRUE:
- self.spin['autoSpin'] = FALSE
- self.SendSystemChat('Auto Spin deaktiviert!')
- #self.SendSystemChat('Auto spin deactivated!')
- else:
- self.spin['autoSpin'] = TRUE
- self.SendSystemChat('Auto Spin aktiviert!')
- #self.SendSystemChat('Auto spin activated!')
- def OnClickBetMax(self):
- maxBet = self.maxBet
- if player.GetElk >= maxBet:
- self.creditsDict['text_1'].SetText(str(maxBet))
- else:
- self.SendSystemChat('Du besitzt nicht genuegend Credits.')
- #self.SendSystemChat('You do not have enough credits.')
- def OnPressEscapeKey(self):
- self.Close()
- return TRUE
- def OnPressExitKey(self):
- self.Close()
- return TRUE
- ##################################
- ## On Click/Press Key Events End
- ##################################
- ##################################
- ## Quest send Begin
- ##################################
- def GetWinningIcons(self):
- self.QuestCMD('GET_WINNING_ICONS')
- def SendCreditsBet(self):
- self.QuestCMD('BET#'+self.creditsDict['text_1'].GetText())
- def QuestCMD(self, command):
- constInfo.SLOTMACHINE["questCMD"] = command
- event.QuestButtonClick(int(constInfo.SLOTMACHINE["qid"]))
- ##################################
- ## Quest send End
- ###################################
- ##################################
- ## Quest receive complete Begin
- ##################################
- ## set multipliers (9)
- def SetMultipliers(self, multiplierList):
- multiplierList = multiplierList.split('#')
- ## set multipliers
- for i in range(len(multiplierList)):
- self.multiplierDict['text_'+str(i)].SetText('X'+multiplierList[i])
- ## stop spinning and set slot icons on quest receive complete (3)
- def SetSlotIcons(self, slotList):
- self.spin['run'] = FALSE
- self.spin['count'] = 0
- slotList = slotList.split('#')
- ## set new icons
- for i in range(len(slotList)):
- self.slotBoxDict['slot_'+str(i)].LoadImage(self.slotIcons[int(slotList[i])])
- ## check for auto spin
- if self.spin['autoSpin'] == TRUE:
- self.spin['time'] = float(time.clock()) + float(autoSpinDelay)
- self.OnClickSpin()
- ## set credits won on quest receive complete
- def SetCreditsWon(self, credits):
- self.creditsDict['text_2'].SetText(str(credits))
- ## update player credits (yang) on quest receive complete
- def SetCredits(self):
- self.creditsDict['text_0'].SetText(str(player.GetElk()))
- def OnReceiveCanSpin(self):
- self.spin['run'] = TRUE
- self.SetCreditsWon(0)
- ##################################
- ## Quest End
- ##################################
- ##################################
- ## Spin Begin
- ##################################
- def OnUpdate(self):
- ## is max bet more than allowed?
- creditInput = self.creditsDict['text_1'].GetText()
- if creditInput != "":
- if int(creditInput) > self.maxBet:
- self.creditsDict['text_1'].SetText(str(self.maxBet))
- ## update ingame credits (yang)
- self.SetCredits()
- ## spinning process
- if self.spin['run'] == TRUE:
- ## check spin delay
- if float(self.spin['time']) < float(time.clock()):
- ## go through all three slot boxes
- for i in range(3):
- slotIconsLen = len(self.slotIcons)
- index = randrange(0,slotIconsLen-1)
- ## avoid two times in a row the same icon
- while index == self.spin['index'][i]:
- index = randrange(0,slotIconsLen-1)
- self.spin['index'][i] = index
- ## set new slot icon's
- self.slotBoxDict['slot_' + str(i)].LoadImage(self.slotIcons[index])
- self.spin['time'] = float(time.clock()) + float(delay)
- ## get winning icons if spinning time is equal spinTimesUntilQuestEvent
- if spinTimesUntilQuestEvent == self.spin['count']:
- self.GetWinningIcons()
- self.spin['count'] += 1
- ##################################
- ## Spin End
- ##################################
Vielen Dank schon mal ich hoffe ihr könnt mir helfen