TalkAction NewID Outfit

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
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


enjoy
 
Last edited:

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Nice, I will probably use this, maybe add some "extras". :thumbup:
 
OP
Sync

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
Location
Canada
Thanks for all the positive feedback. ^^
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
<flame flame flame>

Kool script :D
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
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:
OP
Sync

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,876
Best answers
0
Reaction score
19
Location
Canada
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
 

Yuji

Helper
Joined
Mar 18, 2010
Messages
438
Best answers
0
Reaction score
33
Location
U.S.A New York
hey by any chance could u add like /newid (name of char you whant to give the new id to) 1234
 

Syntax

Developer
Joined
Oct 10, 2007
Messages
2,840
Best answers
0
Reaction score
201
Location
Texas
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
 

Yuji

Helper
Joined
Mar 18, 2010
Messages
438
Best answers
0
Reaction score
33
Location
U.S.A New York
is that the code i asked for? and if it is umm like what sould the words be in the Talkactions.xml
 

Thorun

New Member
Joined
Jun 17, 2010
Messages
69
Best answers
0
Reaction score
0
Location
The Netherlands
The newID doesn't stay by players (when they relogg they go back to normal outfit)
 

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
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:
Top