• 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 Problem with NPC direction.

Nyarl666

Member
Joined
Sep 25, 2022
Messages
63
Reaction score
7
Hello. This NPC named Percival is always wrongly turned. I want it to be NORTH rotated and so I set it up in Remere's Map Editor. But it doesn't do anything :(
I also do not know what to do so that when the conversation with him ends (he turns behind the player - that's ok) he returns to his position (direction).
Thank you for any help :)

Bez tytułu.png

CODE:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Percival" script="Percival.lua" walkinterval="0" floorchange="0" speechbubble="3">
    <health now="150" max="150"/>
    <look type="128" head="94" body="113" legs="132" feet="115" addons="2" />
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. I sell 30 days of {premium} for 50000 gold pieces. "/>
    </parameters>
</npc>

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 greet(cid)   talkState[cid] = 0   return true end
function getNpcName() return getCreatureName(getNpcId()) 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
  
   local player_gold  = getPlayerItemCount(cid,2148)
   local player_plat  = getPlayerItemCount(cid,2152)*100
   local player_crys  = getPlayerItemCount(cid,2160)*10000
   local player_money  = player_gold + player_plat + player_crys
  
   if msgcontains(msg, "you") then
     selfSay("I sell {premium} for 30 days.", cid)
    
   -- Premium
   elseif msgcontains(msg, "premium") then
     selfSay("Would you like to receive your 30 premium days?", cid)
     talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 and player_money >= 50000 then
     doPlayerRemoveMoney(cid, 50000)
     doPlayerAddPremiumDays(cid, 30)
     selfSay("Congratulations! You have received 30 days of premium!", cid)
     talkState[talkUser] = 0
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 and player_money < 50000 then
     selfSay("You do not have enough gold to complete this transaction.", cid)
     talkState[talkUser] = 0
  
   -- If they say something other then yes
   elseif msgcontains(msg, "no") and talkState[talkUser] >= 1 then
     selfSay("No then.", cid)
     talkState[talkUser] = 0
    
   end
   return true   
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top