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

Whats wrong with my npc?

SnowFox

New Member
Joined
May 18, 2008
Messages
264
Reaction score
0
Hey can someone look at this and help me please.


Code:
----Snowfox----

nomoney        = '|PLAYERNAME|, Sorry but you do not have enough money'

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') or msgcontains(msg, 'hello') then
npcHandler:say("Hello |PLAYERNAME| I am a magical wizard from the far west of isula, I sell Health.",  cid)
if msgcontains(msg, 'buy hp') or msgcontains(msg, 'buy health') then
npcHandler:say("|PLAYERNAME|, are you willing to pay 10 crystal coins for 10 health points?", cid)
if msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid,2160,10) then
doCreatureAddHealth(cid, 10)
doSendMagicEffect(getCreaturePosition(cid), 13)
end
else
selfSay(nomoney)
end
 
First of all, the player need to say just "yes" to buy it...
Second,
Code:
nomoney        = '|PLAYERNAME|, Sorry but you do not have enough money'
must are in " " and no ' '.
and, you must use setCreatureMaxHealth(cid, health) but in this case i am not 100% right!

if you use setCreatureMaxHealth(cid, health) do this:

health = getCreatureHealth(cid)

(setCreatureMaxHealth(cid, health) + 10)
 
Code:
----Snowfox----

nomoney        = 'Sorry but you do not have enough money'

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, 'buy hp') or msgcontains(msg, 'buy health') then
			npcHandler:say("Are you willing to pay 10 crystal coins for 10 health points?", cid)
			talkState[talkUser] = 1
		elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
			if doPlayerRemoveItem(cid,2160,10) then
				local healHP = 10 - getCreatureHealth(cid)
				doCreatureAddHealth(cid, healHP)
				doSendMagicEffect(getCreaturePosition(cid), 13)
			else
				npcHandler:say(nomoney, cid)
			end
		end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
First of all, the player need to say just "yes" to buy it...
Second,
Code:
nomoney        = '|PLAYERNAME|, Sorry but you do not have enough money'
must are in " " and no ' '.
and, you must use setCreatureMaxHealth(cid, health) but in this case i am not 100% right!

if you use setCreatureMaxHealth(cid, health) do this:

health = getCreatureHealth(cid)

(setCreatureMaxHealth(cid, health) + 10)

'' works to..

Like doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'this will work')

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "this will works too :)")
 
Back
Top