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

doPlayerAddItem(cid, RANDOM ITENZ PLZ)

richux

Tibera.org
Joined
Aug 18, 2008
Messages
3,666
Reaction score
26
Location
---------
Okey, I bet this is deadly simple, but I haven't yet managed how to do it.

I got a script that gives player reward, smth like(just a silly sample):

Code:
if blablabla then
rewardplayer
end

I want that "rewardplayer" would be random. Sometimes it would add items, sometimes experience etc.

thank you
 
Code:
	local t = {
		items = {2499, 2500, 2501},
		exp = 10000
	}
	local v = math.random(1, 3)
	if v < 3 then
		doPlayerAddItem(cid, t.items[math.random(#t.items)], 1)
	else
		doPlayerAddExp(cid, t.exp)
	end
 
thx to you it will add random items now and that's really great, thu I still don't understand how to include possibility of experience S;

LUA:
local temple = {x=3000, y=2998, z=7}

local t = {
	items = {2499, 2500, 2501},
	exp = 10000
}
local v = math.random(1, 3)
local config = {
	arena = {
		frompos = {x = 2792, y = 2891, z =7},
		topos = {x = 2822, y = 2909, z=7}
	}
}


	
  function onPrepareDeath(cid, deathList)
  lastHitKiller = deathList[1]
        if(	isMonster(lastHitKiller) and isPlayer(cid)) then
			if (getCreatureName(lastHitKiller) == "Apocalypse") then
				if #getPlayersfromArea(config.arena.frompos, config.arena.topos) == 1 then
				doTeleportThing(cid, temple)
				doSendMagicEffect(getCreaturePosition(cid),10)
				doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Congratulations, you won! Enjoy your reward!")
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
				doPlayerAddItem(cid, t.items[math.random(#t.items)], 1)
				else
				doTeleportThing(cid, temple)
				doSendMagicEffect(getCreaturePosition(cid),10)
				doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You got owned!")
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
				return false
				end
			end
		elseif(isPlayer(lastHitKiller) and isPlayer(cid)) and (isInRange(getCreaturePosition(cid), config.arena.frompos, config.arena.topos)) then
				doTeleportThing(cid, temple)
				doSendMagicEffect(getCreaturePosition(cid),10)
				doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You got owned!")
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
				return false
        end
        return false
end
 
Code:
local temple =  {x=3000, y=2998, z=7}

local t = {
	items = {2499, 2500, 2501},
	exp = 10000
}
local config = {
	arena = {
		frompos = {x = 2792, y = 2891, z =7},
		topos = {x = 2822, y = 2909, z=7}
	}
}

function onPrepareDeath(cid, deathList)
	if (isMonster(deathList[1]) and isPlayer(cid)) then
		if (getCreatureName(deathList[1]) == "Apocalypse") then
			if #getPlayersfromArea(config.arena.frompos, config.arena.topos) == 1 then
				doTeleportThing(cid, temple)
				doSendMagicEffect(getCreaturePosition(cid),10)
				doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Congratulations, you won! Enjoy your reward!")
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
				local v = math.random(1, 3)
				if v < 3 then
					doPlayerAddItem(cid, t.items[math.random(#t.items)], 1)
				else
					doPlayerAddExp(cid, t.exp)
				end
			else
				doTeleportThing(cid, temple)
				doSendMagicEffect(getCreaturePosition(cid),10)
				doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You got owned!")
				doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
				return false
			end
		end
	elseif isPlayer(deathList[1]) and isPlayer(cid) and isInRange(getCreaturePosition(cid), config.arena.frompos, config.arena.topos) then
		doTeleportThing(cid, temple)
		doSendMagicEffect(getCreaturePosition(cid),10)
		doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You got owned!")
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid), CONST_ME_MAGIC_BLUE, TEXTCOLOR_BLUE, true)
		return false
	end
	return false
end
 
Back
Top