NPC Lua script not working. (For unknown reason) menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    Joakim Karbing's Avatar Member
    Reputation
    1
    Join Date
    Feb 2016
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NPC Lua script not working. (For unknown reason)

    Dialogue/Spells wont trigger. No errors in world.exe. (Using ArcEmu)

    Any suggestions? ;(

    Code:
    local Name = Pontus
    local NPCID = 100001
    
    ---------------Standard---------------------
    function Pontus_OnCombat(pUnit, event, player)
    pUnit:SendChatMessage(12, 0, "Ni kommer försent!")
    pUnit:RegisterEvent("Pontus_Phase1", 1000, 1)
    end
    
    function Pontus_OnLeaveCombat(pUnit, event, player)
    pUnit:SendChatMessage(14, 0, "Har ni gjort färdigt era gymnasiearbeten?")
    pUnit:RemoveEvents()
    end
    
    function Pontus_OnDeath(pUnit, event, player)
    pUnit:SendChatMessage(12, 0, "Det här ska ni skita i...")
    pUnit:RemoveEvents()
    end
    ----------------------------------------------
    --------------------Phases--------------------
    function Pontus_Phase1(pUnit, event, player)
    if pUnit:GetHealthPct() == 80 then
    pUnit:SendChatMessage(12, 0, "Ni slösar bort eran tid!")
    pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
    pUnit:SetCombatCapable(1)
    pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.096680, -3096.876953, 268.675476, 100003))
    pUnit:RegisterEvent("Pontus_Phase2", 1000, 1)
    end
    end
    
    function Pontus_Phase2(pUnit, event, player)
    if pUnit:GetHealthPct() == 60 then
    pUnit:SendChatMessage(12, 0, "Håll Käften!")
    pUnit:CastSpell(64189)
    pUnit:SetCombatCapable(0)
    pUnit:RegisterEvent("Pontus_Phase3", 1000, 1)
    end
    end
    
    function Pontus_Phase3(pUnit, event, player)
    if pUnit:GetHealthPct() == 40 then
    pUnit:SendChatMessage(12, 0, "Ni kommer få indraget CSN!")
    pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.284668, -3103.452881, 268.674347, 100003))
    pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
    pUnit:RegisterEvent("Pontus_Volley", 10000, 0)
    pUnit:CastSpell(57381)
    pUnit:RegisterEvent("Pontus_Phase4", 1000, 1)
    pUnit:SetCombatCapable(1)
    end
    end
    
    function Pontus_Phase4(pUnit, event, player)
    if pUnit:GetHealthPct() == 20 then
    pUnit:SendChatMessage(12, 0, "SKA JAG TA KONTAKT MED ERA FÖRÄLDRAR?")
    pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.408448, -3098.933350, 286.500397, 100003))
    pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
    pUnit:CastSpell(68872)
    pUnit:SetCombatCapable(0)
    end
    end
    -----------------------------------------------
    
    ------------------------Spells----------------
    function Pontus_RandomAoeGround(pUnit, event, player)
    pUnit:FullCastSpellOnTarget(50752, pUnit:GetRandomPlayer(0))
    end
    
    function Pontus_Volley(pUnit, event, player)
    pUnit:CastSpell(57381)
    end
    ----------------------------------------------
    RegisterUnitEvent(100001, 1, "Pontus_OnCombat")
    RegisterUnitEvent(100001, 2, "Pontus_OnLeaveCombat")
    RegisterUnitEvent(100001, 4, "Pontus_OnDeath")

    NPC Lua script not working. (For unknown reason)
  2. #2
    Joakim Karbing's Avatar Member
    Reputation
    1
    Join Date
    Feb 2016
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    fixed it.

    the problem was this: pUnit:GetCreatureNearestCoords
    was supposed to be only Unit:GetCreatureNearestCoords

  3. #3
    Joakim Karbing's Avatar Member
    Reputation
    1
    Join Date
    Feb 2016
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But only the first OnCombat part worked, nothing else triggers.

  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)
    I hate to go off topic like this but, I'm going to anyway.

    ArcEmu is really bad and hasn't even been developed for going on 5 years it must be now. The Lua engine has known stability issues that were never fixed.

    TrinityCore is pretty much the most you could ever ask for out of a emulator. 3.3.5a default checkout can run 2000 players stable. With the Eluna project you can even have a Lua engine, which is what I use. For example, something I am working on at the moment for a scaling health system:

    Code:
    local playerDistance = 80
    local minPlayerScaling = 5
    
    function Creature:GetScaledDamage(damage)
    	local p = self:GetPlayersInRange(playerDistance)
    	if not p or #p < 5 then
    		return damage * 3.5
    	end
    	return damage * (1 + (#p / 2))
    end
    
    --[[
    function Creature:GetMaxScaledHealth()
    	local hp = maxHealthMap[self:GetGUIDLow()]
    	local p = self:GetPlayersInRange(playerDistance)
    	if not p or #p < 5 then
    		return hp * 5
    	end
    	return hp * (1 + (#p / 2))
    end
    ]]
    
    function Creature:UpdateScaledHealth()
    	local scaling = self:GetValue("currentScaling") or 1
    	local maxHealth = self:GetMaxHealth() / scaling;
    	local currentHealth = self:GetHealth() / scaling;
    	local players = #(self:GetPlayersInRange(playerDistance) or {});
    	scaling = math.max(minPlayerScaling, 1 + players / 2);
    	self:SetMaxHealth(maxHealth * scaling);
    	self:SetHealth(currentHealth * scaling);
    	self:SetValue("currentScaling", scaling);
    end
    
    function Creature:RegisterScalingHealth(hp)
    	if self then
    		local guid = self:GetGUID()
    		table.insert(healthMap, guid)
    	end
    end
    
    local function ScaleCreatureHealths(_, _, _)
    	for _,v in pairs(healthMap) do
    		local pUnit = GetCreatureByGUID(v)
    		if pUnit and pUnit:IsAlive() then
    			pUnit:UpdateScaledHealth()
    		end
    	end
    end
    
    CreateLuaEvent(ScaleCreatureHealths, 5000, 0)

  5. #5
    Tikki100's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2008
    Posts
    83
    Thanks G/R
    3/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Stoneharry said, I would recommend Eluna as well

    I did notice something in your code, however

    Code:
    pUnit:RegisterEvent("Pontus_Phase1", 1000, 1)
    That command calls the Phase1 only once, after 1 second. When it jumps down to Phase 1, the unit hasn't lost enough health, and the script stops there.

    Change 1 to a 0, so that it becomes:

    Code:
    pUnit:RegisterEvent("Pontus_Phase1", 1000, 0)
    This should also be changed in

    Code:
    pUnit:RegisterEvent("Pontus_Phase2", 1000, 1)
    to
    Code:
    pUnit:RegisterEvent("Pontus_Phase2", 1000, 0)
    You should also include a RemoveEvents, so that the phaes stops being called, once a new phase is activated.

    Try this (changed marked in red):

    Code:
    local Name = "Pontus" --Is there any reason, that this is a variable? If so, it should be a string. 
    local NPCID = 100001
    
    ---------------Standard---------------------
    function Pontus_OnCombat(pUnit, event, player)
    pUnit:SendChatMessage(12, 0, "Ni kommer försent!")
    pUnit:RegisterEvent("Pontus_Phase1", 1000, 0)
    end
    
    function Pontus_OnLeaveCombat(pUnit, event, player)
    pUnit:SendChatMessage(14, 0, "Har ni gjort färdigt era gymnasiearbeten?")
    pUnit:RemoveEvents()
    end
    
    function Pontus_OnDeath(pUnit, event, player)
    pUnit:SendChatMessage(12, 0, "Det här ska ni skita i...")
    pUnit:RemoveEvents()
    end
    ----------------------------------------------
    --------------------Phases--------------------
    function Pontus_Phase1(pUnit, event, player)
    if pUnit:GetHealthPct() == 80 then
    pUnit:RemoveEvents() --To prevent the function to be called, once we go to phase 2.
    pUnit:SendChatMessage(12, 0, "Ni slösar bort eran tid!")
    pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
    pUnit:SetCombatCapable(1)
    pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.096680, -3096.876953, 268.675476, 100003))
    pUnit:RegisterEvent("Pontus_Phase2", 1000, 0)
    end
    end
    
    function Pontus_Phase2(pUnit, event, player)
    if pUnit:GetHealthPct() == 60 then
    pUnit:SendChatMessage(12, 0, "Håll Käften!")
    pUnit:CastSpell(64189)
    pUnit:SetCombatCapable(0)
    pUnit:RegisterEvent("Pontus_Phase3", 1000, 0)
    end
    end
    
    function Pontus_Phase3(pUnit, event, player)
    if pUnit:GetHealthPct() == 40 then
    pUnit:SendChatMessage(12, 0, "Ni kommer få indraget CSN!")
    pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.284668, -3103.452881, 268.674347, 100003))
    pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
    pUnit:RegisterEvent("Pontus_Volley", 10000, 0)
    pUnit:CastSpell(57381)
    pUnit:RegisterEvent("Pontus_Phase4", 1000, 0)
    pUnit:SetCombatCapable(1)
    end
    end
    
    function Pontus_Phase4(pUnit, event, player)
    if pUnit:GetHealthPct() == 20 then
    pUnit:SendChatMessage(12, 0, "SKA JAG TA KONTAKT MED ERA FÖRÄLDRAR?")
    pUnit:ChannelSpell(47855, pUnit:GetCreatureNearestCoords(2759.408448, -3098.933350, 286.500397, 100003))
    pUnit:RegisterEvent("Pontus_RandomAoeGround", 2000, 0)
    pUnit:CastSpell(68872)
    pUnit:SetCombatCapable(0)
    end
    end
    -----------------------------------------------
    
    ------------------------Spells----------------
    function Pontus_RandomAoeGround(pUnit, event, player)
    pUnit:FullCastSpellOnTarget(50752, pUnit:GetRandomPlayer(0))
    end
    
    function Pontus_Volley(pUnit, event, player)
    pUnit:CastSpell(57381)
    end
    ----------------------------------------------
    RegisterUnitEvent(100001, 1, "Pontus_OnCombat")
    RegisterUnitEvent(100001, 2, "Pontus_OnLeaveCombat")
    RegisterUnitEvent(100001, 4, "Pontus_OnDeath")

Similar Threads

  1. Halp please lua script not working
    By thebigman in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 09-29-2009, 06:06 PM
  2. LUA script not working
    By Dz The Rage in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 04-04-2009, 09:26 PM
  3. LUA script not working
    By pedobear123 in forum World of Warcraft General
    Replies: 12
    Last Post: 09-01-2008, 09:38 AM
  4. [Help] Lua Script Not Working
    By Muruk in forum World of Warcraft Emulator Servers
    Replies: 26
    Last Post: 03-16-2008, 02:13 PM
  5. Simple Lua Script , not working need help!
    By Arugos in forum World of Warcraft Emulator Servers
    Replies: 16
    Last Post: 12-30-2007, 02:06 PM
All times are GMT -5. The time now is 04:45 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