Ulysses Stuff > Releases

Player Chat Tags [2.58v]

<< < (12/56) > >>

Bite That Apple:

--- Quote from: Mates on October 28, 2013, 04:47:48 PM ---In the end I managed to solve it by writing similar function clientside, using the OnPlayerChat hook.  But I can still use this with other gamemodes, so thanks!

--- End quote ---

I'm glad you found yourself help. I may also use your advice, for future released of this and or other addons I make.

Mates:

--- Quote from: Mates on October 28, 2013, 04:47:48 PM ---In the end I managed to solve it by writing similar function clientside, using the OnPlayerChat hook.  But I can still use this with other gamemodes, so thanks!

--- End quote ---
I just realised your solution works exactly the same way I described mine, which is weird since it didn't work. I guess I will try it once more when I get a moment.

rainbow Dash:

--- Quote from: chaos13125 on October 28, 2013, 03:37:31 PM ---I wouldn't really know how to fix that, as I'm not too much into looking at the OOC chat part for darkrp. Someone who is familiar with Dark RP systems can maybe assist you, or such.

--- End quote ---

Well its simple, I'll give you a few tips to detect DarkRP and act accordingly.

To detect DarkRP, and this probably isn't the best way, but its how I do it, but to detect it (clientside) look for LocalPlayer().DarkRPVars.money

As for the tags... I think this file (darkrp/gamemode/modules/chat/sv_chatcommands.lua) might be of some help to you to add DarkRP support, be mindful that the chat command prefix is defined at GAMEMODE.Config.chatCommandPrefix.


--- Code: ---/*---------------------------------------------------------
Talking
 ---------------------------------------------------------*/
local function PM(ply, args)
local namepos = string.find(args, " ")
if not namepos then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end

local name = string.sub(args, 1, namepos - 1)
local msg = string.sub(args, namepos + 1)

if msg == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
target = DarkRP.findPlayer(name)

if target then
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(target, col, "(PM) "..ply:Nick(), Color(255,255,255,255), msg, ply)
DarkRP.talkToPerson(ply, col, "(PM) "..ply:Nick(), Color(255,255,255,255), msg, ply)
else
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("could_not_find", tostring(name)))
end

return ""
end
DarkRP.defineChatCommand("pm", PM, 1.5)

local function Whisper(ply, args)
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
DarkRP.talkToRange(ply, "(".. DarkRP.getPhrase("whisper") .. ") " .. ply:Nick(), text, 90)
end
return args, DoSay
end
DarkRP.defineChatCommand("w", Whisper, 1.5)

local function Yell(ply, args)
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
DarkRP.talkToRange(ply, "(".. DarkRP.getPhrase("yell") .. ") " .. ply:Nick(), text, 550)
end
return args, DoSay
end
DarkRP.defineChatCommand("y", Yell, 1.5)

local function Me(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end

local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
if GAMEMODE.Config.alltalk then
for _, target in pairs(player.GetAll()) do
DarkRP.talkToPerson(target, team.GetColor(ply:Team()), ply:Nick() .. " " .. text)
end
else
DarkRP.talkToRange(ply, ply:Nick() .. " " .. text, "", 250)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("me", Me, 1.5)

local function OOC(ply, args)
if not GAMEMODE.Config.ooc then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("disabled", DarkRP.getPhrase("ooc"), ""))
return ""
end

local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local col = team.GetColor(ply:Team())
local col2 = Color(255,255,255,255)
if not ply:Alive() then
col2 = Color(255,200,200,255)
col = col2
end
for k,v in pairs(player.GetAll()) do
DarkRP.talkToPerson(v, col, "("..DarkRP.getPhrase("ooc")..") "..ply:Name(), col2, text, ply)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("/", OOC, true, 1.5)
DarkRP.defineChatCommand("a", OOC, true, 1.5)
DarkRP.defineChatCommand("ooc", OOC, true, 1.5)

