• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Will this make my server laggy?

You don't need to add this to monsters when they aren't the one who will be using the event. Your first check is to make sure it is a player who is attacking, if it isn't then it returns, and the rest is not executed, so none of this script is meant for monsters, therefore no need in registering it for them. I don't see any reason this should lag your server, unless you have an insanely high rate for attack speed and TONS of players are steadily calling this event...
 
But it's the monsters who takes the extra damage, if I remove it from monsters (I have tried without, and it doesn't work), they take no extra damage, I added the player check because without it I took extra damage from monsters :p

Thanks for your answer though! I guess it won't make the server lagg :p
 
If you remove that from monsters events it really keeps them from taking the extra damage? Because that just doesn't even make sense to me. Have you tested this yourself thoroughly?
 
Yes, here's my test:

rCC7Clmfy.png


Trainers have the event while demons don't.

It's the creatures that lose HP (if type == STATSCHANGE_HEALTHLOSS then) so I think this why I have to make it for all mobs. So i'm still curious if this would cause much lagg, I would imagine it would be fine with normal attack speed etc like you said.

Maybe I could use onAttack instead? I'm not entirely sure if that would be better or even work, but this would require a more advanced script I guess and would it even make a difference in the end?
 
Last edited:
He is right, it needs to be on every monster.

Just look at the code a moment: (It runs FOR cid, which is the creature that was attacked, not the creature attacking)
Code:
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(attacker) then -- if a player attacks a creature (creature = cid)
if type == STATSCHANGE_HEALTHLOSS then -- If the creature (cid) takes damage to health
if combat ~= COMBAT_HOLYDAMAGE then -- If the combat is not holy damage
doTargetCombatHealth(attacker, cid, COMBAT_HOLYDAMAGE, -10, -10, CONST_ME_EXPLOSIONHIT) -- Add 10 extra holy damage
end
end
end
return true
end

This will not cause lag. At all. You do not need to worry about lag unless you have repeating scripts or errors.
Examples of Repeating scripts:
Code:
local count = 0
while count ~= 10000000000000000 do
  count = count + 1
end
---Or---
for a = 1, 10000000000000 do
  doPlayerSetStorageValue(cid, "laggyness", a)
end

Also, an easier way to add that to all monsters would to be registering it through an onSpawn script. (Rather than adding it to every monster xml file)

Unless you only want it on specific monsters that is**
 
You can add it to all monsters with two clicks with notepad++ but that wasn't my concern, only wanted to know if it was going to cause laggs! :)

Thanks everyone! I guess it will be fine to use on my live server! :D
Would be cool if I someone had skype or something that they'd be willing to give me, i'm working on a custom server and quite new to scripting, so that I don't have to create a new thread everytime I got some question like this :)
 
Last edited:
Would be cool if I someone had skype or something that they'd be willing to give me, i'm working on a custom server and quite new to scripting, so that I don't have to create a new thread everytime I got some question like this :)
That is what the forums are here for so you can create a new thread every time you have a question it can be answered by anyone rather than just 1 person.
 
That is what the forums are here for so you can create a new thread every time you have a question it can be answered by anyone rather than just 1 person.

PLUS, it also means your question will be answered for all eternity. So if anyone ever has this problem in the future, it is here to help them.
 
Please leave the original question as it was so others who might have the same question can find it and read it.

Agreed! It is like @Flatlander said, this thread could very well provide valuable information for ETERNITY! Well maybe not eternity, but for as long as this thread exists and others have the same question, it will be in their benefit to use the search function and find this thread...
 
Original question
Code:
Ahilphino Member

Joined:
Jun 5, 2013
Messages:
113
Ok, I made system to make some players get extra dmg after completing a quest.
This is my code:
Code:
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) then
    if type == STATSCHANGE_HEALTHLOSS then
        if combat ~=  COMBAT_HOLYDAMAGE then
            doTargetCombatHealth(attacker, cid, COMBAT_HOLYDAMAGE, -10, -10, CONST_ME_EXPLOSIONHIT)
        end
        end
    end
    return true
end
(I didn't add check for storagevalue from quest yet)

But I also had to register this in all my monsters with

<script>
<event name= "damageBaseIncrease"/>
</script>

Will this make my server lagg? And if so is there some better way to implement this?
 
^ Thanks for having my old post :) I'll remember not to edit next time :P

Now, another question - as my intention was to increase the damage with quests and whatnot - I guess adding something like this

Code:
local dmg = getPlayerStorageValue(attacker, 33333)

I suppose this would maybe cause some extra laggs? since every time it has to get the storagevalue from the player attacking? Or am I wrong again? :P
 
Back
Top