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

Solved A PVP channel?

Status
Not open for further replies.

Samaster

Raptorserver.ddns.net
Joined
Jun 9, 2013
Messages
291
Reaction score
23
Location
UK
Hi, I would like a PVP channel that all players can open and see when players kill other players; but not be able to talk in it.

I only have a XML file of the list of channels at the moment and have no idea what else to do:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
    <!-- README:
        0 - dynamic, reserved for guilds
        1 - always acts as Party channel, only "name" tag available
        3 - always acts as Rule Violations channel
        9 - acts as Help channel- clientsided message
        65535 - DO NOT CHANGE THE ID- only "name", "enabled", "active" and "logged" tags available
     -->
    <channel id="1" name="Party"/>
    <channel id="2" name="Staff" access="3"/>
    <channel id="3" name="Rule Violations" logged="yes"/>
    <channel id="4" name="Counsellor" access="1"/>
    <channel id="5" name="Game Chat" level="2"/>
    <channel id="6" name="Trade" level="8" muted="120" conditionId="2" conditionMessage="You may only place one offer in two minutes.">
        <vocation id="1-12"/>
    </channel>
    <channel id="7" name="Trade-Rookgaard" level="2" muted="120" conditionId="3" conditionMessage="You may only place one offer in two minutes.">
        <vocation id="0"/>
    </channel>
    <channel id="8" name="RL-Chat" level="2"/>
    <channel id="9" name="Help" logged="yes"/>
    <channel id="65535" name="Private Chat Channel"/>
</channels>

An example of what I would like to appear in this channel would be:

01:23 Player 1 [LEVEL] has slain Player 2 [LEVEL]. Justified
01:23 Player 3 [LEVEL] has slain Player 1 [LEVEL]. Unjustified
etc


Could someone help me please?

Thanks
 
Code:
player:sendChannelMessage(author, text, type, channelID)
and
Code:
event onDeath/onKill

I am not sure how to block chatting but you can try with mute script.
 
Add a new channel in the list and I you have to set the attribute enabled or active to "no" so nobody can talk in it.
Then send messages to the channel in onKill creatureevent.
 
This is what I've done so far:
Code:
    <channel id="10" name="PVP" logged ="yes" muted="yes" conditionId="4" conditionMessage="You cannot talk in this channel.">
        <vocation id="1-12"/>
    </channel>

When i add
Code:
muted="yes"
it doesn't mute the channel?

Also, Hernest, where do I put that or add that to?
 
You should have mentioned your TFS version since the beginning
channels.xml
Code:
<channel id="10" name="Events" active="no"/>

050-function.lua
Code:
function doChannelBroadcast(message, class)
    for _, cid in ipairs(getPlayersOnline()) do
        doPlayerSendChannelMessage(cid, '', message, class, 10)
    end
end

working message classes:
8 (white)
13 (red)
15 (orange)

sample:
Code:
doChannelBroadcast("[Event] This is a test message.", 8)
 
What I have atm is: (this code works)
Code:
<channel id="10" name="PVP" active="no"/>
and something I tried to make but doesn't work:
Code:
function onDeath do
     for _, cid in ipairs(getPlayersOnline()) do
        ChannelBroadcast("[PVP] This is a test message.", 8)
        doPlayerSendChannelMessage(cid, '', message, class, 10)
        end
     end
end
what do I need to change?
 
That's now how creature events are written at 0.3.6
You don't need to iterate again to all players since my function does it
Code:
function onDeath(cid, corpse, deathList)
     ChannelBroadcast("[PVP] This is a test message.", 8)
     return true
end
You have to register event to the player at login.lua and add its xml line at creaturescripts.xml
 
Code:
<event type="death" name="PlayerDeath" event="script" value="login.lua"/>
Would this be ok for creaturescripts.xml?

And for the login.lua event, do I just add the same thing as I did in 050-function.lua?

(Sorry for asking so stupid things)
 
^Yes that will work, but you have to add the onKill function below the onLogin function, at the end.
Once you add my function at 050-function.lua you can use it anywhere, don't need to declare it again.

Just add:
Code:
level="99999"
and nobody will speak there.
That is so needless having the 'active' tag of channels.xml
 
okay, so I've added this atm:

Channels.xml
Code:
<channel id="10" name="PVP" logged="yes" active="no"/>

Creaturescripts.xml
Code:
<event type="death" name="PlayerDeath" event="script" value="login.lua"/>

Login.lua
Code:
function onDeath(cid, corpse, deathList)
     ChannelBroadcast("[PVP] This is a test message.", 8)
     return true
end