local function PlayerAdvertise(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(v, col, DarkRP.getPhrase("advert") .." "..ply:Nick(), Color(255,255,0,255), text, ply)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("advert", PlayerAdvertise, 1.5)

local function MayorBroadcast(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
if not RPExtraTeams[ply:Team()] or not RPExtraTeams[ply:Team()].mayor then DarkRP.notify(ply, 1, 4, "You have to be mayor") return "" end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
local col = team.GetColor(ply:Team())
DarkRP.talkToPerson(v, col, DarkRP.getPhrase("broadcast") .. " " ..ply:Nick(), Color(170, 0, 0,255), text, ply)
end
end
return args, DoSay
end
DarkRP.defineChatCommand("broadcast", MayorBroadcast, 1.5)

local function SetRadioChannel(ply,args)
if tonumber(args) == nil or tonumber(args) < 0 or tonumber(args) > 100 then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", "0<channel<100"))
return ""
end
DarkRP.notify(ply, 2, 4, DarkRP.getPhrase("channel_set_to_x", args))
ply.RadioChannel = tonumber(args)
return ""
end
DarkRP.defineChatCommand("channel", SetRadioChannel)

local function SayThroughRadio(ply,args)
if not ply.RadioChannel then ply.RadioChannel = 1 end
if not args or args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end
local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end
for k,v in pairs(player.GetAll()) do
if v.RadioChannel == ply.RadioChannel then
DarkRP.talkToPerson(v, Color(180,180,180,255), DarkRP.getPhrase("radio_x", ply.RadioChannel), Color(180,180,180,255), text, ply)
end
end
end
return args, DoSay
end
DarkRP.defineChatCommand("radio", SayThroughRadio, 1.5)

local function GroupMsg(ply, args)
if args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return ""
end

local DoSay = function(text)
if text == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
return
end

local t = ply:Team()
local col = team.GetColor(ply:Team())

local hasReceived = {}
for _, func in pairs(GAMEMODE.DarkRPGroupChats) do
-- not the group of the player
if not func(ply) then continue end

for _, target in pairs(player.GetAll()) do
if func(target) and not hasReceived[target] then
hasReceived[target] = true
DarkRP.talkToPerson(target, col, DarkRP.getPhrase("group") .. " " .. ply:Nick(), Color(255,255,255,255), text, ply)
end
end
end
if next(hasReceived) == nil then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("unable", "/g", ""))
end
end
return args, DoSay
end
DarkRP.defineChatCommand("g", GroupMsg, 1.5)

-- here's the new easter egg. Easier to find, more subtle, doesn't only credit FPtje and unib5
-- WARNING: DO NOT EDIT THIS
-- You can edit DarkRP but you HAVE to credit the original authors!
-- You even have to credit all the previous authors when you rename the gamemode.
local CreditsWait = true
local function GetDarkRPAuthors(ply, args)
local target = DarkRP.findPlayer(args); -- Only send to one player. Prevents spamming
if not IsValid(target) then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("player_doesnt_exist"))
return ""
end

if not CreditsWait then DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("wait_with_that")) return "" end
CreditsWait = false
timer.Simple(60, function() CreditsWait = true end)--so people don't spam it

local rf = RecipientFilter()
rf:AddPlayer(target)
if ply ~= target then
rf:AddPlayer(ply)
end

umsg.Start("DarkRP_Credits", rf)
umsg.End()

return ""
end
DarkRP.defineChatCommand("credits", GetDarkRPAuthors, 50)

--- End code ---

EDIT: But uh, just in case, I'm suggesting to FPtje to add a hook to his chat commands so that people can do all this.

npd1124:
for some reason it works and says the message when somone leaves but not when they join do you know how to fix this

this is the code

--- Code: ---// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
--surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
--surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)
--- End code ---

Bite That Apple:

--- Quote from: npd1124 on November 10, 2013, 12:57:51 PM ---for some reason it works and says the message when somone leaves but not when they join do you know how to fix this

this is the code

--- Code: ---// client side apple

// Spawn
function player_spawn( data )
local name1 = data:ReadString()
local nickteamcolour1 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour1, name1, Color( 255, 255, 255 ), " has joined in the server." )
--surface.PlaySound( "garrysmod/save_load1.wav" )
end
usermessage.Hook("player_spawn", player_spawn)

// Disconnect
function player_disconnect( data )
local name3 = data:ReadString()
local nickteamcolour3 = team.GetColor(data:ReadShort())
chat.AddText( Color( 5, 29, 168 ), "[FuZionGaming] ", nickteamcolour3, name3, Color( 255, 255, 255 ), " has left the server." )
--surface.PlaySound( "garrysmod/save_load2.wav" )
end
usermessage.Hook("player_disconnect", player_disconnect)
--- End code ---

--- End quote ---

Bro wrong thread topic. Please go here and paste your issues there:
http://forums.ulyssesmod.net/index.php/topic,6036.0.html

Though to put this out here. It looks like a serer side error, because I see not difference in the CLIENT side code.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version