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

TalkAction (Gods/GMs) Give items to players

Aarthec

w0000t
Joined
Apr 25, 2009
Messages
129
Reaction score
0
Location
Sweden
How to use:
/giveitem playername, itemid, amount


Lua:
function onSay(cid, words, param)
local param = param.explode(param, ',')
if param then
	if isPlayer(getCreatureByName(param[1])) == TRUE then
		doPlayerSendTextMessage(getCreatureByName(param[1]), 22, "You recieved an item from an admin!")
		doPlayerAddItem(getCreatureByName(param[1]), param[2], param[3])
	end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
	end
return TRUE
end

PHP:
<talkaction log="yes" access="5" words="/giveitem" event="script" value="giveitem.lua"/>

:blink:
 
That is a pretty cool & simple idea,
Thanks. :thumbup:

Yay, 1,200th Post :huh:
 
Look my script:

Lua:
function onSay(cid, words, param, channel)

local param = string.explode(param, ",")
local item =
{
	player = getPlayerByNameWildcard(param[1]),
	itemid = tonumber(param[2]),
	type = tonumber(param[3]),
	charges = 1
}
local str =
{
	"",
	""
}

	if(item.player == 0 or item.player == nil) then
		doPlayerSendCancel(cid, "Player " .. param[1] .. " is not online.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return TRUE
	end

	if(not item.itemid) then
		item.itemid = getItemIdByName(param[2], false)
		if not item.itemid then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			return TRUE
		end
	end

	if(item.itemid < 1) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No item specified.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return TRUE
	end

	if(not item.type) then
		if(isItemRune(item.itemid) or isItemStackable(item.itemid)) == TRUE then
			item.type = 100
			item.charges = 1
		else
			item.type = 1
			item.charges = 1
		end
	end

	if(isItemMovable(item.itemid) == FALSE) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give that item.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return TRUE
	end

local str =
{
	"You give " .. item.type .."x " .. getItemNameById(item.itemid) .. " to " .. param[1] .. ".",
	"You received " .. item.type .. "x " .. getItemNameById(item.itemid) .. " from " .. getCreatureName(cid) .. "."
}

	if(isItemRune(item.itemid) == TRUE) then
		item.charges = item.type
		item.type = 1
		str[1] = "You give " .. item.type .. "x " .. getItemNameById(item.itemid) .. " with " .. item.charges .. "x charges to " .. param[1] .. "."
		str[2] = "You received " .. item.type .. "x " .. getItemNameById(item.itemid) .. " with " .. item.charges .. " charges from " .. getCreatureName(cid) .. "."
	end

	doPlayerGiveItem(item.player, item.itemid, item.type, item.charges)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str[1])
	doSendMagicEffect(getCreaturePosition(item.player), CONST_ME_MAGIC_RED)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str[2])
	return TRUE
end

You can use:
Code:
/giveitem Darkhaos, 2195, 1
/giveitem Darkhaos, 2195
/giveitem Darkhaos, boots of haste, 1
/giveitem Darkhaos, boots of haste
 
Back
Top