Hello!
I am working on creating some chat features for my server, one of the chat ideas is roleplaying.
Idea:
/me is depressed about what he sees.
[Me] (Nick) is depressed about what he sees.
/gme is quite astounded by the devs
[GlobalMe] (Nick) is quite astounded by the devs
Same with being dead, except you get the dead tag in front.
/me is depressed about what he sees.
*DEAD* [Me] (Nick) is depressed about what he sees.
/gme is quite astounded by the devs
*DEAD* [GlobalMe] (Nick) is quite astounded by the devs
So like an if / else if - just in case the person is dead.
[CODE]
local RoleplayGlobalMe =
local RoleplayLocalMe =
hook.Add( "PlayerSay", "RoleplayGlobalMe", function( ply, Text, Team, PlayerIsDead )
if ( string.sub( text, 1, 4 ) == "/gme" ) then -- if the first four characters of the string are /gme
if ply:Alive() then
chat.AddText(Color(190, 255, 100, 255), "[GlobalMe] ", ply:Nick(), Color(80, 100, 100, 0), .. string.sub( text, 5 )) -- add [GlobalMe] (Nick) in front of the players text then display
else
chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(190, 255, 100, 255), "[GlobalMe] ", ply:Nick(), Color(80, 100, 100, 0), .. string.sub( text, 5 )) -- add *DEAD* [GlobalMe] (Nick) in front of the players text
end
return true
end
end)
hook.Add( "PlayerSay", "RoleplayLocalMe", function( ply, Text, Team, PlayerIsDead )
if ( string.sub( text, 1, 3 ) == "/me" ) then -- if the first four characters of the string are /me
if ply:Alive() then
chat.AddText(Color(190, 255, 100, 255), "[Me] ", ply:Nick(), Color(80, 100, 100, 0), .. string.sub( text, 4 )) -- add [Me] (Nick) in front of the players text then display
else
chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(190, 255, 100, 255), "[Me] ", ply:Nick(), Color(80, 100, 100, 0), .. string.sub( text, 4 )) -- add *DEAD* [Me] (Nick) in front of the players text
end
return true
end
end)
[/CODE]
Can someone assist with this or tell me where I am going wrong?
Also I tried mounting to the server - addons/roleplayme/lua/autorun/client/cl_roleplayme.lua
And the server is not picking up on the folder.
I tried adding an addition lua for the server - addons/roleplayme/lua/autorun/client/sv_roleplayme.lua
In which the contents:
[CODE]AddCSLuaFile( "cl_roleplayme.lua" )[/CODE]
But the server is refusing to load it.
I have Chat Tags installed, not sure if this is conflicting. Same with ULX. [URL="http://steamcommunity.com/sharedfiles/filedetails/?id=272591265"]http://steamcommunity.com/sharedfiles/filedetails/?id=272591265[/URL]
Since it is overriding the chatbox..
[CODE]
hook.Add("OnPlayerChat", "Tags", function(ply, Text, Team, PlayerIsDead)
if ply:IsValid() then
for k,v in pairs(Tags) do
if ply:IsUserGroup(v[1]) then
if Team then
if ply:Alive() then
chat.AddText(Color(190, 255, 100, 255), "[Global] ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
else
chat.AddText(Color(255, 0, 0, 255), "*DEAD*", Color(190, 255, 100, 255), "[Global] ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
end
return true
end
if ply:IsPlayer() then
if ply:Alive() then
chat.AddText(Color(255, 0, 0, 255), "", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
return true
elseif !ply:Alive() then
chat.AddText(Color(255, 0, 0, 255), "*Dead* ", v[3], v[2], Color(50, 50, 50, 255), "| ", v[3], ply:Nick(), color_white, ": ", Color(255, 255, 255, 255), Text)
return true
end
end
end
end
end
end)
[/CODE]
****Resolved****
Regarding the first piece of code, i didn't look at it but u want it serversided?
Why do u put it in /client? (addons/roleplayme/lua/autorun[B]/client/[/B])
put it in addons/roleplayme/lua/autorun/[B]server[/B]/
tzahush,
Thanks, that mounted. Now I can work on getting this thing to work. I deserve a dummy smack though...
"https://wiki.garrysmod.com/page/GM/PlayerSay"
Only adds the message after what the player says. I deserve a dummy smack. "Player Say" Not "Player Name" >.>
Will be fixing that, but that resolved the issue.
I did a test, came out like...
[Global] Dipshit Owner| Kawaii, Believe It!: [GlobalMe] Test
[code]
hook.Add( "PlayerSay", "RoleplayGlobalMe", function( ply, text, team )
if ( string.sub( text, 1, 4 ) == "/gme" ) then -- if the first four characters of the string are /gme
return "[GlobalMe] " .. string.sub( text, 5 ) -- add [GlobalMe] in front of the players text then display
end
end )
[/code]
Time to do my research.
If you need help, be sure to add me on steam.
[QUOTE=tzahush;51877145]If you need help, be sure to add me on steam.[/QUOTE]
Awesome, will do! Thanks!
Sorry, you need to Log In to post a reply to this thread.