[Sorry i am not good at english, i never has studied it]
I am working to create the first server 9.54 on Spain. I'm trying to create a full map by myshelf with NPC, monster, quest, etc. I had created a town with 64 Houses and 2 Guild Houses and a depot area too. Now i am trying to make some NPC to sell items like food, weapons, armor and others for task or quest. I DON'T want COPY - PASTE because i hate it. I want learn to create NPC and copy a sample can't show me how to create a NPC. I study informatic so i know what is an if - elseif loop too and all this things. But there are a loot of functions in the guide: http://otland.net/f481/scripting-guide-74030/
And he explain the principal functions but dont make a little sample for every one of the principal samples. And if you dont see a sample without programing the function is like be mother and father for first time and try to change a diaper without being taught. So If someone want to explain not only for me, to all admins that want to create a NPC for themself GO please and a lot of dudes are going to be resolved.
If anyone want plase solve this:
NPC .XML
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The King" script="data/npc/scripts/the king.lua" walkinterval="2000" floorchange="0">
<health now="185" max="185"/>
<look corpse="2317" addons="0" feet="114" legs="114" body="94" head="20" type="266"/>
<parameters>
<parameter key="message_greet" value="Bienvenido a mi castillo. ¿Quieres que te ofrezca alguna mision?"/>
<parameter key="message_farewall" value="Que tu camino se ilumine ante tus ojos."/>
<parameter key="message_walkaway" value="Que maleducado. La gente suele decir adios..."/>
</parameters>
</npc>
NPC .LUA
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'mision')) then
selfSay('Quieres que te encomiende una mision ¿no? Bueno como sabras para ganarte mi respeto tendras que ir haciendo misiones poco a poco, para que pueda encargarte cada vez missiones que te traigan mas recompensas.', cid)
selfSay('Bueno ahora mismo atravesamos un momento muy amargo en la ciudad ya que las alcantarillas han sido invadidas por mounstruos. Una patrulla anda en las alcantarillas, busca al capitan y pidele que te entregue un libro. ¿Aceptas la mision?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'si') and talkState[talkUser] == 1) then
talkState[talkUser] = 0
selfSay('¡Bien! Muchas gracias por acerte cargo de esta tarea. La haria encantado pero perdi mi espada y hasta que no la encuentre no podre ayudar en las labores de defensa.')
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('Si no quieres por ahora, mas tarde podras realizar mis misiones. Recuerda que te llevaras dinero honor gloria y mucha experiencia.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
The error
There are no error on the server console but when the server start and you go to the position where i put it in Remere's Map Editor it don't appear (AND YES I SEE IT BEFORE) i see it because i create the NPC as default only with look type and he appear and say Hi and Bye. After a few updates because i try script without a guide only with the functions he desappear and i try to delete spawn.xml and create it again delete the monster spawner with the NPC and replace it. Modify the .LUA to the last version (when i see it) i try to create it with other name and the same .LUA and i try to create a new NPC with default.lua and it don't appear too.
¿Solution? Thanks for helping. And if you want create a small guide with the functions and his uses with small samples ¡UBERSUPERTHANKS!
I am working to create the first server 9.54 on Spain. I'm trying to create a full map by myshelf with NPC, monster, quest, etc. I had created a town with 64 Houses and 2 Guild Houses and a depot area too. Now i am trying to make some NPC to sell items like food, weapons, armor and others for task or quest. I DON'T want COPY - PASTE because i hate it. I want learn to create NPC and copy a sample can't show me how to create a NPC. I study informatic so i know what is an if - elseif loop too and all this things. But there are a loot of functions in the guide: http://otland.net/f481/scripting-guide-74030/
And he explain the principal functions but dont make a little sample for every one of the principal samples. And if you dont see a sample without programing the function is like be mother and father for first time and try to change a diaper without being taught. So If someone want to explain not only for me, to all admins that want to create a NPC for themself GO please and a lot of dudes are going to be resolved.
If anyone want plase solve this:
NPC .XML
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The King" script="data/npc/scripts/the king.lua" walkinterval="2000" floorchange="0">
<health now="185" max="185"/>
<look corpse="2317" addons="0" feet="114" legs="114" body="94" head="20" type="266"/>
<parameters>
<parameter key="message_greet" value="Bienvenido a mi castillo. ¿Quieres que te ofrezca alguna mision?"/>
<parameter key="message_farewall" value="Que tu camino se ilumine ante tus ojos."/>
<parameter key="message_walkaway" value="Que maleducado. La gente suele decir adios..."/>
</parameters>
</npc>
NPC .LUA
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler
function onCreatureDisappear(cid) npcHandler
function onCreatureSay(cid, type, msg) npcHandler
function onThink() npcHandler
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'mision')) then
selfSay('Quieres que te encomiende una mision ¿no? Bueno como sabras para ganarte mi respeto tendras que ir haciendo misiones poco a poco, para que pueda encargarte cada vez missiones que te traigan mas recompensas.', cid)
selfSay('Bueno ahora mismo atravesamos un momento muy amargo en la ciudad ya que las alcantarillas han sido invadidas por mounstruos. Una patrulla anda en las alcantarillas, busca al capitan y pidele que te entregue un libro. ¿Aceptas la mision?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'si') and talkState[talkUser] == 1) then
talkState[talkUser] = 0
selfSay('¡Bien! Muchas gracias por acerte cargo de esta tarea. La haria encantado pero perdi mi espada y hasta que no la encuentre no podre ayudar en las labores de defensa.')
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('Si no quieres por ahora, mas tarde podras realizar mis misiones. Recuerda que te llevaras dinero honor gloria y mucha experiencia.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
The error
There are no error on the server console but when the server start and you go to the position where i put it in Remere's Map Editor it don't appear (AND YES I SEE IT BEFORE) i see it because i create the NPC as default only with look type and he appear and say Hi and Bye. After a few updates because i try script without a guide only with the functions he desappear and i try to delete spawn.xml and create it again delete the monster spawner with the NPC and replace it. Modify the .LUA to the last version (when i see it) i try to create it with other name and the same .LUA and i try to create a new NPC with default.lua and it don't appear too.
¿Solution? Thanks for helping. And if you want create a small guide with the functions and his uses with small samples ¡UBERSUPERTHANKS!
Last edited: