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

Solved How to make random set values?

Siegh

Thronar Developer
Joined
Mar 12, 2011
Messages
1,282
Solutions
1
Reaction score
645
Location
Brazil
I know you can make random values like this for instance:

Code:
math.random(1,100)

But how to make a random that works only with certain numbers? For instance, Id want a script to randomize between some item IDs, like 1540 or 1753 or 11235.

Is this possible?
 
It works but, if I use the action with the script repeteadly, it will always give me the same item that seems to change each time I reload it. Thoughts?
 
It works but, if I use the action with the script repeteadly, it will always give me the same item that seems to change each time I reload it. Thoughts?

That's because it depends where you put this piece of code in the script. It has to be inside the function, not global (before the function). If you put it global, it will load values only when you run the server and won't change them anymore.
 
That's because it depends where you put this piece of code in the script. It has to be inside the function, not global (before the function). If you put it global, it will load values only when you run the server and won't change them anymore.

My bad for not noticing it, it works 100% now!

Thanks you both :)
 
Fix It guys He get to me Error In Engine


-- function SendAnmi(cid)
-- stone_pos={x=562,y=1591,z=8,stackpos=1}
-- num = getGlobalStorageValue(98575)
-- stone = getThingfromPos(stone_pos)
-- if stone.itemid == 6966 then
-- --if num>0 then
-- -- setGlobalStorageValue(98575, -1)
-- -- end
-- else


-- num = num -1
-- n = num + 17
-- doSendAnimatedText(stone_pos, "".. n .."", TEXTCOLOR_RED)
-- if num == 0 then
-- num=17
-- end
-- setGlobalStorageValue(98575, num)

-- end
-- end




function onStepIn(cid, item, pos)
pos1={x=556,y=1580,z=8,stackpos=1}
pos2={x=568,y=1589,z=8,stackpos=1}
stone_pos={x=562,y=1591,z=8,stackpos=1}
stone = getThingfromPos(stone_pos)
local found = nil
local player=nil
for arenax = pos1.x, pos2.x do
for arenay = pos1.y, pos2.y do
for sp=0,253 do
arenapos = {x=arenax, y=arenay, z=pos1.z, stackpos=sp}
slain1 = getThingfromPos(arenapos)

if slain1.itemid == 3028 then
found = true
x=slain1.duration

end
end
end
end



if found and stone.itemid == 6966 then
doRemoveItem(stone.uid,1)
doSendMagicEffect(stone_pos, 41)

for arenax = pos1.x, pos2.x do
for arenay = pos1.y, pos2.y do
for sp=0,253 do
arenapos = {x=arenax, y=arenay, z=pos1.z, stackpos=sp}
slain1 = getThingfromPos(arenapos)

if slain1.itemid == 3028 then


for x = 1, 15 do

end
end
end
end
end
end


if found ~=true and stone.itemid ~= 6966 then
doCreateItem(cid,6966,1,stone_pos)
doSendMagicEffect(stone_pos, 43)
end

end
 
Back
Top