Jump to content

beetwen numbers problem


orcun99

Recommended Posts

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
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

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 by IIYAMA
  • Like 1
Link to comment

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 by orcun99
Link to comment
  • Moderators

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
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
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
1 hour ago, IIYAMA said:

Please use tabs in your code, I am not going to read this otherwise. :whiteblindfold:

 

tabkey.png

 

 

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
1 minute ago, MIKI785 said:

Bu girinti, bütün bu kadar çok şey yapmadı .. O.o

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...