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

Command /i with exception.

SnakevL

New Member
Joined
Jun 5, 2008
Messages
71
Reaction score
0
Hey y'all, what's up?

I came to here to ask your help...
I need a modified /i that create any item, EXCEPT whose i configured to do not create. (more safety.. if some hacker want to do items in my server, their cannot create vip items.(it's happened to me) and a way of moderate others GODs administration).

My data/talkactions/scripts/createitem.lua:
Code:
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_ORANGE)
	end

	return true
end

Can somebody help me?
 
Maybe this:
Lua:
function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end
	local k = {
	[1] = 3150,
	[2] = 3151,
	[3] = 3152,
	[4] = 3153,
	[5] = 3154,
	[6] = 3155
	} -- item ids
 for i = k[1], k[6] do -- change [6] to the max value of k (the table)
	if (param == ''..i..'') then
	return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may not create this item") and false
	end
	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
not tested tho.
Edit: also, IIRC, the items of the table must be from lowest id to highest id.
I.E. local k = {
[1] = 100,
[2] = 200,
[3] = 300
}
it cant be like
local k = {
[1] = 400,
[2] = 350,
[3] = 200
}
 
Lua:
local restricted = {
	itemids = {1111, 1112},
	exceptions = {'me', 'you', 'and the other one'}
	}
	
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

	if isInArray(restricted.itemids, id) and not isInArray(restricted.exceptions, getCreatureName(cid)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You may not create this item.")
		return true
	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_ORANGE)
	end

	return true
end

this way you don't have to put the ids in order.. I think someone requested this before.. but not sure
 
Code:
local blocked, allowed = {1234, 'name', 5678, 'another item name'}, {'god'}

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)

	if table.find(blocked, tonumber(t[1]) or t[1]:lower()) and not isInArray(allowed, getCreatureName(cid):lower()) then
		return false
	end

	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_ORANGE)
	end

	return true
end
 
Lua:
local _t = {
	restricted = {2196, 7461, 2505, 3975, 2507, 3982, 5958, 7423, 7416, 7435, 7427, 7958, 7426, 9975, 5785, 8932, 9927, 8879, 9928, 7892, 2537, 2300, 2316, 2297, 2128, 6880, 9777, 7893, 6391, 2275, 2312, 2363, 8306, 2424, 7420, 2408, 7437, 8854, 2299, 9003},
	allowedNames = {'Inferno-ot Owner'}
}

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 tmp = 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 with such name does not exist.")
			return true
		end
	end

	if isInArray(_t.restricted, id) and not isInArray(_t.allowedNames, getCreatureName(cid)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot create donated items.")
		return true
	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
			tmp = getPlayerLookPos(cid)
		end

		ret = doTileAddItemEx(tmp, 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

	doSendMagicEffect(tmp, CONST_ME_MAGIC_RED)
	return true
end
script by Cykotitan
edit this part
Lua:
	restricted = {2196, 7461, 2505, 3975, 2507, 3982, 5958, 7423, 7416, 7435, 7427, 7958, 7426, 9975, 5785, 8932, 9927, 8879, 9928, 7892, 2537, 2300, 2316, 2297, 2128, 6880, 9777, 7893, 6391, 2275, 2312, 2363, 8306, 2424, 7420, 2408, 7437, 8854, 2299, 9003},
	allowedNames = {'Inferno-ot Owner'}
restricted = items that cannot be made by "normal" gods. only allowedNames can make those.
 
Hi y'all, sorry for make u wait for my response.
i tested only @Luciano (Cykotitan) script, and it works..
Thanks very much, moderators can close the thread.
 
Back
Top