P[ow]er Posted February 27, 2016 Share Posted February 27, 2016 hello everybody i have problem with bet systeme, when anybody playing bet on any player and if this player win bet , system doesn't give the money to the player... where is the problem ? function createNewBet(thePlayer,toPlayer,newAmount,oldAmount,betState) local account = getPlayerAccount(thePlayer) if not (isGuestAccount(account)) then if getPlayerCount() >= minPlayers then if bettingEnabled == true then if (betState == 0) then if (toPlayer) then if (newAmount) then local newAmount = tonumber(math.ceil(tonumber(newAmount))) if (newAmount >= 1) then local playerCash = tonumber(getAccountData(account,"cash")) local maxBet = 10000 if (findPlayerByName(toPlayer)) then local toPlayerName = findPlayerByName(toPlayer) if (newAmount <= playerCash) then if newAmount <= maxBet then callClientFunction(thePlayer,"addNewBet",toPlayerName,newAmount) setAccountData(account,"cash",playerCash-newAmount) scoreboardRefresh(thePlayer) totalBetsAdd(thePlayer) --outputChatBox("#00FF00* #FFFFFFYou have placed your bet on "..getPlayerName(toPlayerName).."#FFFFFF for #ABCDEF$"..newAmount.."#FFFFFF!",thePlayer,255,255,255,true) outputChatBox(""..colorCode.."[bET] #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has placed a bet on "..getPlayerName(toPlayerName).."#FFFFFF for #ABCDEF$"..newAmount.."#FFFFFF!",getRootElement(),255,255,255,true) elseif newAmount > maxBet then outputChatBox(""..colorCode.."[bET] #FFFFFFYou are allowed to bet a maximum of #ABCDEF$"..maxBet.."#FFFFFF!",thePlayer,255,255,255,true) return false end else outputChatBox(""..colorCode.."[bET] #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true) end else outputChatBox(""..colorCode.."[bET] #FFFFFFERROR! The player you specified has not been found! (#FFFF00"..toPlayer.."#FFFFFF)",thePlayer,255,255,255,true) return false end else outputChatBox(""..colorCode.."[bET] #FFFFFFERROR! Invalid amount! [#ABCDEF$"..newAmount.."#FFFFFF]",thePlayer,255,255,255,true) end else outputChatBox(""..colorCode.."[bET] #FFFFFFERROR! Please specify an amount to bet! Correct syntax: #ABCDEF/bet [player] [amount]",thePlayer,255,255,255,true) return false end else outputChatBox(""..colorCode.."[bET] #FFFFFFERROR! Please specify a player! Correct syntax: #ABCDEF/bet [player] [amount]",thePlayer,255,255,255,true) return false end else outputChatBox(""..colorCode.."[bET] #FFFFFFYou have already placed your bet on "..betState.." #FFFFFFfor #ABCDEF$"..oldAmount.."#FFFFFF!",thePlayer,255,255,255,true) return false end else outputChatBox(""..colorCode.."[bET] #FFFFFFBetting time is over! You can place your bet on the next map.",thePlayer,255,255,255,true) end else outputChatBox(""..colorCode.."[bET] #FFFFFFBetting #dd1111disabled.#FFFFFF Minimum required players on server: #ABCDEF" ..minPlayers..""..colorCode.." | #FFFFFFConnected: #ABCDEF"..getPlayerCount(),thePlayer,255,255,255,true) end else outputChatBox(""..colorCode.."[bET] #FFFFFFYou have to be logged to bet!",thePlayer,255,255,255,true) end end function onPlayerBetWin(self,betAmount) local thePlayer = self local account = getPlayerAccount(thePlayer) if not (isGuestAccount(account)) then outputChatBox(""..colorCode.."[bET] #FFFFFF"..getPlayerName(self).."#FFFFFF has won his bet and has recieved #ABCDEF$".. betAmount*2 .."#FFFFFF!",getRootElement(),255,255,255,true) local playerCash = getAccountData(account,"cash") setAccountData(account,"cash",playerCash+betAmount+betAmount*2) totalBetsWonAdd(thePlayer) scoreboardRefresh(thePlayer) end end Link to comment
EstrategiaGTA Posted February 28, 2016 Share Posted February 28, 2016 Anything in debugscript 3? Link to comment
Mann56 Posted February 28, 2016 Share Posted February 28, 2016 Instead of setAccountData(account,"cash",playerCash+betAmount+betAmount*2) You can just use givePlayerMoney(thePlayer,playerCash+betAmount+betAmount*2) Link to comment
1LoL1 Posted February 28, 2016 Share Posted February 28, 2016 Instead of setAccountData(account,"cash",playerCash+betAmount+betAmount*2) You can just use givePlayerMoney(thePlayer,playerCash+betAmount+betAmount*2) He used in all setAccountData so why givePlayerMoney? and setAccountData data is saved in account. Link to comment
Mann56 Posted February 28, 2016 Share Posted February 28, 2016 Instead of setAccountData(account,"cash",playerCash+betAmount+betAmount*2) You can just use givePlayerMoney(thePlayer,playerCash+betAmount+betAmount*2) He used in all setAccountData so why givePlayerMoney? and setAccountData data is saved in account. Set Account Data wont increase his money you can use it just to store things. Link to comment
ozulus Posted February 28, 2016 Share Posted February 28, 2016 He used in all setAccountData so why givePlayerMoney? and setAccountData data is saved in account. Set Account Data wont increase his money you can use it just to store things. Ah c'mon man, this script is using in race gamemode with custom cash system. So cash saved on player's account. ON TOPIC: Please give handler of onPlayerBetWin function. Maybe there is error with addEventHandler. Link to comment
Mann56 Posted February 28, 2016 Share Posted February 28, 2016 He used in all setAccountData so why givePlayerMoney? and setAccountData data is saved in account. Set Account Data wont increase his money you can use it just to store things. Ah c'mon man, this script is using in race gamemode with custom cash system. So cash saved on player's account. ON TOPIC: Please give handler of onPlayerBetWin function. Maybe there is error with addEventHandler. Ah, my bad.... Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now