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

[Need] Change npc

Wrong section.. its not request subforum but nvm...

Check this:

PHP:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local Topic = {} 

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 greetCallback(cid)
    Topic[cid] = 0
    return true
end

function creatureSayCallback(cid, type, msg) 
    if not npcHandler:isFocused(cid) then 
        return false 
    elseif msgcontains(msg, 'magic egg') or msgcontains(msg, 'eggs') or msgcontains(msg, 'egg') or msgcontains(msg, 'trade') then 
        selfSay('Do you want change 100 eggs for 25 magic eggs ?', cid) 
        Topic[cid] = 1 
    elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then 
        if getPlayerItem(cid, 2160) >= 100 then
            doPlayerAddItem(cid, 8858, 25)
            selfSay('Here you are.', cid)
        else
            selfSay('You don\'t have required eggs.', cid)
        end
        Topic[cid] = 0
    elseif msgcontains(msg, 'no') and Topic[cid] > 0 then
        Topic[cid] = 0
        selfSay('Ok than...', cid)
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Last edited:
Not work :P


21:32 Rasta: Hello Devil, I change 100 marijuanas for 25 magic eggs! yes?.
21:32 Devil [75]: yes
21:32 Devil [75]: Yes
21:32 Devil [75]: ess
21:33 Devil [75]: egg
21:33 Rasta: Do you want change 100 eggs for 25 magic eggs ?
21:33 Devil [75]: yes
21:33 Devil [75]: egg
21:33 Rasta: Do you want change 100 eggs for 25 magic eggs ?
21:33 Devil [75]: egg
21:33 Rasta: Do you want change 100 eggs for 25 magic eggs ?
21:33 Devil [75]: trade
21:33 Rasta: Do you want change 100 eggs for 25 magic eggs ?
21:33 Devil [75]: yes
 
Check now...

LUA:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local Topic = {} 

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 greetCallback(cid)
    return true
end

function creatureSayCallback(cid, type, msg) 
    if not npcHandler:isFocused(cid) then 
        return false 
    elseif msgcontains(msg, 'magic egg') or msgcontains(msg, 'eggs') or msgcontains(msg, 'egg') or msgcontains(msg, 'trade') then 
        selfSay('Do you want change 100 eggs for 25 magic eggs ?', cid) 
    elseif msgcontains(msg, 'yes') then 
        if getPlayerItem(cid, 2160) >= 100 then
            doPlayerAddItem(cid, 8858, 25)
            selfSay('Here you are.', cid)
        else
            selfSay('You don\'t have required eggs.', cid)
        end
        Topic[cid] = 0
    elseif msgcontains(msg, 'no') and Topic[cid] > 0 then
        Topic[cid] = 0
        selfSay('Ok than...', cid)
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Another copy of great server called noobwar.eu...
Sux skillboy...
 
Now, must works, JUST CHANGE ID OF ITEMS AND TEXT:
PHP:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local Topic = {} 

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 greetCallback(cid)
	Topic[cid] = 0
	return true
end

function creatureSayCallback(cid, type, msg) 
	if not npcHandler:isFocused(cid) then 
		return false 
	elseif msgcontains(msg, 'egg') or msgcontains(msg, 'magic egg') or msgcontains(msg, 'trade') then 
		selfSay('Do you want trade {100 eggs} for {25 magic eggs} ?', cid) 
		Topic[cid] = 1 
	elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then 
		if doPlayerRemoveItem(cid, 2160, 100) then
			doPlayerAddItem(cid, 2155, 25)
			selfSay('Hmpf! <smoke weed> huh! Good grass baby!', cid)
		else
			selfSay('Sorry, you don\'t have {100 eggs}!', cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, 'no') and Topic[cid] > 0 then
		Topic[cid] = 0
		selfSay('Bless ya!', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Get Online Then Or Answer -.-

SKILLBOY!, Just Log On Msn And Answer Me... Your Online... Look Picture...

2ai4s54.jpg


I see Your Looking At This Thread Now....
Why Dont U Just Answer Me On Msn -.-

Current Activity
Viewing Thread [NPC] [Need] Change npc

Last Activity
Today 22:35

Dont Let Me Call You Thief Everywhere..... :S
 
Last edited by a moderator:
Back
Top