ULX

Author Topic: Admin sounds, tools and other code chat.  (Read 56128 times)

0 Members and 1 Guest are viewing this topic.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #75 on: April 28, 2008, 06:57:37 PM »
Another thing is I got the effect I want, but the ring is verticle instead of horizontal. No matter what I set the angles to it stays the same. Heres the effects code.

Code: [Select]
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( 90, 90, 0) )
util.Effect( "selection_indicator", effectdata, true, true )
end

Also I found the error in for my timer, but no fix.

Code: [Select]

if ply:IsValid() then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
else
        timer.Destroy( "Admin" ..ply:Nick() )
end

Let's say I'm admin ok, so when I join it creates a timer called AdminJay209015, but when I leave it tries to remove AdminNull bc ply is now a null value. So I need a way to check if ply disconnects, check to see if they're admin, and if yes then get their nick and destroy their timer. To advance for my knowledge though :'(. Maybe one of you lua experts can help here.
« Last Edit: April 28, 2008, 09:01:01 PM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: Admin sounds, tools and other code chat.
« Reply #76 on: April 28, 2008, 09:18:10 PM »
A few options here, in no particular order:
  • Hook into PlayerDisconnected and remove the timer when they disconnect.
  • Use a non-recurring timer, and recreate it each time it calls with a valid player (if it's not valid just return and it won't get called next time)
  • Create your own "timer" using a Think hook and comparing against CurTime(). Loop through all players, create effect when ply:IsAdmin() is true

Edit: I also recommend against using their name as the name for the timer. Consider what happens if they are to change their name while connected and go to connect. Best option to uniquely identify them would probably be UniqueID. Either way, this is only necessary if you go the Named timer/PlayerDisconnected route.
« Last Edit: April 28, 2008, 09:23:48 PM by spbogie »
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #77 on: April 29, 2008, 05:18:57 AM »
Thank you Spbodie it works, and here is my new code:

Code: [Select]
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)
content = file.Read( "Umotd/admins.txt" )
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 )
if string.find( content, ply:Nick(), 1, true ) then
content = content
else
content = content.. "\n" ..ply:Nick()
file.Write( "Umotd/admins.txt", content )
end
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 )



Now to get the effects to dsiplay a horizontal ring instead of a vertical one.

==EDIT==
New Code: Now rights admins that have connected to the server to Admins.txt for the Umotd file so that the admin list is available to users :D
« Last Edit: April 29, 2008, 04:27:13 PM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #78 on: April 29, 2008, 05:24:41 PM »
Revision of code above, better file.write on spawn rather than initial spawn plus cleaner code.

Code: [Select]
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" )
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

end
end
hook.Add( "PlayerSpawn", "AdminWrite", AdminWrite )
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #79 on: April 29, 2008, 06:19:10 PM »
Script is not writing to players.txt, but the admins.txt is working perfectly. players.txt does exist in the proper location to, it's just not writing to it.

Code: [Select]
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 )
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Admin sounds, tools and other code chat.
« Reply #80 on: April 29, 2008, 06:41:39 PM »
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?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #81 on: April 29, 2008, 06:43:34 PM »
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.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Admin sounds, tools and other code chat.
« Reply #82 on: April 29, 2008, 06:52:10 PM »
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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #83 on: April 29, 2008, 06:55:02 PM »
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.
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.

Yes, they are both in gmod/data/Umotd.

Welcome to my "Land of Confusion" :D
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #84 on: April 29, 2008, 07:07:41 PM »
Ok, found the fix. EasyEngine was conflicting. I removed it and the script worked fine :D Full code:
Code: [Select]
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 )

Now back to rotating the effect so that's is horizontal instead of vertical.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: Admin sounds, tools and other code chat.
« Reply #85 on: April 29, 2008, 10:16:10 PM »
Try

effectdata:SetAngle( Angle( 0, 0, 90) )

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #86 on: April 30, 2008, 05:04:43 AM »
Try

effectdata:SetAngle( Angle( 0, 0, 90) )


Nothing happend :'(
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #87 on: April 30, 2008, 02:21:49 PM »
I've tried all angles I could think of, it doesn't even rotate at all. It's always vertical, and rotated the same way.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: Admin sounds, tools and other code chat.
« Reply #88 on: April 30, 2008, 02:33:36 PM »
Try moving the line SetAngle at the beginning, dunno. Also maybe try to disable SetStart and SetNormal (i don't even know what are these functions)

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #89 on: April 30, 2008, 03:16:56 PM »
Tried and it didn't work :'(
Ok, randomly works now. Thanks. Code:

==EDIT==
Nvm, if you shoot the ground with a tool gun or any flat horizontal prop the effect rotates to follow that, same for any angle. Is there A way I can make this effect unique?

Code: [Select]
local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetAngle( Angle( 0, 0, 90 ) )
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
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 = string.gsub( content, "</div></div></body>", "<li>" ..ply:Nick().. "</div></div></body>" )
file.Write( "Umotd/admins.txt", content )
end
else
if string.find( contentp, ply:Nick(), 1, true ) then
contentp = contentp
else
contentp = string.gsub( contentp, "</div></div></body>", "<li>" ..ply:Nick().. "</div></div></body>" )
file.Write( "Umotd/players.txt", contentp )
end
end
end
hook.Add( "PlayerSpawn", "AdminWrite", AdminWrite )
« Last Edit: April 30, 2008, 03:58:14 PM by jay209015 »
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly