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

Lua Math.random fail!

Reaper7

dunno wat 2 rite here
Joined
Feb 18, 2011
Messages
133
Reaction score
1
Hi there!
I'm trying to optymalize my script but it doesn't want to work propely.
This is it:
PHP:
--[[
	Script by Elff/Reaper7
	-]]
	function onUse(cid, item, fromPosition, itemEx, toPosition)
      local number = math.random(1,2)
       
   	if item.itemid == 2123 and number==1 then
            doCreatureAddHealth(cid,20) 
        	doPlayerSendTextMessage(cid,22,"Just chill out man!")
        	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        	doRemoveItem(item.uid, 1)
        	return 1
      		
				elseif number==2 then
                        
				doCreatureAddHealth(cid,20) 
             		doPlayerSendCancel(cid,22,"<Coughs> I think that drugs, aren't good for me...")
        			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        		      doRemoveItem(item.uid, 1)
 
 
      end
      return 1
end
the math.random doesn't work - it always uses the first option. Second one, hasn't been used yet. I don't now what to do, so I ask you guys, for help. :)
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition) 
    if math.random(2) == 1 then 
        doCreatureAddHealth(cid, 20)  
        doPlayerSendTextMessage(cid, 22, "Just chill out man!") 
    else     
        doCreatureAddHealth(cid, -20)  
        doPlayerSendCancel(cid, 22, "<Coughs> I think that drugs, aren't good for me...") 
    end 
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) 
    doRemoveItem(item.uid, 1) 
    return true 
end
wtf have u done with tabs :w00t:
 
Back
Top