iRack Posted June 19, 2019 Posted June 19, 2019 Hi! Can someone help me to solve this problem? Problem : [2019-06-19 17:29:06] ERROR: boxcreated\server.Lua:52: bad argument #2 to 'random' (interval is empty) [2019-06-19 17:29:06] ERROR: boxcreated\server.Lua:57: bad argument #1 to 'random' (number expected, got table) Quote if hit and getElementType(hit) == "player" then local reward = math.random(100) if reward >= settings.possibility[1] then local weapon,ammo = settings.weaponIDs[math.random(#settings.weaponIDs)],math.random(settings.ammoCount[1],settings.ammoCount[2]) giveWeapon(hit,weapon,ammo) -- oyuncuya silah ver outputChatBox(getPlayerName(hit).." #FFFFFFfound the gift box and won #FF0000"..getWeaponNameFromID(weapon).." ("..ammo.." ammo) #FFFFFF$ Congratulations!",root,255,255,255,true) -- outputChatBox(getPlayerName(hit).." #FFFFFFfound the gift box and won #00FF00"..getWeaponNameFromID(weapon).." ("..ammo.." ammo)",root,255,255,255,true) else local money = math.random(settings.cashCount[1],settings.cashCount[2]) givePlayerMoney(hit,money) -- oyuncuya para ver outputChatBox(getPlayerName(hit).." #FFFFFfound the gift box and won #FF0000"..money.."#FFFFFF$ Congratulations!",root,255,255,255,true) -- outputChatBox(getPlayerName(hit).." #FFFFFFfound the gift box and won #00FF00"..money.."#FFFFFF$",root,255,255,255,true) end local premium = math.random(settings.premiumCount) aclGroupAddObject(aclGetGroup("Premium"), "user."..accountName) outputChatBox(getPlayerName(hit).." #FFFFFfound the gift box and won #FF0000"..premium.."#FFFFFF$ Congratulations!",root,255,255,255,true) -- outputChatBox(getPlayerName(hit).." #FFFFFFfound the gift box and won #00FF00"..getWeaponNameFromID(weapon).." ("..ammo.." ammo)",root,255,255,255,true) else if settings.health_armor then setElementHealth(hit,100) setPedArmor(hit,100) end outputChatBox("No hidden gift box found :(",root,255,0,0,true) -- outputChatBox("No hidden gift box found :(",root,255,0,0,true) end setTimer(destroyElement,1500,1,secretBox) removeEventHandler("onColShapeHit",col,stopSearch) destroyElement(col) secretBox = nil col = nil triggerClientEvent("secretBox:stopRender",resourceRoot,hit) outputChatBox("The next gift box will be create in "..settings.createTime.." minutes.",root,0,255,0,true) -- outputChatBox("The next gift box will be create in "..settings.createTime.." minute.",root,0,255,0,true) createTimer = setTimer(createSecretBox,settings.createTime*60000,1) end end 52 is: local money = math.random(settings.cashCount[1],settings.cashCount[2]) 57 is: local premium = math.random(settings.premiumCount) and: Quote settings = { createTime = 160, -- create time (minute) searchTime = 5, -- time to search (minute) (disappear when the time expires) weaponIDs = {22,23,24,25,26,27,28,29,30,31,32}, -- weapon ids ammoCount = {30,60,90}, -- minAmmo,maxAmmo cashCount = {3000,1000}, -- minCash,maxCash premiumCount = {1}, possibility = {20,30,50}, -- money,weapon (default: %70 money, %30 weapon, %50 premium acc) objectID = 1347, -- box object health_armor = true, -- when player find the secret box give health and armor? command = "createBox", -- create secret box command } Help please ?
DNL291 Posted June 20, 2019 Posted June 20, 2019 line 57 is returning a table. Debug these values with iprint: iprint( settings.cashCount ) iprint( settings.premiumCount ) If you aren't able to fix it show us the whole code. Please do not PM me with scripting related question nor support, use the forums instead.
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