• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Present

jestemPolakiem

New Member
Joined
Oct 17, 2009
Messages
48
Reaction score
2
Location
Poland
Present
by jestemPolakiem

script has been tested on The Forgotten Server 0.3.6pl1 and worked

mapai.png


Code:
[B]To use the script, just use a present.[/B]
I congratulate you won item! This item is ITEMNAME!
Sorry, have not won anything!

data/actions/actions.xml
PHP:
<action itemid="9074" event="script" value="9074.lua"/>

data/actions/scripts/9074.xml
PHP:
items = {
	[0] = {id = 2472, count = 1, chance = 2},
	[1] = {id = 2466, count = 1, chance = 5},
	[2] = {id = 8930, count = 1, chance = 10},
	[3] = {id = 8858, count = 1, chance = 15},
	[4] = {id = 2160, count = 10, chance = 30},
	[5] = {id = 6569, count = 50, chance = 100}
}
function onUse(cid, item, fromPos, itemEx, toPos)
	for i = 0, #items do
		if (items[i].chance > math.random(1, 100)) then
			doPlayerAddItem(cid, items[i].id, items[i].count)
			doRemoveItem(item.uid, 1)
			return doCreatureSay(cid, 'I congratulate you won item! This item is '..getItemNameById(items[i].id)..'!', TALKTYPE_MONSTER)
		end
	end
	doRemoveItem(item.uid, 1)
	return doCreatureSay(cid, 'Sorry, have not won anything!', TALKTYPE_MONSTER)
end



Greets
jestemPolakiem
 
Present
by jestemPolakiem

script has been tested on The Forgotten Server 0.3.6pl1 and worked

mapai.png


Code:
[B]To use the script, just use a present.[/B]
I congratulate you won item! This item is ITEMNAME!
Sorry, have not won anything!

data/actions/actions.xml
PHP:
<action itemid="9074" event="script" value="9074.lua"/>

data/actions/scripts/9074.xml
PHP:
items = {
	[0] = {id = 2472, count = 1, chance = 2},
	[1] = {id = 2466, count = 1, chance = 5},
	[2] = {id = 8930, count = 1, chance = 10},
	[3] = {id = 8858, count = 1, chance = 15},
	[4] = {id = 2160, count = 10, chance = 30},
	[5] = {id = 6569, count = 50, chance = 100}
}
function onUse(cid, item, fromPos, itemEx, toPos)
	for i = 0, #items do
		if (items[i].chance > math.random(1, 100)) then
			doPlayerAddItem(cid, items[i].id, items[i].count)
			doRemoveItem(item.uid, 1)
			return doCreatureSay(cid, 'I congratulate you won item! This item is '..getItemNameById(items[i].id)..'!', TALKTYPE_MONSTER)
		end
	end
	doRemoveItem(item.uid, 1)
	return doCreatureSay(cid, 'Sorry, have not won anything!', TALKTYPE_MONSTER)
end



Greets
jestemPolakiem

nice :p the text just needs to be fixed a bit i think:
congratulations you won " .. (items.id > 1 and items.count or getItemInfo(items.id).article) .. " " .. (items.count > 1 and getItemInfo(items.id).plural or getItemInfo(items.id).name) .. "!'

or something like that :p
 
nice script! it reminds me of like a scratch'n win card or a Raffle ticket except it's with a present? anyways very cool i was thinking of making a sticker board, that when you buy items at certain shops they add a sticker and if you collect 30 stickers on the board you win a random prize, but i have nowhere to begin since i suck at working with npc scripts.
 
Back
Top