Hi,
This will come useful if you want to save some time!
Example if you copy from wiki, in this case name the file xodetwiki.txt and this how it should look inside the txt file:
coloum 1 itemname, coloum 2 price, coloum 3 subtype in this case:
The script is checking automatic, if there is 3 coloums or not. The third one is always subtype!
When you execute the command you will get this:
Also the script has a debug mode, it will print on the console or send text message, if it does not find the name of that item, or if a item is corrupt that you forgot to add price.
TFS 1.0
Tfs 0.3
Now name it: npcgenerator.lua and paste the code below:
Enjoy!
Here is also Yasir which ive generated from wiki!
Remember Yasir have items from latest versions!
Yasir file
This will come useful if you want to save some time!
Example if you copy from wiki, in this case name the file xodetwiki.txt and this how it should look inside the txt file:
Code:
Stone Shower Rune, 37
Thunderstorm Rune, 37
blank rune, 10
Code:
Vial of Blood,15,blood
The script is checking automatic, if there is 3 coloums or not. The third one is always subtype!
When you execute the command you will get this:
Code:
This log have been generated at: [22/09/2013 12:25:43]:
Stone Shower Rune,2288,37;
Thunderstorm Rune,2315,37;
blank rune,2260,10;
Vial of Blood,2006,15,2,Vial of Blood;
End of genereated log.
Also the script has a debug mode, it will print on the console or send text message, if it does not find the name of that item, or if a item is corrupt that you forgot to add price.
TFS 1.0
Code:
<talkaction words="!make" script="npcgenerator.lua"/>
Tfs 0.3
Code:
<talkaction words="!make" event="script" value="npcgenerator.lua"/>
Now name it: npcgenerator.lua and paste the code below:
Code:
--Author: Printer from otland.net!
local config = {
tfs_10 = "no", --if you are using 1.0 or 0.2 then write yes, else if you are using 0.3 then leave it as default: no
wiki_file = "xodetwiki", --where script will take the information from [remember the txt file has to be .txt]
generated_file = "xodet-generated" --new file name
}
if (config.tfs_10 == "yes") then
string.trim = function (str)
return str:gsub("^%s*(.-)%s*$", "%1")
end
string.explode = function (str, sep, limit)
if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then
return {}
end
local i, pos, tmp, t = 0, 1, "", {}
for s, e in function() return string.find(str, sep, pos) end do
tmp = str:sub(pos, s - 1):trim()
table.insert(t, tmp)
pos = e + 1
i = i + 1
if(limit ~= nil and i == limit) then
break
end
end
tmp = str:sub(pos):trim()
table.insert(t, tmp)
return t
end
return true
end
function onSay(cid, words, param)
local f = io.open("data/logs/"..config.generated_file..".txt", "a+")
if f ~= nil then
f:write("This log have been generated at: ["..os.date("%d/%m/%Y %H:%M:%S").."]:\n")
for line in io.lines("data/logs/"..config.wiki_file..".txt") do
if line ~= "" then
local format = string.explode(line, ",")
local item = {}
item.id = (getItemIdByName(format[1]))
item.price = tonumber(format[2])
item.subtype = format[3]
if (not item.id) then
print("(" .. os.date("%H:%M:%S") .. "): This itemname doesnt exsist: ["..format[1].."].")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Failed to create a log. This item doesnt exsist: ["..format[1].."].")
f:write("Failed\n")
f:write("End of failed genereated log.\n\n")
f:close()
return false
end
if (not item.price) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Failed to create a log. This is not a price: ["..format[2].."] on item: ["..format[1].."].")
return false
end
if (item.subtype) == "Empty" then
item.subtype = 0
elseif item.subtype == "Water" then
item.subtype = 1
elseif item.subtype == "Blood" then
item.subtype = 2
elseif item.subtype == "Beer" then
item.subtype = 3
elseif item.subtype == "Slime" then
item.subtype = 4
elseif item.subtype == "Lemonade" then
item.subtype = 5
elseif item.subtype == "Milk" then
item.subtype = 6
elseif item.subtype == "Mana" then
item.subtype = 7
elseif item.subtype == "Life" then
item.subtype = 10
elseif item.subtype == "Oil" then
item.subtype = 11
elseif item.subtype == "Urine" then
item.subtype = 13
elseif item.subtype == "Coconut milk" then
item.subtype = 14
elseif item.subtype == "Wine" then
item.subtype = 15
elseif item.subtype == "Mud" then
item.subtype = 19
elseif item.subtype == "Fruit Juice" then
item.subtype = 21
elseif item.subtype == "Lava" then
item.subtype = 26
elseif item.subtype == "Rum" then
item.subtype = 27
elseif item.subtype == "Swamp" then
item.subtype = 28
elseif item.subtype == "Tea" then
item.subtype = 35
end
if (item.subtype) then
f:write(""..format[1].." of "..format[3].."," .. item.id .. "," .. item.price ..","..item.subtype..","..format[1].." of "..format[3]..";\n")
else
f:write(""..format[1].."," .. item.id .. "," .. item.price ..";\n")
end
end
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Log been created.")
f:write("End of genereated log.\n\n")
f:close()
end
return false
end
Enjoy!
Here is also Yasir which ive generated from wiki!
Remember Yasir have items from latest versions!
Yasir file
Last edited: