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

Lua NPC Crashing the serv..(With picture of error)

RoHaN-OTs

RoHaN-OTs.com
Joined
Jul 28, 2010
Messages
1,594
Reaction score
82
Location
Sweden
http://www13.speedy*****malware.localhost/files/25795946/download/npc.jpg

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, 'reward') then
	   selfSay("Ah! I see you are here to take your reward {yes} ?",cid)
	   talkState[talkUser] =1
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
	   selfSay("Here is your reward.",cid)
	   doPlayerAddItem(cid,6527,20)
	   doSendMagicEffect(getThingPos(cid),49)
	   addEvent(doTeleportThing, 50,cid,{x=1000,y=1000,z=7})
	   talkState[talkUser] = 0
	elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
	  selfSay("Maybe later.",cid)
	  talkState[talkUser] = 0
	end
return true
end
	
	
	
	
	
	
	
	
	
	npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I think you can see what the problem is.. help plx? :p
 
Me either, but why are you using an addEvent to teleport.
Try with doTeleportThing
LUA:
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, 'reward') then
	   selfSay("Ah! I see you are here to take your reward {yes} ?",cid)
	   talkState[talkUser] = 1
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
	   selfSay("Here is your reward.",cid)
	   doPlayerAddItem(cid,6527,20)
	   doSendMagicEffect(getThingPos(cid),49)
	   doTeleportThing(cid,{x=1000,y=1000,z=7})
	   talkState[talkUser] = 0
	elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
	  selfSay("Maybe later.",cid)
	  talkState[talkUser] = 0
	end
return true
end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Changed the code to santig's, hopefully wont crash again !

Btw, while you guys still are here, any idea how to fix this script? :D
http://www12.speedy*****malware.localhost/files/25797726/download/froze.jpg
Code:
local freezetime = 4   

local cooldown = 10   -- time to use again

local storage = 19001

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaust)
 
local exhaustt = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustt, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustt, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaustt)

function countDown(number, pos, effect, msgonend, effectonend)
  local n = number
       for i = 1, number do
           addEvent(doSendAnimatedText,i* 1000, pos, n > 1 and n.."" or msgonend .."", n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
		   addEvent(doSendMagicEffect,i* 1000, pos, n > 1 and effect or effectonend )
              n = n -1
	   end
      n = number
return true
end

function removed(cid)
	doCreatureSetNoMove(cid, 0)
	setPlayerStorageValue(cid,979880,-1)
	doRemoveCondition(cid,CONDITION_EXHAUST,1)
	doRemoveCondition(cid,CONDITION_EXHAUST,2)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.get(cid,storage) then
		return doPlayerSendCancel(cid,"You can't use this yet.")
	end
	
	if not isPlayer(itemEx.uid) or cid == itemEx.uid then
		return doPlayerSendCancel(cid,"You can only use this on another players.")
	end
	
	doSendAnimatedText(getThingPos(itemEx.uid),"Freezed!", TEXTCOLOR_BLUE)
	exhaustion.set(cid,storage,cooldown)
	doCombat(cid, combat, numberToVariant(itemEx.uid))
	setPlayerStorageValue(itemEx.uid,979880,1)
	doCreatureSetNoMove(itemEx.uid, 1)
	countDown(3, toPosition, 0, "melted", 5)
	addEvent(removed,freezetime*1000,itemEx.uid)
	return true
end
 
LUA:
local freezetime = 4   

local cooldown = 10   -- time to use again

local storage = 19001

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaust)

local exhaustt = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustt, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustt, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, exhaustt)

function countDown(number, pos, effect, msgonend, effectonend)
	local n = number
	for i = 1, number do
		addEvent(doSendAnimatedText,i*1000, pos, n > 1 and n or msgonend, n < 6 and TEXTCOLOR_RED or TEXTCOLOR_GREEN)
		addEvent(doSendMagicEffect,i*1000, pos, n > 1 and effect or effectonend )
			n = n -1
	end
	n = number
end

function removed(cid)
	if isPlayer(cid) then
		doCreatureSetNoMove(cid, 0)
		setPlayerStorageValue(cid, 979880)
		doRemoveCondition(cid, CONDITION_EXHAUST, 1)
		doRemoveCondition(cid, CONDITION_EXHAUST, 2)
	end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.get(cid,storage) then
		return doPlayerSendCancel(cid,"You can't use this yet.")
	elseif not isPlayer(itemEx.uid) or cid == itemEx.uid then
		return doPlayerSendCancel(cid,"You can only use this on other players.")
	end

	doSendAnimatedText(toPosition, "Freezed!", TEXTCOLOR_BLUE)
	exhaustion.set(cid, storage, cooldown)
	doCombat(cid, combat, numberToVariant(itemEx.uid))
	setPlayerStorageValue(itemEx.uid, 979880, 1)
	doCreatureSetNoMove(itemEx.uid, true)
	countDown(3, toPosition, 0, "melted", 5)
	addEvent(removed, freezetime*1000, itemEx.uid)
	return true
end
 
Back
Top