User Tag List

Page 2 of 2 FirstFirst 1 2
Results 8 to 9 of 9

Thread: A script linked to some NPCs

  1. #8
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Thanked 1,842 Times in 1,115 Posts
    Quote Originally Posted by susumakusu View Post
    Maybe @Rochet2 can explain me about the stability of assing multiple events in a script.
    There's nothing wrong with doing that. If it was such a huge "stability" issue we'd recommend not doing it or if possible fix the issue..

  2. #9
    Moderator / Eluna Dev <span style='color: #FF0000'><span class='glow_8B0000'>Rochet2</span></span>'s Avatar
    Join Date
    Apr 2013
    Thanked 560 Times in 390 Posts
    Yeah, there is no stability issue with that. Infact using the same function for multiple NPCs is more efficient since you only need one function instead of X amount of functions. So you save RAM.
    And like Grandelf said and Tommy implied, its a good practice not to repeat stuff.

    In general there should be no "stability issues" other than from something we have overlooked or your code does wrong in the logic.
    There are ways your code could set something in an incoherent state or you could possibly not notice some small detail.
    For example you could use async and sync database queries and possibly read old data, save new data and then save the old data you read over the new data.
    Or you could set a timed event go forever and ever cancel it. They do keep firing even if the NPC is dead for example.
    Or you could use the addvendoritem - or whats the method called - to add items to the vendor to make a "multivendor" but at the same time you destroy the chance for multiple ppl to use the vendor.

    Other than that there might be RAM consumed if your code is wrong or needs to hold a lot of DB data. Eluna in itself does need some RAM as well.
    Also efficiency can be limiting as checking hooks and such on events is done etc.

    One thing new programmers etc. do often miss is that all variables in the scripts are SHARED.
    This means that if you do
    local entry
    function OnSpawn(creature)
        entry = creature:GetEntry()
    RegisterCreatureEvent(ONSPAWN, 123, OnSpawn)
    RegisterCreatureEvent(ONSPAWN, 564, OnSpawn)
    Then in this case the entry is shared and the value of that variable changes over time depending on which entry NPC was last spawned ingame.
    So if you register a timed event that makes the NPCs say the value of the entry variable, they will keep saying different things depending on ingame spawns and they will NOT only say their own entry (even though when testing the script it might seem so)

    Also with same logic, passing stuff through the global or locally global scope between different events or functions is not a good idea. Same thing was basically happening with the multivendor example I said above.

    If you know of some stability or other issues, do report them :) Preferrably on our issue tracker:
    Last edited by Rochet2; 02-20-2016 at 12:39 AM.
    Support LOL Scripter Facepalm! Raffle Winner - Home of great codes

  3. The Following 4 Users Say Thank You to Rochet2 For This Useful Post:

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts