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

add item to BP

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
I wanted a command that adds item x to the BP of a player
/additem name of player,item ID,quantity.

would be possible?
 
Edited version of /i script..
Create "additem.lua" in talkactions/scripts and add this:
PHP:
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end

	local t = string.explode(param, ",")
	local ret = RETURNVALUE_NOERROR
	local name = getPlayerByName(tostring(t[1]))
	if name == nil then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player doesn't exist or isn't online.")
		return true
	end
	local pos = getCreaturePosition(name)

	local id = tonumber(t[2])
	if(not id) then
		id = getItemIdByName(t[2], false)
		if(not id) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
			return true
		end
	end

	local amount = 100
	if(t[3]) then
		amount = t[3]
	end

	local item = doCreateItemEx(id, amount)
	if(t[4] and getBooleanFromString(t[4])) then
		if(t[5] and getBooleanFromString(t[5])) then
			pos = getCreatureLookPosition(name)
		end

		ret = doTileAddItemEx(pos, item)
	else
		ret = doPlayerAddItemEx(name, item, true)
	end

	if(ret ~= RETURNVALUE_NOERROR) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[2])
		return true
	end

	doDecayItem(item)
	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
	end
	return true
end

And in talkaction.xml add this line:
PHP:
<talkaction log="yes" words="/ai" access="4" event="script" value="additem.lua"/>

Now you can write like this:
/ai the_name_here, item_id/item_name, item_count (There are 2 more parameters but I bet you won't need them..)

Rep+ if I helped you :d
 
Back
Top