Guard speaks when you come close menu

User Tag List

Results 1 to 6 of 6
  1. #1
    Fumi's Avatar Contributor CoreCoins Purchaser
    Reputation
    207
    Join Date
    Feb 2008
    Posts
    561
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Guard speaks when you come close

    Would you be able to make a guard say something when you come close in Lua, i know you can in C++ but i need it in Lua and if you are able to how would it look?

    thanks

    Guard speaks when you come close
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function OnSpawn(pUnit, Event)
      pUnit:RegisterEvent("CheckForPlayers", 1000, 0)
    end
    
    function CheckForPlayers(pUnit)
      local plr = pUnit:GetClosestPlayer()
      if plr ~= nil then
        if pUnit:GetDistanceYards(plr) < 10 then
          pUnit:SendChatMessage(12,0,"Stay away!")
        end
      end
    end
    
    RegisterUnitEvent(npcid, 18, "OnSpawn")

  3. #3
    Fumi's Avatar Contributor CoreCoins Purchaser
    Reputation
    207
    Join Date
    Feb 2008
    Posts
    561
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    Code:
    function OnSpawn(pUnit, Event)
      pUnit:RegisterEvent("CheckForPlayers", 1000, 0)
    end
    
    function CheckForPlayers(pUnit)
      local plr = pUnit:GetClosestPlayer()
      if plr ~= nil then
        if pUnit:GetDistanceYards(plr) < 10 then
          pUnit:SendChatMessage(12,0,"Stay away!")
        end
      end
    end
    
    RegisterUnitEvent(npcid, 18, "OnSpawn")
    Thanks, is the 10 the range from the guard?

  4. #4
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Yes, in yards.

    Currently it will keep sending that message very second while you are less than 10 yards away from the npc.

    You can make it only sent the message by removing events (pUnit:RemoveEvents()) and then registering when you next want the function to be called.

  5. #5
    Fumi's Avatar Contributor CoreCoins Purchaser
    Reputation
    207
    Join Date
    Feb 2008
    Posts
    561
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i cant seem to get it to work i placed it in script folder as guard.lua

    Code:
    function OnSpawn(pUnit, Event)
      pUnit:RegisterEvent("CheckForPlayers", 1000, 0)
    end
    
    function CheckForPlayers(pUnit)
      local plr = pUnit:GetClosestPlayer()
      if plr ~= nil then
        if pUnit:GetDistanceYards(plr) < 10 then
          pUnit:SendChatMessage(12,0,"Its dangerous out there!")
        end
      end
    end
    
    RegisterUnitEvent(99990, 99990, "OnSpawn")
    Last edited by Fumi; 03-31-2011 at 01:01 PM.

  6. #6
    bendaferi's Avatar Active Member
    Reputation
    34
    Join Date
    Jun 2008
    Posts
    111
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is in this line
    Code:
    RegisterUnitEvent(99990, 99990, "OnSpawn")
    you changed the "18" (on load) to the NPCs ID. Just write it back to 18.
    Code:
    RegisterUnitEvent(99990, 18, "OnSpawn")

Similar Threads

  1. *POLL* Will you still use Honorbuddy if and when it comes back online?
    By xcureanddisease in forum World of Warcraft General
    Replies: 0
    Last Post: 05-15-2015, 09:50 PM
  2. What to do when you are waiting for your copy of AOC to come.
    By gilthbric in forum Age of Conan Exploits|Hacks
    Replies: 10
    Last Post: 06-03-2008, 10:13 AM
  3. How'd you come up with your name?
    By idusy-org in forum Community Chat
    Replies: 233
    Last Post: 08-18-2007, 12:31 PM
All times are GMT -5. The time now is 10:55 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search