xXGhostXx Posted October 19, 2018 Posted October 19, 2018 Hello everyone. I make box system and for save number box i used set account data. Command : /givebox <PlayerName> <Number> function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local tedad = tonumber(tedad) local account = getPlayerAccount(taraf) local box = getAccountData(account, tedad) local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData(taraf, account, box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) end end addCommandHandler("givebox", dadanBox) And for show number box I used get account data. function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, tedad) outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) What is problem ?! Please answer me. @iMr.WiFi..! @Dimos7
Dimos7 Posted October 19, 2018 Posted October 19, 2018 first account Data store string need string the value second
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 2 minutes ago, Dimos7 said: first account Data store string need string the value second You can help me ?
Dimos7 Posted October 19, 2018 Posted October 19, 2018 (edited) function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local tedad = tonumber(tedad) local account = getPlayerAccount(taraf) local box = getAccountData(account, tedad) local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData( account,"tedad" box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) end end addCommandHandler("givebox", dadanBox) function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) Edited October 19, 2018 by Dimos7
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 7 minutes ago, Dimos7 said: function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local tedad = tonumber(tedad) local account = getPlayerAccount(taraf) local box = getAccountData(account, tedad) local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData( account,"tedad" box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) end end addCommandHandler("givebox", dadanBox) function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) Debug error : attempt to perform arithmetic on local 'box' (a boolean value)
Dimos7 Posted October 19, 2018 Posted October 19, 2018 (edited) function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local tedad = tonumber(tedad) local account = getPlayerAccount(taraf) local box = getAccountData(account, "tedad") local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData( account,"tedad", box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) end end addCommandHandler("givebox", dadanBox) function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) Edited October 19, 2018 by Dimos7
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 3 minutes ago, Dimos7 said: function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local tedad = tonumber(tedad) local account = getPlayerAccount(taraf) local box = getAccountData(account, "tedad") local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData( account,"tedad", box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) end end addCommandHandler("givebox", dadanBox) function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) Debug error : unexpected symbol near '
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 2 minutes ago, Dimos7 said: line? function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) line : 8 Test yourself
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 1 minute ago, Dimos7 said: here is not line 8 I said on line 8 Check yourself please
Dimos7 Posted October 19, 2018 Posted October 19, 2018 2 minutes ago, xXGhostXx said: I said on line 8 Check yourself please in thath code you post have 7 lines above not 8
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 2 minutes ago, Dimos7 said: in thath code you post have 7 lines above not 8 oh ! yes ! line 7 What is problem ?
xXGhostXx Posted October 19, 2018 Author Posted October 19, 2018 1 hour ago, Dimos7 said: hmm i don't see something problem in local box !
Z4Zy Posted October 20, 2018 Posted October 20, 2018 (edited) If there's not account data called "tedad" in the account, local value called box will receive a boolean [ false ]. So, you can't set it's data in line 10 since this is a boolean. Therefore, you need to set box's value to 0 if there isn't value already exists in that, like below. Server Side :- function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local account = getPlayerAccount(taraf) local box = getAccountData(account, "tedad") or 0 local tedad = tonumber(tedad) local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData( account,"tedad", box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) end end addCommandHandler("givebox", dadanBox) function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true) end addCommandHandler("mybox", boxMan) Edited October 20, 2018 by DeadthStrock 1
xXGhostXx Posted October 20, 2018 Author Posted October 20, 2018 (edited) 4 hours ago, DeadthStrock said: If there's not account data called "tedad" in the account, local value called box will receive a boolean [ false ]. So, you can't set it's data in line 10 since this is a boolean. Therefore, you need to set box's value to 0 if there isn't value already exists in that, like below. Server Side :- function dadanBox (thePlayer, command, player, tedad) local taraf = getPlayerFromName (player) local account = getPlayerAccount(taraf) local box = getAccountData(account, "tedad") or 0 local tedad = tonumber(tedad) local esmAdmin = getPlayerName(thePlayer) local esmesh = getPlayerName(taraf) if taraf then if tedad then setAccountData( account,"tedad", box+tedad) outputChatBox("#00ff00[Done]: #ffffffShoma Be #00ff00"..esmesh.." #ffffffTedad "..tedad.." Box Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffAdmin #ffff00"..esmAdmin.." #ffffffBe Shoma #ffff00"..tedad.." #ffffffBox Dad!", taraf, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffTedad Box Ra Vared Konid!", thePlayer, 255, 255, 255, true) end else outputChatBox("#00ff00Bezan: /givebox <PartOfName> <Tedad>", thePlayer, 255, 255, 255, true) endendaddCommandHandler("givebox", dadanBox)function boxMan (thePlayer, command, tedad) local tedad = tonumber(tedad) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") outputChatBox("#00ff00Shoma #ffffff"..box.." #00ff00Box Darid!", thePlayer, 255, 255, 255, true)endaddCommandHandler("mybox", boxMan) Thanks !!!!!!!!! I LOVE YOU What is problem ?! function bazKardanBox (thePlayer, command) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") local jayeze = math.random(100000,600000) if ( getAccountData(account, "tedad") == true ) then givePlayerMoney(thePlayer, jayeze) setAccountData( account,"tedad", box-tedad) outputChatBox("#FF00FF[Pro-Box]: #ffffff"..getPlayerName(thePlayer).." Az Box Mablagh #FF00FF$"..jayeze.." #ffffffBe Dast Avord!", root, 255, 255, 255, true) else outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) end end addCommandHandler("openbox", bazKardanBox) I want when use /openbox take 1 box from account data and give Player money. and if not box the player does not give the money Edited October 20, 2018 by xXGhostXx 1
Z4Zy Posted October 20, 2018 Posted October 20, 2018 Check this out ! function bazKardanBox (thePlayer, command) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") local jayeze = math.random(100000,600000) if ( box > 0 ) then -- the variable 'box' is actually a numeric value givePlayerMoney(thePlayer, jayeze) setAccountData( account,"tedad", box-1) -- 1 will be deducted from current box amount outputChatBox("#FF00FF[Pro-Box]: #ffffff"..getPlayerName(thePlayer).." Az Box Mablagh #FF00FF$"..jayeze.." #ffffffBe Dast Avord!", root, 255, 255, 255, true) else if box == 0 then -- box amount is 0 outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) else -- when box ammount isn't exists or it's a boolean setAccountData( account,"tedad", 0) outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) end end end addCommandHandler("openbox", bazKardanBox)
xXGhostXx Posted October 20, 2018 Author Posted October 20, 2018 2 minutes ago, DeadthStrock said: Check this out ! function bazKardanBox (thePlayer, command) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") local jayeze = math.random(100000,600000) if ( box > 0 ) then -- the variable 'box' is actually a numeric value givePlayerMoney(thePlayer, jayeze) setAccountData( account,"tedad", box-1) -- 1 will be deducted from current box amount outputChatBox("#FF00FF[Pro-Box]: #ffffff"..getPlayerName(thePlayer).." Az Box Mablagh #FF00FF$"..jayeze.." #ffffffBe Dast Avord!", root, 255, 255, 255, true) else if box == 0 then -- box amount is 0 outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) else -- when box ammount isn't exists or it's a boolean setAccountData( account,"tedad", 0) outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) end endendaddCommandHandler("openbox", bazKardanBox) Why the chatBox line 11 are repeated twice?
Z4Zy Posted October 20, 2018 Posted October 20, 2018 If player's box amount is equals to zero .. then it outputs. If there isn't "tedad" value in the account, set value to 0 and it output. It wouldn't output twice a same time.
xXGhostXx Posted October 20, 2018 Author Posted October 20, 2018 2 minutes ago, DeadthStrock said: If player's box amount is equals to zero .. then it outputs. If there isn't "tedad" value in the account, set value to 0 and it output. It wouldn't output twice a same time. Which take output for simplified code ? Line 11 or 14 ?
Z4Zy Posted October 20, 2018 Posted October 20, 2018 Below one is the better one. Since it checking if account data exist before any processes. function bazKardanBox (thePlayer, command) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") local jayeze = math.random(100000,600000) if ( box and box > 0 ) then -- the variable 'box' is actually a numeric value givePlayerMoney(thePlayer, jayeze) setAccountData( account,"tedad", box-1) -- 1 will be deducted from current box amount outputChatBox("#FF00FF[Pro-Box]: #ffffff"..getPlayerName(thePlayer).." Az Box Mablagh #FF00FF$"..jayeze.." #ffffffBe Dast Avord!", root, 255, 255, 255, true) else if box == 0 then -- box amount is 0 outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) else setAccountData( account,"tedad", 0) outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) end end end addCommandHandler("openbox", bazKardanBox)
xXGhostXx Posted October 20, 2018 Author Posted October 20, 2018 1 minute ago, DeadthStrock said: Below one is the better one. Since it checking if account data exist before any processes. function bazKardanBox (thePlayer, command) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "tedad") local jayeze = math.random(100000,600000) if ( box and box > 0 ) then -- the variable 'box' is actually a numeric value givePlayerMoney(thePlayer, jayeze) setAccountData( account,"tedad", box-1) -- 1 will be deducted from current box amount outputChatBox("#FF00FF[Pro-Box]: #ffffff"..getPlayerName(thePlayer).." Az Box Mablagh #FF00FF$"..jayeze.." #ffffffBe Dast Avord!", root, 255, 255, 255, true) else if box == 0 then -- box amount is 0 outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) else setAccountData( account,"tedad", 0) outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) end end end addCommandHandler("openbox", bazKardanBox) I deleted chat box line 14, no problem ?
Z4Zy Posted October 20, 2018 Posted October 20, 2018 no problem. But, when a player command /openbox for first time, he wouldn't notify than he hadn't enough number of boxes.
xXGhostXx Posted October 20, 2018 Author Posted October 20, 2018 6 minutes ago, DeadthStrock said: no problem. But, when a player command /openbox for first time, he wouldn't notify than he hadn't enough number of boxes. I added sound for open box ! But sound played for all players ! How to add sound for the Player ? Server : function bazKardanBox (thePlayer, command) local account = getPlayerAccount(thePlayer) local box = getAccountData(account, "pBox") local jayeze = math.random(50000,300000) if ( box and box > 0 ) then triggerClientEvent("sedabox", root) givePlayerMoney(thePlayer, jayeze) setAccountData( account,"pBox", box-1) outputChatBox("#FF00FF[Pro-Box]: #ffffff"..getPlayerName(thePlayer).." Az Box Mablagh #FF00FF$"..jayeze.." #ffffffBe Dast Avord!", root, 255, 255, 255, true) else if box == 0 then outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) else setAccountData( account,"pBox", 0) outputChatBox( "#ff0000[Error]: #ffffffShoma Box Nadarid!", thePlayer, 255, 0, 0,true ) end end end addCommandHandler("openbox", bazKardanBox) Client : addEvent("sedabox",true) addEventHandler("sedabox",getRootElement(),function() local sound = playSound("Data/box.wav") setSoundVolume(sound, 5.0) end)
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