General > Developers Corner
Gmod automatic AOD god (and message)
(1/1)
Shadowmist:
Hello there, I was wondering if you guys have an idea on how to make it say "*player* has gone AOD!"
Here's my system for the godmode
--- Code: ---if (SERVER) then
local adminondutyteams = { TEAM_ADMIN }
hook.Add("PlayerShouldTakeDamage", "godmodeAdminsss", function(ply)
if ( ply:IsPlayer() ) then
for i, v in ipairs(adminondutyteams) do
if ply:Team() == v then
return false
end
end
end
end
--- End code ---
But does anyone have a clue how to make it so it says *playername* has gone aod!?
Would I have to make a PlayerSay hook that gets called when they go admin on duty? I am not sure how though.
Maybe
if Player:Team == TEAM_ADMIN then
AddChat( "v:Nick has gone AOD!" )
?????? Thank you.
Shadowmist:
I need to test this ingame but I believe I've found it.
--- Code: ---concommand.Add( "Shadowfunc",
function shadowfunction()
local ply = LocalPlayer()
if ply:Team() == "TEAM_ADMIN" then
ply:GodEnable
else
print "You're not admin! You can NOT have godmode! HAHAHAH"
end
end
--- End code ---
Lmao wait I forgot to add the addchat thing.. the point in making this post xD
BlueNova:
This is just something I noticed.
But first thing when you have
--- Code: ---print "You're not admin! You can NOT have godmode! HAHAHAH"
--- End code ---
It prints in console. If you want an error print it's more like
--- Code: ---ULib.tsayError( calling_ply, "You're not admin, you cannot have godmode!" )
--- End code ---
Furthermore,
When you try to get someone's nickname it needs to be v:Nick()
Just doing v:Nick won't work (at least I won't think it will)
As for
--- Quote ---But does anyone have a clue how to make it so it says *playername* has gone aod!?
Would I have to make a PlayerSay hook that gets called when they go admin on duty? I am not sure how though.
Maybe
if Player:Team == TEAM_ADMIN then
AddChat( "v:Nick has gone AOD!" )
?????? Thank you.
--- End quote ---
Perhaps adding the following instead
--- Code: ---ulx.fancyLogAdmin( calling_ply, "#A has gone AOD!" )
--- End code ---
though DarkRP should have a default way to echo if someone changes class.
I haven't worked with DarkRP too much so this may not be 100% correct, but it's just stuff I noticed.
Edit: Ignore most of the above. I didn't see you were making hooks and the likes. What I wrote probably won't work but I'll leave it just in case it does.
Shadowmist:
I have some sort of idea now.
I've scrapped all of that.
Here's how the chat thing works:
Serverside is
--- Code: ---util.AddNetworkString( "sf_name" )
concommand.Add( "Shadowfunc",
function aod()
local ply = LocalPlayer()
if ply:Team() == "TEAM_ADMIN" then
ply:GodEnable
else
print "You're not admin! You can NOT have godmode! HAHAHAH"
end
net.Start( "sf_name" )
net.WriteString( ply:Name )
net.Send( ply )
end )
--- End code ---
clientside is
--- Code: ---function HasGoneAod()
local name = net.ReadString()
chat.AddText( color( 0, 255, 255 ), name, "Has gone AOD! And have granted godmode upon themself.")
end
--- End code ---
Navigation
[0] Message Index
Go to full version