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

Lua How to? REP++

strike95

ROSESTYLEZ 2012
Joined
Mar 9, 2010
Messages
1,645
Reaction score
12
Location
Los Angeles, CA/Aalborg, Denmark
Well,

I'm interesed how can i do this for an example:
/i crystal coin
and not /i 2160

Simple description, more understanding:

- I can not (I'm not able) to type an item name, just an item ID to spawn an item.
I'm using 8.70, 0.2.10 tfs.


I'm giving Reputation++ to a guy which solve this.
 
you can use /n crystal coin

Or...

LUA:
 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 pos = getCreaturePosition(cid)

	local id = tonumber(t[1])
	if(not id) then
		id = getItemIdByName(t[1], 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[2]) then
		amount = t[2]
	end

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

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

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

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

	return true
end

Save in the talkaction with your /i command script.

And then should work?
 
hmm still you can add the script into talkactions, and then save it as createitem.lua and add this line into talkactions.xml

PHP:
 <talkaction log="yes" words="/i" access="4" event="script" value="createitem.lua"/>

And voila!

Also the /n item name Works in that way too

And lower the
access="4"
to what ever you wish- 4=god, 3=cm etc
 
don't use any of the above, 0.3 scripts won't work in 0.2

simply say /n crystal coin 100

you only need 100 (count) if item name has more than 1 word
 
Back
Top