• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

creatuescript help

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
247
Solutions
1
Reaction score
40
Location
Ankrahmun
hi guys, i have a problem and need to fix it
its a script that gives a random reward to a random player who have a storage X
i dont know how to complete it -,- thx

function onThink(cid, interval)
if getStorage(storage) == 1 then --going to select winner
doSetStorage(storage, -1) --now event is off

for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, storage) == 0 then --these are players in event
local winner = math.random(#cid) --random player from event
local prize = math.random(#rewardID) --random prize from all prizes id
doPlayerAddItem(winner, [prize], 1)
doCreatureSetStorage(cid, storage, -1)

return true
end

end
end
return true
end
 
Not trying to be rude at all but this is really where you should start, or a tutorial that best suits you and your native language.

There's a ton of issues with this script, and if you want someone to create this script for you then you should post it in the requests board.

Also, read through this to learn how to make sure your threads are useful enough so someone can actually help you. Like including your TFS and client version, and using code tags, which are few of many rules that are needed to find the support you need.
Rules for the Support board

Lastly, I will try to point out what you're doing wrong as much as I can for now.
- onThink doesn't use cid as a parameter
- getStorage isn't a function (unless you're using a distro I've never seen)
- Variable 'storage' isn't defined anywhere in your script. You need something like:
LUA:
local storage = 32745
- #cid won't work because cid is an id not a table and # looks to find the size of a table.
- Variable 'rewardID' needs to be defined as a table somewhere with all the item id's that you want to be used as a random reward. For instance:
LUA:
local rewardID = {2512, 2513, 2514}
 
Back
Top