• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Fixnijcie mi npcta

Dubler

PHP, LUA, C++
Joined
Aug 3, 2009
Messages
268
Reaction score
11
Location
Poland
Mam problem z tym npc:
Jak zagadam do niego to mowi hi playername, i have been expecting you
a na mission/help itp nie reaguje:
XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Dad" script="dad.lua" walkinterval="0" floorchange="0">
	<health now="150" max="150"/>
	<look type="129" head="114" body="119" legs="114" feet="114" corpse="2212"/>
</npc>
lua:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid)                        end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                end
function onThink()                                      npcHandler:onThink()                                    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, 'hi')) then
                selfSay('Hi son!', cid)
                talkState[talkUser] = 1
        elseif(msgcontains(msg, 'help') and talkState[talkUser] == 1) then
                selfSay('Real mens says quest!', cid)
        elseif(msgcontains(msg, 'quest') and talkState[talkUser] == 1) then
                if (getPlayerStorageValue(cid, 1100)==6) then
                        selfSay('I need 5 fresh corpses of rats to make some equipment for you.', cid)
                        setPlayerStorageValue(cid, 1100,7)
                        selfSay('Because of rats are much stronger then rabbits i will borrow you my shield and my old knife', cid)
                        doPlayerAddItem(cid, 2526,1)
                        doPlayerAddItem(cid, 2379,1)
                end
        elseif(msgcontains(msg, 'rat') and talkState[talkUser] == 1) then
        if(getPlayerStorageValue(cid,1100)==7 and doPlayerRemoveItem(cid, 2813,5)) then
        selfSay('Uncle Alfred want to see you', cid)
        setPlayerStorageValue(cid, 1100,8)
        else
        selfSay('You arent doing it good.', cid)
        end
        elseif(msgcontains(msg, 'bye') and talkState[talkUser] == 1) then
                talkState[talkUser] = 0
                selfSay('Ok then.', cid)
 
        end
        return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
PLZ HELP!
 
What the fuck is that:
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

Od kiedy takie cos jest? :p
 
nie wiem... to nie ja pisałem tego NPCta tylko moj kolega... w każdym razie badziew nie działa :| a help masz na samym początku...

reflesh
 
Last edited by a moderator:
Spróbuj to.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid)                        end
function onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid)                     end
function onCreatureSay(cid, type, msg)                  npcHandler:onCreatureSay(cid, type, msg)                end
function onThink()                                      npcHandler:onThink()                                    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, 'hi')) then
                selfSay('Hi son!', cid)
                talkState[talkUser] = 1
        elseif(msgcontains(msg, 'help')) and talkState[talkUser] == 1 then
                selfSay('Real mens says quest!', cid)
        elseif(msgcontains(msg, 'quest')) and talkState[talkUser] == 1 then
                if (getPlayerStorageValue(cid, 1100)==6) then
                        selfSay('I need 5 fresh corpses of rats to make some equipment for you.', cid)
                        setPlayerStorageValue(cid, 1100,7)
                        selfSay('Because of rats are much stronger then rabbits i will borrow you my shield and my old knife', cid)
                        doPlayerAddItem(cid, 2526,1)
                        doPlayerAddItem(cid, 2379,1)
                end
        elseif(msgcontains(msg, 'rat')) and talkState[talkUser] == 1 then
        if(getPlayerStorageValue(cid,1100)==7 and doPlayerRemoveItem(cid, 2813,5)) then
        selfSay('Uncle Alfred want to see you', cid)
        setPlayerStorageValue(cid, 1100,8)
        else
        selfSay('You arent doing it good.', cid)
        end
        elseif(msgcontains(msg, 'bye')) and talkState[talkUser] == 1 then
                talkState[talkUser] = 0
                selfSay('Ok then.', cid)
 
        end
        return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top