General > Developers Corner
Admin sounds, tools and other code chat.
JamminR:
Though I applaud you wanting to learn how to do what it is you're doing...you do know Umotd has a dynamic variable for both Super/Admins and current players, right?
jay209015:
Yes, but I don't want it to display current admins, I want it to list admins that have been in the server so I can know who's been doing their job/ and so user can find a list a active admins. As for the players.txt, do you have any idea why it's not writing to the file?
==EDIT==
Also the player.txt is so that users and I can know who all has been on the server.
JamminR:
Do both files already exist when you attempt to read them in the beginning? If neither exist, I'm pretty sure the script would error out.
Make sure, though from a comment you made in Umotd I think you are, that you're looking in gmod/data/Umotd , not gmod/addons/data/Umotd, for the file.
jay209015:
--- Quote ---Do both files already exist when you attempt to read them in the beginning? If neither exist, I'm pretty sure the script would error out.
--- End quote ---
They both exist and have content, and the admins.txt is working fine. It's just the players.txt that's not for some reason.
--- Quote ---Make sure, though from a comment you made in Umotd I think you are, that you're looking in gmod/data/Umotd , not gmod/addons/data/Umotd, for the file.
--- End quote ---
Yes, they are both in gmod/data/Umotd.
Welcome to my "Land of Confusion" :D
jay209015:
Ok, found the fix. EasyEngine was conflicting. I removed it and the script worked fine :D Full code:
--- Code: ---local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetStart( ply:GetPos() )
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
effectdata:SetAngle( Angle( 0, 0, 0) )
util.Effect( "selection_indicator", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 3, game.ConsoleCommand, "ulx playsound admin.mp3 \n")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
timer.Create( "Admin" ..ply:SteamID( ), 1, 0, MakeEffect, ply )
function PlyDisconnected( ply )
if ply:IsValid() then
timer.Destroy( "Admin" ..ply:SteamID( ) )
end
end
hook.Add( "PlayerDisconnected" , "PlyDisconnected" , PlyDisconnected )
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )
function AdminWrite( ply )
content = file.Read( "Umotd/admins.txt" )
contentp = file.Read( "Umotd/players.txt" )
if ply:IsUserGroup("admin") || ply:IsUserGroup("superadmin") then
if string.find( content, ply:Nick(), 1, true ) then
content = content
else
content = content.. "<li>" ..ply:Nick()
file.Write( "Umotd/admins.txt", content )
end
else
if string.find( contentp, ply:Nick(), 1, true ) then
contentp = contentp
else
contentp = contentp.. "<li>" ..ply:Nick()
file.Write( "Umotd/players.txt", contentp )
end
end
end
hook.Add( "PlayerSpawn", "AdminWrite", AdminWrite )
--- End code ---
Now back to rotating the effect so that's is horizontal instead of vertical.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version