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

Lua Script help

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
I was trying to make a script but i got stuck in the first part of it i hope someone can help me.

I want to get item id in item place and if that item id is in array of wepaon type 1,2,3 and get gem id in gem place = config.Dgem then blalbalba.

will the code below works ?

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
	Dchance = math.random(1,100)
	ItemPlace = {x=1001, y=1003, z=6} 
	GemPlace = {x=999, y=1003, z=6} 
	Items = getTileItemById(ItemPlace, item)
}

if(isInArray({1, 2, 3}, getItemWeaponType(config.Items))) then
if(getTileItemById(config.GemPlace, 2156)) then
	doItemSetAttribute(config.Items.uid, "attack", (getItemAttack(config.Items) + config.Dchance))
	doSetItemSpecialDescription(config.Items.uid, "+"..config.Dchance.." ATTK")
	doSendMagicEffect(config.ItemPlace, 30)
end
end
return true
end

- - - Updated - - -

Bump whats wrong in the script?
 
Last edited:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local thing = getThingfromPos({x=1001, y=1003, z=6, stackpos=1})
	if thing.uid ~= 0 and isInArray({1, 2, 3}, getItemWeaponType(thing.uid)) then
		if getTileItemById({x=999, y=1003, z=6}, 2156).uid ~= 0 then
			if getItemAttribute(thing.uid, 'attack') then
				doPlayerSendCancel(cid, 'Item is already enchanted.')
			else
				local Dchance = math.random(1,100)
				doItemSetAttribute(thing.uid, 'attack', getItemInfo(thing.itemid).attack + Dchance)
				doItemSetAttribute(thing.uid, 'description', '+'..Dchance..' ATTK')
				doSendMagicEffect({x=1001, y=1003, z=6}, 30)
			end
		else
			doPlayerSendCancel(cid, 'You need to place a red gem.')
		end
	else
		doPlayerSendCancel(cid, 'You need to place a weapon.')
	end
	return true
end
 
Last edited:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local thing = getThingfromPos({x=1001, y=1003, z=6, stackpos=1})
	if thing.uid ~= 0 and isInArray({1, 2, 3}, getItemWeaponType(thing.uid)) then
		if getTileItemById({x=999, y=1003, z=6}, 2156).uid ~= 0 then
			local attack = getItemAttribute(thing.uid, 'attack')
			if attack then
				doPlayerSendCancel(cid, 'Item is already enchanted.')
			else
				local Dchance = math.random(1,100)
				doItemSetAttribute(thing.uid, 'attack', getItemInfo(thing.itemid).attack + Dchance)
				doItemSetAttribute(thing.uid, 'description', '+'..Dchance..' ATTK')
				doSendMagicEffect({x=1001, y=1003, z=6}, 30)
			end
		else
			doPlayerSendCancel(cid, 'You need to place a red gem.')
		end
	else
		doPlayerSendCancel(cid, 'You need to place a weapon.')
	end
	return true
end

Best scripter evah
 
Back
Top