orcun99 Posted February 19, 2018 Share Posted February 19, 2018 client kazanmasansi = 50 ----%50 kazanma şansı ayarladım dediğin gibi değiştirebilirsin bu sayıyı function spin(source, cmd, para) local kumar = math.random(1,100) local money = getPlayerMoney(source) local para = math.min = (100) and math.max (10000) outputChatBox(para) if para > 10001 and para < 100 then outputChatBox("100-10000 arasında bir sayı gir",player) return end if (money < 999) then outputChatBox("paran yetersiz",player) return end if kumar > (100-kazanmasansi) and (money > 999) then outputChatBox("oynanıyor..",player) triggerServerEvent("moneyVer", localPlayer, para ) else triggerServerEvent("moneyAl", localPlayer, para) end end addCommandHandler("spin",spin) server function paraAl(para) for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #c80000"..para.."$ #e4e4e4kaybetti..!",player, 255,255,255,true ) end takePlayerMoney(source, para ) end addEvent("moneyAl", true) addEventHandler("moneyAl", getRootElement(), paraAl) function paraVer(para) for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #0589f9"..para.."$ #e4e4e4kazandi..!",player, 255,255,255,true ) end givePlayerMoney(source, para ) end addEvent("moneyVer", true) addEventHandler("moneyVer", getRootElement(), paraVer) para = beetwen 100-10000 I can't do this and I need timer every 10min one time use /spin command I can't do this to Link to comment
Moderators IIYAMA Posted February 19, 2018 Moderators Share Posted February 19, 2018 local para = math.random(100, 10000) 1 Link to comment
orcun99 Posted February 19, 2018 Author Share Posted February 19, 2018 Just now, IIYAMA said: local para = math.random(100, 10000) this command just select a one number for example user command : /spin 333 (333 = para and min:100 max : 10000 ) Link to comment
Moderators IIYAMA Posted February 19, 2018 Moderators Share Posted February 19, 2018 Then you do not need this: local para = math.min = (100) and math.max (10000) Only this: para = tonumber(para) 1 Link to comment
orcun99 Posted February 19, 2018 Author Share Posted February 19, 2018 Just now, IIYAMA said: Then you do not need this: local para = math.min = (100) and math.max (10000) Only this: para = tonumber(para) Thank you. but I need one more thing. I want the command to be used only once in 10 minutes. /spin you already use this command . you should wait 10min before again using this command sorry for bad england Link to comment
Moderators IIYAMA Posted February 19, 2018 Moderators Share Posted February 19, 2018 (edited) For the spin delay, use tickCount. local nextSpinTime = 0 local spinDelay = 10000 -- 10 sec -- function () local timeNow = getTickCount() if timeNow > nextSpinTime then nextSpinTime = timeNow + spinDelay -- -- You can only execute this code every 10 sec. -- else -- Not so fast... end --end Edited February 19, 2018 by IIYAMA 1 Link to comment
orcun99 Posted February 19, 2018 Author Share Posted February 19, 2018 (edited) I have some debug kazanmasansi = 50 ----%50 kazanma şansı ayarladım dediğin gibi değiştirebilirsin bu sayıyı function spin(source, cmd, para) local kumar = math.random(1,100) local money = getPlayerMoney(source) local para = tonumber(para) outputChatBox(para) if para > 10001 and para < 99 then outputChatBox("beetwen 100-10000 ",player) return end if (money < para) then outputChatBox("no enough money",player) return end if kumar > (100-kazanmasansi) and (money > para) then outputChatBox("playing..",player) triggerServerEvent("moneyVer", localPlayer, para ) else triggerServerEvent("moneyAl", localPlayer, para) end end addCommandHandler("spin",spin) server function paraAl(para) for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #c80000"..para.."$ #e4e4e4kaybetti..!",player, 255,255,255,true ) end takePlayerMoney(source, para ) end addEvent("moneyAl", true) addEventHandler("moneyAl", getRootElement(), paraAl) function paraVer(para) for _, player in ipairs(getElementsByType("player")) do outputChatBox ( getPlayerName(source).."#e4e4e4 isimli kullanici kumarda #0589f9"..para.."$ #e4e4e4kazandi..!",player, 255,255,255,true ) end givePlayerMoney(source, para ) end addEvent("moneyVer", true) addEventHandler("moneyVer", getRootElement(), paraVer) when I try /spin 202 error client side : line 8 attempt to compare number nil if (tonumber(para) > 10000) then still don't work I tried this code same error Edited February 19, 2018 by orcun99 Link to comment
ParadoxTR Posted February 19, 2018 Share Posted February 19, 2018 Try it. if tonumber(para) < 10001 and tonumber(para) > 99 then Link to comment
Moderators IIYAMA Posted February 19, 2018 Moderators Share Posted February 19, 2018 That happens when you do not fill in valid para. (which has to be a string which only contains numbers.) para = tonumber(para) -- `para` is already a local as it is a parameter. function (parameters...) if para and para > 10001 and para < 99 then -- works good! end And your bug is here: function spin(source, cmd, para) function spin(cmd, para) As it is clientside, only the localPlayer(YOU/You/you/and just you) can activate an addCommandHandler. Which means they decided to not pass the player on to the first parameter. Check wiki: https://wiki.multitheftauto.com/wiki/AddCommandHandler Serverside syntax: player playerSource, string commandName, [string arg1, string arg2, ...] Clientside syntax string commandName, [string arg1, string arg2, ...] Please do not use `source` in addCommandHandlers, it is for eventHandlers! You will only confuse yourself! Link to comment
orcun99 Posted February 20, 2018 Author Share Posted February 20, 2018 8 hours ago, IIYAMA said: That happens when you do not fill in valid para. (which has to be a string which only contains numbers.) para = tonumber(para) -- `para` is already a local as it is a parameter. function (parameters...) if para and para > 10001 and para < 99 then -- works good! end And your bug is here: function spin(source, cmd, para) function spin(cmd, para) As it is clientside, only the localPlayer(YOU/You/you/and just you) can activate an addCommandHandler. Which means they decided to not pass the player on to the first parameter. Check wiki: https://wiki.multitheftauto.com/wiki/AddCommandHandler Serverside syntax: player playerSource, string commandName, [string arg1, string arg2, ...] Clientside syntax string commandName, [string arg1, string arg2, ...] Please do not use `source` in addCommandHandlers, it is for eventHandlers! You will only confuse yourself! thank u all now scripts works as well I just need timer function for example x user first time use this command /spin 500 all done okey but second time outputChatBox("you need wait 10min before using this command again.",player) I need this after 10 mins outputChatBox("you can /spin now") Link to comment
Moderators IIYAMA Posted February 20, 2018 Moderators Share Posted February 20, 2018 I already gave you the methode to built that. You only have to edit it in terms of your needs... 1 Link to comment
orcun99 Posted February 20, 2018 Author Share Posted February 20, 2018 4 minutes ago, IIYAMA said: I already gave you the methode to built that. You only have to edit it in terms of your needs... local nextSpinTime = 0 local spinDelay = 20000*1 -- 10 sec function spin(cmd, para) local timeNow = getTickCount() local kumar = math.random(1,100) local money = getPlayerMoney(source) para = tonumber(para) if timeNow > nextSpinTime then nextSpinTime = timeNow + spinDelay outputChatBox("kodu tekrar kullanmadan önce 10dakika beklemelisin",player) else if para > 10000 then outputChatBox("100-10000 arasında bir sayı gir",player) return end if para < 100 then outputChatBox("100-10000 arasında bir sayı gir",player) return end if (money < para) then outputChatBox("paran yetersiz",player) return end if kumar > (100-kazanmasansi) and (money > para) then outputChatBox("oynanıyor..",player) triggerServerEvent("moneyVer", localPlayer, para ) else triggerServerEvent("moneyAl", localPlayer, para) end end end addCommandHandler("spin",spin) where is wrong? Link to comment
Moderators IIYAMA Posted February 20, 2018 Moderators Share Posted February 20, 2018 Please use tabs in your code, I am not going to read this otherwise. 1 Link to comment
orcun99 Posted February 20, 2018 Author Share Posted February 20, 2018 1 hour ago, IIYAMA said: Please use tabs in your code, I am not going to read this otherwise. kazanmasansi = 50 ----%50 kazanma şansı ayarladım dediğin gibi değiştirebilirsin bu sayıyı local nextSpinTime = 0 local spinDelay = 20000*1 -- 10 sec function spin(cmd, para) local timeNow = getTickCount() local kumar = math.random(1,100) local money = getPlayerMoney(source) para = tonumber(para) if timeNow > nextSpinTime then nextSpinTime = timeNow + spinDelay outputChatBox("kodu tekrar kullanmadan önce 10dakika beklemelisin",player) else if para > 10000 then outputChatBox("100-10000 arasında bir sayı gir",player) return end if para < 100 then outputChatBox("100-10000 arasında bir sayı gir",player) return end if (money < para) then outputChatBox("paran yetersiz",player) return end if kumar > (100-kazanmasansi) and (money > para) then outputChatBox("oynanıyor..",player) triggerServerEvent("moneyVer", localPlayer, para ) else triggerServerEvent("moneyAl", localPlayer, para) end end end addCommandHandler("spin",spin) Link to comment
MIKI785 Posted February 20, 2018 Share Posted February 20, 2018 That indentation didn't help all that much.. Anyway, what is the issue now? You should learn how to debug properly.. see this: https://wiki.multitheftauto.com/wiki/Debugging. 1 Link to comment
orcun99 Posted February 20, 2018 Author Share Posted February 20, 2018 1 minute ago, MIKI785 said: Bu girinti, bütün bu kadar çok şey yapmadı .. Her neyse, şimdi sorun ne? Doğru şekilde hata ayıklama yöntemini öğrenmelisiniz .. bkz . Https://wiki.multitheftauto.com/wiki/Debugging . the problem is the code I wrote above I need when user command /spin 333 all right done but I need timer if user again try command message outputChatBox("you need wait 10min to use this command") after 10min message ("you can use /spin now 10min expried") Link to comment
MIKI785 Posted February 20, 2018 Share Posted February 20, 2018 I can see that you use player and then source, but neither is defined, so they should both be nil. Link to comment
orcun99 Posted February 21, 2018 Author Share Posted February 21, 2018 13 hours ago, MIKI785 said: Oyuncu ve daha sonra kaynak kullandığını görebiliyorum , ama ikisi de tanımlanmadı, bu yüzden her ikisi de sıfır olmalı. can u edit code 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