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

Action Piggy Bank and soul orb

Erikas Kontenis

Board Moderator
Staff member
Board Moderator
Joined
Jul 3, 2009
Messages
1,859
Reaction score
557
Location
Lithuania
hello its pretty easy scripts but the idea i thinking is pretty good for rpg servers :)

piggybank.lua
Lua:
local coin = {2148}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local count = 1
	if item.itemid == 2114 then
		local randomChance = math.random(1)
		if randomChance == 1 then
			count = math.random(1,100)
		elseif randomChance == 2 then
			count = 3
		end
		doPlayerAddItem(cid, coin[randomChance], count)
	end
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doTransformItem(item.uid, 2115)
	return TRUE
end

soul orb.lua

Lua:
local coin = {2148}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local count = 1
	if item.itemid == 5944 then
		local randomChance = math.random(1)
		if randomChance == 1 then
			count = math.random(1,100)
		elseif randomChance == 2 then
			count = 3
		end
		doPlayerAddItem(cid, coin[randomChance], count)
	end
	doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
	doRemoveItem(item.uid, 1)
	return TRUE
end


i hope us like it and wont forget to rep me :D


Tested on 0.2.5 and 0.3.5
 
Good for RPG servers? Wouldn't say so.
By the looks of the first script, it makes no sense:
Lua:
	local count = 1
"ok", but what's this:
Lua:
		local randomChance = math.random(1)
		if randomChance == 1 then
			count = math.random(1,100)
		elseif randomChance == 2 then
			count = 3
		end
math.random(1) will always result in 1, which will set count to a random number between 1 and 100 afterwards.. "ok"

But what about this:
Lua:
		doPlayerAddItem(cid, coin[randomChance], count)
coin is array, but it only has 1 value .. so what's the point of making it an array?

I think you wanted to make something like this:
Lua:
local coin = 2148

function onUse(cid, item, fromPosition, itemEx, toPosition)
	doPlayerAddItem(cid, coin, math.random(3) == 1 and math.random(100) or 1)
	doSendMagicEffect(toPosition, CONST_ME_GIFT_WRAPS)
	doTransformItem(item.uid, 2115)
	return TRUE
end
soul orb.lua is also pointless and both could share the same script.
 
Last edited:
Lua:
  local coin = 2148

function onUse(cid, item, fromPosition, itemEx, toPosition)
        doPlayerAddItem(cid, coin, math.random(3) == 1 and math.random(100) or 1)
        doSendMagicEffect(toPosition, CONST_ME_GIFT_WRAPS)
        doTransformItem(item.uid, 2115)
        return TRUE
end

not works it just allways giving 1 gold coin :p
 
Lua:
  local coin = 2148

function onUse(cid, item, fromPosition, itemEx, toPosition)
        doPlayerAddItem(cid, coin, math.random(3) == 1 and math.random(100) or 1)
        doSendMagicEffect(toPosition, CONST_ME_GIFT_WRAPS)
        doTransformItem(item.uid, 2115)
        return TRUE
end

not works it just allways giving 1 gold coin :p
You gotta be really unlucky.

27yu8n8.gif


Anyway, here's a script closer to the real one:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local random = math.random(4)
	doSendMagicEffect(toPosition, random == 1 and CONST_ME_BLOCKHIT or CONST_ME_SOUND_YELLOW)
	doPlayerAddItem(cid, random == 1 and ITEM_GOLD_COIN or ITEM_PLATINUM_COIN, 1)
	return TRUE, (random == 1 and doTransformItem(item.uid, 2115))
end
 
Back
Top