JaquezGaming
Member
Hi im just wondering if anyone have script for 0.4 where it locks items for example (Plate Armor) so its not possible to do it in /i but you can create it through /rc or only owner can create the item? 

local id = tonumber(t[1])
if(not id) then
errors(false)
id = getItemIdByName(t[1])
errors(true)
if(not id) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
return true
end
end
if isInArray(locked_items, id) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.")
return true
end
local locked_items =...
local id = tonumber(t[1])
if(not id) then
errors(false)
id = getItemIdByName(t[1])
errors(true)
if(not id) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
return true
end
end
if isInArray(locked_items, id) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.")
return true
end
local locked_items = {2463, 1111, 2222, 3333}
if isInArray(locked_items, id) then
if getPlayerAccess(cid) < 6 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.")
return true
end
end
local owners = {"xikini", "jaquezgaming"} -- use only lowercase letters (put this up above function onSay)
if isInArray(locked_items, id) then
if not isInArray(owners, getCreatureName(cid):lower()) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.")
return true
end
end
Thanks broLook in talkactions and find the script that /i uses.
Inside that script, look for the line that shows something similar or exactly the same as this..
Directly underneath that block of code, place this code.LUA:local id = tonumber(t[1]) if(not id) then errors(false) id = getItemIdByName(t[1]) errors(true) if(not id) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true end end
At the top of the script above function onSay, place this code.LUA:if isInArray(locked_items, id) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.") return true end
LUA:local locked_items = {2463, 1111, 2222, 3333}
The above steps will 'lock' the items from being spawned.
Now, to only allow a 'owner' to spawn these items, you have a couple of choices.
The easier choice, is to only allow owners to have the highest access on the server. (such as access 6 in data/xml/groups.xml)
And then implement that into the script, like this.
The slightly harder choice would be to manually input the 'owners' name into the script, and compare that instead, like this.LUA:if isInArray(locked_items, id) then if getPlayerAccess(cid) < 6 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.") return true end end
LUA:local owners = {"xikini", "jaquezgaming"} -- use only lowercase letters (put this up above function onSay)
LUA:if isInArray(locked_items, id) then if not isInArray(owners, getCreatureName(cid):lower()) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry! This item is not allowed to be created.") return true end end
In either case, this should do what you are wanting, I believe.
Cheers.