• 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!

Solved No damage to teammates TFS 1.0

narko

vertrauenswürdig ~
Joined
Oct 19, 2008
Messages
1,317
Solutions
2
Reaction score
131
Location
Unknown
Code:
function onStatsChange(cid, attacker, type, combat, value)
    if type == 1 and getCreatureHealth(cid) <= value then
        if(getGlobalStorageValue(33165) == 1) then
                elseif isPlayer(attacker) and isPlayer(cid) then
                    if isPlayer then
                        if tostring(getPlayerStorageValue(cid, 16391)) == tostring(getPlayerStorageValue(cid, 16391)) then
                            return false
                        end
                    end
                end
                return true
            end
    end

I've been trying something like this, but when a player attacks an enemie it hits no DMG and when attacks a teammate either. @Limos just tagging you if you'd like to help me :)
 
Last edited:
Which TFS 1.0 version do you use? The default one doesn't have statschange, it has healthchange and manachange.
 
Yes, I had worked with tfs 1.1 and it has lots of new functions that tfs 1.0 doesn't, but unfortunately my server is based on 1.0 and I have to adapt the whole datapack and really don't want to do that.
 
Ehm no...
The main thing you have to change is the way arrows etc gets removed. That was moved from items.xml to weapons.xml
You can still utilize the compat.lua file.
 
Well that is something that im not interesting in. That is why I need a little help with this ^^^
 
better adapt it now since you will be forced to move once you note that there are so many bugs being fixed in 1.1 that you server you not have
 
When exactly is someone a teammate? Is this based on storage, party or something else?
If it's based on storage, do they both have the same storage value? Which storage and which value?

You can just check for isPlayer(attacker) and the storagevalue of both cid and attacker.
Code:
if isPlayer(attacker) and getPlayerStorageValue(cid, 16391) == getPlayerStorageValue(attacker, 16391) then
With TFS 1.0 functions
Code:
local player, attacker = Player(cid), Player(attacker)
if attacker and player:getStorageValue(16391) == attacker:getStorageValue(16391) then
If it needs to be both for example 1 you can compare both with 1.
Then return false if it's true.
Add return true above the last end.
 
Last edited:
red storage = 15000
blue storage = 1600

Code:
function onStatsChange(cid, attacker, type, combat, value)
    if type == 1 and getCreatureHealth(cid) <= value then
        if(getGlobalStorageValue(33165) == 1) then -- global storage when the event is running
                elseif isPlayer(attacker) and isPlayer(cid) then
                    if isPlayer then
                        if tostring(getPlayerStorageValue(cid, 15000)) == tostring(getPlayerStorageValue(attacker, 15000)) then  --- Check storages if they are the same 
                            return false
                        end
                    end
                end
                return true
            end
    end
 
Code:
if Game.getStorageValue(33165) ~= 1 then
     return true
end
local player, attacker = Player(cid), Player(attacker)
if type == 1 and attacker and (player:getStorageValue(15000) == attacker:getStorageValue(15000) or player:getStorageValue(1600) == attacker:getStorageValue(1600)) then
     return false
end
 
Players still damage each other.

3v54fwJL.png

code:
Code:
function onStatsChange(cid, attacker, type, combat, value)

if Game.getStorageValue(33165) ~= 1 then
     return true
end

local player, attacker = Player(cid), Player(attacker)
if type == 1 and attacker and (player:getStorageValue(15391) == attacker:getStorageValue(15391) or player:getStorageValue(15392) == attacker:getStorageValue(15392)) then
     return false
end
end

Do I have something wrong?
 
How did you registered it? Can you post the creaturescripts.xml and login.lua line?
You can also do: (type == 1 or type == 3) instead of just type == 1.

You can test results with print, for example
Code:
print(player:getStorageValue(15391))
 
creaturescripts.xml
Code:
<event type="statschange" name="States" script="events/rushcombat.lua"/>
login.lua
Code:
local events = {
     'States',
}
 
Actually last bug was produced because the event storage was always enable so I disabled and now getting this attacking teammates and enemies also.

i4kbqc.png

No damage against enemies or teammates.
 
Back
Top