050-function.lua
Code:
function onDeath(cid, corpse, deathList)
     ChannelBroadcast("[PVP] This is a test message.", 8)
     return true
end

But when I kill another player, nothing appears in the channel. I know, somewhere, something that links the kill to the player names and levels, and all of that to the channel ID needs to be added but I don't know how to put that in a script properly.

This is my attempt (added to login.lua) as a new script:
Code:
function onKill(cid, target, lastHit)
     ChannelBroadcast("[PVP] ".. getPlayerName(cid) .." has slain ".. getPlayerName(target), 8)
     end

I have added this is creaturescripts.xml:
Code:
<event type="kill" name="PlayerKill" event="script" value="login.lua"/>

But this doesn't work?
 
You need to register the onKill event in login.lua, though it seems like you have renamed it to something else.

Code:
registerCreatureEvent(cid, "PlayerKill")
 
okay I have added it in but I get this error:
Code:
[25/07/2014 21:19:18] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/login.lua:67: unexpected symbol near 'then'
[25/07/2014 21:19:18] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)
[25/07/2014 21:19:18] data/creaturescripts/scripts/login.lua:67: unexpected symbol near 'then'

This is my onKill script in login.lua (the only one I've changed):
Code:
function onKill(cid, target, lastHit)
     do registerCreatureEvent(cid, "PlayerKill") then
         doChannelBroadcast("[PVP] ".. getPlayerName(cid) .." has slain ".. getPlayerName(target), 8)
     end
end

EDITED:

I don't get any errors with this script, but nothing happens still:
Code:
function onKill(cid, target, lastHit)
         registerCreatureEvent(cid, "PlayerKill")
         doChannelBroadcast("[PVP] ".. getPlayerName(cid) .." has slain ".. getPlayerName(target), 8)
         return true
     end
 
Last edited:
Okay I have been trying all sorts of things for the past couple of hours and I cannot get this to work, nothing ever comes up. I must be just missing something rather than have put the wrong thing (or both):

Channels.xml:
Code:
<channel id="10" name="PVP" logged="yes" active="no"/>

Creaturescripts.xml:
Code:
<event type="death" name="PlayerDeath" event="script" value="login.lua"/>
<event type="kill" name="PlayerKill" event="script" value="login.lua"/>

050-function.lua:
Code:
function onDeath(cid, corpse, deathList)
doChannelBroadcast("[PVP] ".. getPlayerName(cid) .. " level ".. getPlayerLevel(cid) .." has slain ".. getPlayerName(target) .." level ".. getPlayerLevel(target) ..".", 8, 10)
return true
end

Login.lua:
Code:
function onDeath(cid, corpse, deathList)
      doChannelBroadcast("[PVP] ".. getPlayerName(cid) .. " level ".. getPlayerLevel(cid) .." has slain ".. getPlayerName(target) .." level ".. getPlayerLevel(target) ..".", 8, 10)
     return true
end

function onKill(cid, target, lastHit)
         registerCreatureEvent(cid, "PlayerKill")
         if isPlayer(target) == true then
          doChannelBroadcast("[PVP] ".. getPlayerName(cid) .. " level ".. getPlayerLevel(cid) .." has slain ".. getPlayerName(target) .." level ".. getPlayerLevel(target) ..".", 8, 10)
        end
    return true
end

Can someone please tell me what is wrong here?
 
Add the kill and death scripts in different scripts (remove from the lib 050-function.lua and login.lua) and register the names you used in creaturescripts.xml in login.lua
Code:
registerCreatureEvent(cid, "PlayerKill")
registerCreatureEvent(cid, "PlayerDeath")
 
Okay I've done that, but when I add this (first code) into login.lua, a player doesn't die when on 0 health and this error comes up on the server and spams until the player on 0 health logs out, and still nothing comes up on the PVP channel:
Code:
registerCreatureEvent(cid, "PlayerKill")
registerCreatureEvent(cid, "PlayerDeath")

Code:
[26/07/2014 09:26:02] [Error - CreatureScript Interface]
[26/07/2014 09:26:02] data/creaturescripts/scripts/playerkill.lua:onKill
[26/07/2014 09:26:02] Description:
[26/07/2014 09:26:02] data/creaturescripts/scripts/playerkill.lua:5: attempt to call global 'doChannelBroadcast' (a nil value)
[26/07/2014 09:26:02] stack traceback:
[26/07/2014 09:26:02]     data/creaturescripts/scripts/playerkill.lua:5: in function <data/creaturescripts/scripts/playerkill.lua:1>
 
Last edited:
Status
Not open for further replies.
Back
Top