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

TalkAction NewID Outfit

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,901
Reaction score
26
Location
Canada
Well, i was making a simple script where you become an item for my good buddy,
then it hit me, I should make a script simliar to /newtype except instead make it ItemIDS instead of monster ids. Here ya go

Code:
<talkaction log="yes" words="/newid" access="4" event="script" value="newid.lua"/>

Lua:
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return true
	end
    	local t = string.explode(param, ",")
	t[1] = tonumber(t[1])
	if(not t[1]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
		return true
	end
	if(t[1] >= 10544) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such item does not exist.")
		return true
	end
	  	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your outfit has been turned into a "..getItemNameById(param)..".")
	  	  doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
		    doSetItemOutfit(cid, param, -1)
	return true
end

Code:
00:02 /newid 1600
15aqz5.jpg


enjoy
 
Last edited:
Nice, I will probably use this, maybe add some "extras". :thumbup:
 
I think this is missing in tfs's commands.
good job:thumbup:
btw can you upgrade it so it can be like "getItemByName"?
 
Last edited:
I think this is missing in tfs's commands.
good job:thumbup:
btw can you upgrade it so it can be like "getItemByName"?

like /newid stone?

{Untested}
Lua:
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") 
                return true
        end                
       	local item = getItemIdByName(param)       
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your outfit has been turned into a "..getItemNameById(param)..".")
                  doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
                    doSetItemOutfit(cid, item, -1)                                          
        return true
end
 
Lua:
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return true
	end

	local t = string.explode(param, ",")
	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 with this name does not exists.")
			return true
		end
	end
	
	local pid = cid
	if(t[2]) then
		pid = getPlayerByNameWildcard(t[2])
		if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
			return true
		end
	end
	
	if(id < 100 or id > 11388)then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid item id. Please enter a valid item id or name.")
		return true
	end
	local info = getItemInfo(id)
	local name,article = info.name, info.article
	local msg = "You changed your outfit to "..article.." "..name.."."
	if(t[2] and pid ~= cid)then
		msg = "You changed "..getCreatureName(pid).."'s outfit to "..article.." "..name.."."
	end
	return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,msg) and doSetItemOutfit(pid,id,-1)
end

Supports players in second parameter and some other minor improvements.
sorry Chris :p
 
Better:
Lua:
function onSay(cid, words, param, channel)
    local p,time = param:match('(%d+)%s*,*%s*(%d*)%s*')
	time = tonumber(time or -1)
	param = tonumber(p or param) or 100
    if(param > 10543 and param < 100) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such item does not exist.")
        return true
    end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your outfit has been turned into a "..getItemNameById(param)..".")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
	doSetItemOutfit(cid, param, time == -1 and -1 or time*1000)
	return true
end
/newid 6500 <-- to 6500 for unlimited time
/newid 6500, 60 <-- to 60 seconds
or
Lua:
function onSay(cid, words, param, channel)
    local p,player = param:match('(%d+)%s*,*%s*(.*)')
	param = tonumber(p or param) or 100
    if(param > 10543 and param < 100) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such item does not exist.")
        return true
    end
        cid = isPlayer(getPlayerByName(player or 0)) and getPlayerByName(player) or 0
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your outfit has been turned into a "..getItemNameById(param)..".")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
	doSetItemOutfit(cid, param, time == -1 and -1 or time*1000)
	return true
end
/newid 6500 <- to you
/newid 6500, omg <- to player omg
 
Last edited:
Back
Top