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

New item in game

niecik

Mapper
Joined
Jan 22, 2009
Messages
18
Reaction score
0
PL:
Witam, nie wiedziałem w jakim dziale napisać więc napisałem w tym. (Jeśli zły to proszę moderatora o przeniesienie tematu do właściwego działu)
Chciałbym dodać nowy item do gry, nie edytować np. magic sworda tylko dodać zupełnie nowy item. Można to zrobić w jakiś sposób?
Chciałbym nadać mu nowy wygląd, nowe id itp.

Jak to zrobić?
__________________________________
ENG. TRANSLATE

Hi, I did not know what section to write so I wrote this. (If wrong, please moderator for transfer subject to the correct department)
I would like to add a new item to the game, do not edit for example, Magic Sword is add a new item. You can do this in some way?
I would give it a new look, new id, etc.

How do I?
 
data\items

Newitems.lua
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<items>
                <item id="100" spriteid="2400" article="a" name="magic edited sword">
                                <attribute key="description" value="Arma editada." />
                                <attribute key="defense" value="45" />
                                <attribute key="attack" value="100" />
                                <attribute key="extradef" value="10" />
                                <attribute key="extraatk" value="10" />
                </item>
                <item id="101" spriteid="2472" article="a" name="master plate armor">
                                <attribute key="description" value="Armor editada." />
                                <attribute key="armor" value="19" />
                </item>
                <item id="102" spriteid="2400" article="a" name="trolling armor">
                                <attribute key="description" value="Trolling power." />
                                <attribute key="armor" value="100" />
                </item>
	<item id="103" spriteid="12396" name="Item editado">
		<attribute key="description" value="Did it just twitch...? No, must have been an optical illusion."/>
		<attribute key="weight" value="240"/>
	</item>
</items>

data\lib

ItemsEditedLib.lua

Lua:
function doPlayerAddEditedItem(cid, itemid)
        local newxml = io.open("data/items/newitems.xml", "r")
        local configs = {}

        for i in newxml:read("*a"):gmatch("<item (.-)</item>") do
                local itemid = tonumber(i:match('id="(.-)"'))
                local itemconfig = {
                        ["spriteid"] = tonumber(i:match('spriteid.-=.-"(.-)"')),
                        ["article"] = i:match('article.-=.-"(.-)"'),
                        ["name"] = i:match('name.-=.-"(.-)"'),
                        ["description"] = i:match('key.-=.-"description".-value.-=.-"(.-)"'),
                        ["defense"] = tonumber(i:match('key.-=.-"defense".-value.-=.-"(.-)"')),
                        ["attack"] = tonumber(i:match('key.-=.-"attack".-value.-=.-"(.-)"')),
                        ["extradefense"] = tonumber(i:match('key.-=.-"extradef".-value.-=.-"(.-)"')),
                        ["armor"] = tonumber(i:match('key.-=.-"armor".-value.-=.-"(.-)"')),
                        ["extraattack"] = tonumber(i:match('key.-=.-"extraatk".-value.-=.-"(.-)"')),
                }
                configs[itemid] = itemconfig
        end
                if configs[itemid] then
                        local item = doPlayerAddItem(cid, configs[itemid].spriteid)
                        for i,x in pairs(configs[itemid]) do
                                doItemSetAttribute(item, i, x)
                        end
                end
end

In talkactions.xml add this
XML:
        <talkaction log="yes" words="!trollingarmor" access="2" event="script" value="trollingarmor.lua"/>

data\talkactions\scripts

trollingarmor.lua

Lua:
function onSay(cid, words, param)
local pos = getCreaturePosition(cid)
        doPlayerAddEditedItem(cid, 102)
        doSendMagicEffect(pos, CONST_ME_BIG_CLOUD)
return true
end
 
Back
Top