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

[Question] Player X kills Player Y; Player Z is notified about it. How to? (+Repping)

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
Im under a lot of stress lately which is keeping me from thinking correctly so Im having quite a hard time figuring this one out, hopefully you will know better.

Basically it is what title says:
"Player X" kills "Player Y" and another player i.e "Player Z" who may or may not even be near the place where this happened, automatically receives a message notifying him about it (i.e "Player X has just killed Player Y.").

If you need a further example, lets say we have 2 teams of players fighting each other on an arena or similar, being:

Team A:
Player A + Player 1

Team B:
Player B + Player 2

So lets say the arena is huge and Player A went on fighting Player B on the upper part of the arena being really far from Player 1 and Player 2 which are on the bottom, in this case if Player A managed to kill Player B, his teammate Player 1 wouldnt be able to know (instantly at least), so my question is how can I make it so Player 1 receives this notification.

In the case Ill use it for, this "Player 1 and Player A" will have a storage that defines them as "Team A", and a different one for Team B, so the point is that if someone from Team B is killed, everyone with the storage for Team A will be notified.

What Im not looking for:

Global Broadcasting. Why? Because I dont want this broadcasted to the whole server, I want the notifications "broadcasted" (messaged) only to this exclusive amount of people (Team A/Team B).

So there you go, any idea how to pull this off? Also, it doesnt matter if you script for 0.2+ or 0.3+, I just need a reference to work with myself.

Thanks in advance, as always Ill be +repping any helpful answers.
(Notice that if you come up with a working solution and dont get +repped from me, it is most certainly because I received the error "must spread rep" thing, but Ill pay attention and try to +rep you everytime I log until I succeed :D)
 
let me ask somthng , is it pvp arena scripted or by map( i recommend scripted one for that :) )
so if it is a script it would be onStateChange
[Assuming you make teams by giving player special strages]
Lua:
local storage1 = 1213   --team1 storage 
local storage2 = 1344   -- team 2 storage
function onStatsChange(cid, attacker, type, combat, value)

   if combat == COMBAT_HEALING then
                return true
        end

        if getCreatureHealth(cid) > value then
                return true
        end

     if getPlayerStorageValue(cid,Storage1) > 0 then
         for _, pid in ipairs(getPlayersOnline()) do
             if getPlayerStorageValue(pid,Storage1) > 0 then
                   doPlayerSendTextMessage(pid,MESSAGE_EVENT_ADVANCE."You team mate : "..getPlayerName(cid).." have       been killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
             end 
         end
     elseif getPlayerStorageValue(cid,Storage2) > 0 then
         for _, pid in ipairs(getPlayersOnline()) do
             if getPlayerStorageValue(pid,Storage2) > 0 then
                   doPlayerSendTextMessage(pid,MESSAGE_EVENT_ADVANCE."You team mate : "..getPlayerName(cid).." have       been killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
             end 
         end
     end
return true
end

This script the main part of it will be + the one you have for the arena
 
Last edited:
let me ask somthng , is it pvp arena scripted or by map( i recommend scripted one for that :) )
so if it is a script it would be onStateChange
[Assuming you make teams by giving player special strages]
Lua:
local storage1 = 1213   --team1 storage 
local storage2 = 1344   -- team 2 storage
function onStatsChange(cid, attacker, type, combat, value)

   if combat == COMBAT_HEALING then
                return true
        end

        if getCreatureHealth(cid) > value then
                return true
        end

     if getPlayerStorageValue(cid,Storage1) > 0 then
         for _, pid in ipairs(getPlayersOnline()) do
             if getPlayerStorageValue(pid,Storage1) > 0 then
                   doPlayerSendTextMessage(pid,MESSAGE_EVENT_ADVANCE."You team mate : "..getPlayerName(cid).." have       been killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
             end 
         end
     elseif getPlayerStorageValue(cid,Storage2) > 0 then
         for _, pid in ipairs(getPlayersOnline()) do
             if getPlayerStorageValue(pid,Storage2) > 0 then
                   doPlayerSendTextMessage(pid,MESSAGE_EVENT_ADVANCE."You team mate : "..getPlayerName(cid).." have       been killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
             end 
         end
     end
return true
end

This script the main part of it will be + the one you have for the arena

Hey there thanks for the reply.

Answering to your question, yes it is by map, it is some sort of MOBA-type of server. So thats why I stated on my post I dont want it broadcasted for all server because there are several maps of different teams each doing their own thing and each should get the respective messages and such.

(For the record, I honestly dont think Ill be able to make a MOBA-type of server correctly lol but well it is a private server for my friends and family so I have to give it a shot, got nothing to lose :D)

And yep, the teams are defined by storages as you correctly stated.

I had never worked with onStatsChange so I will try out what you suggested today and post here the results.

Thanks again, +rep for you.
If you (or anyone) have anything else to add feel free to.
 
Back
Top Bottom