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

0 Members and 5 Guests are viewing this topic.

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 #60 on: April 14, 2008, 09:12:45 PM »
Well, string.Replace(text:lower(), " ","") is replacing all your spaces with nothing, making it all run together.
Perhaps find a way to add a space after and before each censored word was found.
Formatting would stilll be off, but would be better than no space.
"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 #61 on: April 15, 2008, 05:03:50 PM »
Is there a way to just test the for the words while is lowercased and with the spaces removed, then return back to normal, but with the censor in place?
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 #62 on: April 15, 2008, 07:54:06 PM »
Well, no easy way.
If all they were typing was w o r d 1 w o r d 2 w o r d 1 ... after converting to lower/removed spaces, you could replace with ~**** .. then replace ~ with " "
But. That wouldn't make up for when someone went w o r d 1 a n d I t h i n k i t s w o r d 2
" **** andIthinkits **** "
Here, trying to watch for censor avoidance with people using spaces, you start getting really complicated.
You also start chewing into resources.



"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 #63 on: April 16, 2008, 01:33:50 PM »
Ok, I guess I'll stop with any further developement of this script, and start working on something new :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 Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: Admin sounds, tools and other code chat.
« Reply #64 on: April 16, 2008, 03:29:17 PM »
Nice catch there, thank you.

==EDIT==

Code with the change, but still doesn't work.

Code: [Select]
function WFilter( ply, text, toall )
TextD = { "word1", "word2" }
TextC = text.Explode(" ")
for _, v in pairs ( TextC )
    if TextD[v:lower()] then
        text:Replace( v, string.rep( "*", v:len() ) )
    end
end
return text
hook.Add( "PlayerSay", "WFilter", WFilter )

N00b, you copied my error :) i forgot the 'do' after the for, which i fixed some minutes after..that's probably why it didn't worked..well i don't see anything else.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #65 on: April 16, 2008, 03:47:40 PM »
Lol, wow. I see that now. All this effort just to get stuck back where I started lol. Oh well this was very educational for me anyways :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 #66 on: April 27, 2008, 03:07:05 PM »
Ok, Now back to the Ajoin script.
How do I make slow pulsing ring like effect at admins feet?
here is my current script.

Code: [Select]

local function MakeEffect( ply )
                        EFFECT.Mat = Material( "effects/select_dot" )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", 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(math.random( 10000000, 99999999 ), 1, 0, MakeEffect, ply )

end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin );


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 #67 on: April 27, 2008, 05:12:20 PM »
I've not dealt with effects much. You might take a look at Mr.President's explode release script for the various vector functions he used.

I would suggest using the actual ULib library functions for all the ulx console commands you're using though.
This will prevent having to run console commands, bypasses the ULX middleman (which, basically just calls ULib for the commands you're doing)

Library docs can be found at http://www.ulyssesmod.net/docs/index/Functions.html
You'll most likely want csay - http://www.ulyssesmod.net/docs/files/lua/ULib/shared/messages-lua.html#csay
and - Sound - http://www.ulyssesmod.net/docs/files/lua/ULib/server/util-lua.html#play3DSound


"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 #68 on: April 27, 2008, 08:06:27 PM »
I tried using the ULib library functions, but didn't get them to work. I did however get my effects to work with sparks, but if an admin leaves the server I get spammed with this in the server console:

Code: [Select]
Timer Error: autorun/Ajoin.lua:6: Tried to use a NULL entity!
Here's my code:

Code: [Select]
function AdminJoin( ply)
local function MakeEffect( ply )
if ( !ply:IsAdmin() ) then return end
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
end
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(math.random( 10000000, 99999999 ), 1, 0, MakeEffect, ply )
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin );
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 #69 on: April 27, 2008, 08:18:56 PM »
Code: [Select]
Timer Error: autorun/Ajoin.lua:6: Tried to use a NULL entity!

I'll let you tinker with the ULib functions on your own for now. Best practice would be to use them though. :)
As for a tip for how to fix the error, you need to find a way to stop it when they leave. (this you know I'm sure)
You can't kill a simple timer (directly anyway) because they aren't named.
Perhaps an advanced timer, or a think hook self created timer that always checks IsValid().
"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 #70 on: April 27, 2008, 08:35:56 PM »
Ok, I'm getting this error for the ULib.play3DSound timer.
Code: [Select]
Timer Error: ULib/server/util.lua:104: bad argument #1 to 'SetPos' (Vector expec
ted, got nil)
I tried 0, but it gave me an Nil error.

I'm still getting the same error with the effects timer aswell.
Code: [Select]
local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 4, ULib.play3DSound, "admin.mp3, ply:GetPos(), 1, 1")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
if ply:IsConnected( ) then
timer.Create( "AdminJoin", 1, 0, MakeEffect, ply )
else
timer.Destroy("AdminJoin")
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin );
« Last Edit: April 27, 2008, 08:49:52 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 Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Admin sounds, tools and other code chat.
« Reply #71 on: April 28, 2008, 12:33:43 AM »
timer.Simple( 4, ULib.play3DSound, "admin.mp3", ply:GetPos(), 1, 1)
Experiencing God's grace one day at a time.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Admin sounds, tools and other code chat.
« Reply #72 on: April 28, 2008, 02:07:44 PM »
Still trying to get rid of the timer error.

Code: [Select]
Timer Error: autorun/Ajoin.lua:2: Tried to use a NULL entity!
Code: [Select]
local function MakeEffect( ply )
if ply:IsConnected()  then
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", effectdata, true, true )
else
timer.Destroy( "Admin" ..ply:Nick() )
end
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")
if ply:IsConnected( ) then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )

I tested this:

Code: [Select]
lua_run timer.Destroy("AdminJay209015")
> timer.Destroy("AdminJay209015")...

and it worked fine, so obviously it's something in my code :'(

Also tested this:

Code: [Select]
local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", 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")
if ply:IsConnected( ) then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
end
if ( !ply:IsConnected() ) then
timer.Destroy( "Admin" ..ply:Nick() )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )

failed.
« Last Edit: April 28, 2008, 02:33:22 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 #73 on: April 28, 2008, 04:12:13 PM »
instead of ply:IsConnected() use ply:IsValid() or ValidEntity( ply ).
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 #74 on: April 28, 2008, 04:21:18 PM »
Same Error new code:

Code: [Select]
local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", 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")
if ply:IsValid() then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
else
timer.Destroy( "Admin" ..ply:Nick() )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )

Same error here two Different code:

Code: [Select]
local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
util.Effect( "Sparks", 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")
if ValidEntity( ply ) then
timer.Create( "Admin" ..ply:Nick(), 1, 0, MakeEffect, ply )
else
timer.Destroy( "Admin" ..ply:Nick() )
end
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )
« Last Edit: April 28, 2008, 04:23:12 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