• Print

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

0 Members and 1 Guest are viewing this topic.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Admin sounds, tools and other code chat.
« Reply #135 on: May 26, 2008, 09:17:04 pm »
timerreset ~= timereset

:)
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 #136 on: May 26, 2008, 09:18:41 pm »
Lol, omg soo many newb mistakes today. Earlier i was throwing in random commas. Thanks for the help.
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 #137 on: May 26, 2008, 09:26:55 pm »
Well, the code works better, but still not right. Sometimes the adv dupe works others it says "you must wait 0.3 seconds before spawning another prop".

Code: Lua
  1. dlist = { "crane_frame.mdl", "models/props_phx/ball.mdl", "models/props_phx/oildrum001_explosive.mdl", "models/props_phx/mk-82.mdl", "models/props_phx/torpedo.mdl", "models/props_phx/ww2bomb.mdl", "models/props_phx/misc/flakshell_big.mdl", "models/props_junk/gascan001a.mdl", "models/props_junk/propane_tank001a.mdl", "models/props_c17/oildrum001_explosive.mdl", "models/props_phx/huge/tower.mdl", "models/props_phx/huge/evildisc_corp.mdl", "models/props_phx/playfield.mdl", "models/props_c17/utilitypole01d.mdl", "models/props_buildings/building_002a.mdl", "models/props_buildings/collapsedbuilding02b.mdl", "models/props_buildings/collapsedbuilding02c.mdl", "models/props_buildings/project_building01.mdl", "models/props_buildings/project_building02.mdl", "models/props_buildings/project_building03.mdl", "models/props_buildings/project_destroyedbuildings01.mdl", "models/props_buildings/row_church_fullscale.mdl", "models/props_buildings/row_corner_1_fullscale.mdl", "models/props_buildings/row_res_1_fullscale.mdl", "models/props_buildings/row_res_2_ascend_fullscale.mdl", "models/props_canal/canal_bridge01.mdl", "models/props_canal/canal_bridge02.mdl", "models/props_canal/canal_bridge03a.mdl", "models/props_canal/canal_bridge03b.mdl" }
  2. Delay = 0.3
  3. XDelay = 1
  4. function setup_propspawn(ply)
  5.         ply.denied = false
  6.         ply.d_time = 0
  7.         ply.t_time = 0
  8.         Msg(ply.d_time.. " \n")        
  9. end
  10. hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
  11. function propspawn(ply, mdl)
  12.         if CurTime() < ply.d_time then
  13.                         wait_time = ply.d_time - math.Round(CurTime(),2)
  14.                         ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
  15.                         return false
  16.         end
  17.         for k, v in pairs( dlist ) do
  18.                 if string.find( mdl, v, 1, true ) then
  19.                         ply.d_time = math.Round(CurTime()) + XDelay
  20.                         return
  21.                 else   
  22.                         ply.d_time = math.Round(CurTime()) + Delay
  23.                 end
  24.         end
  25. end
  26. hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
  27. function gettool(ply, tr, toolmode)
  28.         if CurTime() > ply.t_time then
  29.                 if toolmode == "adv_duplicator" or toolmode == "duplicator" then
  30.                         ply.whitelist = true
  31.                         ply.t_time = math.Round(CurTime(),1) + Delay
  32.                         ply.d_time = 0
  33.                         timer.Create( ply:Nick().. "whitelist", 10, 0, timerreset, ply)
  34.                 else
  35.                         if toolmode == "ol_stacker" or toolmode == "dynamite" then
  36.                                 ply.t_time = math.Round(CurTime(), 2) + XDelay
  37.                         else
  38.                                 ply.t_time = 0
  39.                         end                      
  40.                 end                    
  41.         else
  42.                 t_wait_time = ply.t_time - math.Round(CurTime(), 2)
  43.                 ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..t_wait_time.. " second(s) before using another tool")
  44.                 ply.whitelist = false
  45.                 return false
  46.         end
  47. end
  48. hook.Add( "CanTool", "GetTool", gettool)
  49. function timerreset( ply )
  50.         ply.d_time = CurTime() + Delay
  51.         timer.Destroy( ply:Nick().. "whitelist" )
  52. end
« Last Edit: May 26, 2008, 09:41:02 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 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 #138 on: May 27, 2008, 03:43:23 pm »
Lol, omg soo many newb mistakes today. Earlier i was throwing in random commas. Thanks for the help.

*sigh*
*chuckle*
If only this were a mistake by new coders.
"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 #139 on: May 28, 2008, 08:25:57 am »
If only :D. Why hasn't someone invented the lua spell checker lol.
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 #140 on: May 28, 2008, 10:40:01 am »
If only :D. Why hasn't someone invented the lua spell checker lol.

If only Lua scripts were compilable..

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 #141 on: May 28, 2008, 04:00:30 pm »
If only Lua scripts were compilable..

They are (and have been for a long time)
"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 #142 on: May 28, 2008, 09:06:10 pm »
Is there anyone interested in taking over this antispam module. I would like to have a good quality anti spam addon.

Here's my attempt if you want to build off of it.

Code: Lua
  1. dlist = { "crane_frame.mdl", "models/props_phx/ball.mdl", "models/props_phx/oildrum001_explosive.mdl", "models/props_phx/mk-82.mdl", "models/props_phx/torpedo.mdl", "models/props_phx/ww2bomb.mdl", "models/props_phx/misc/flakshell_big.mdl", "models/props_junk/gascan001a.mdl", "models/props_junk/propane_tank001a.mdl", "models/props_c17/oildrum001_explosive.mdl", "models/props_phx/huge/tower.mdl", "models/props_phx/huge/evildisc_corp.mdl", "models/props_phx/playfield.mdl", "models/props_c17/utilitypole01d.mdl", "models/props_buildings/building_002a.mdl", "models/props_buildings/collapsedbuilding02b.mdl", "models/props_buildings/collapsedbuilding02c.mdl", "models/props_buildings/project_building01.mdl", "models/props_buildings/project_building02.mdl", "models/props_buildings/project_building03.mdl", "models/props_buildings/project_destroyedbuildings01.mdl", "models/props_buildings/row_church_fullscale.mdl", "models/props_buildings/row_corner_1_fullscale.mdl", "models/props_buildings/row_res_1_fullscale.mdl", "models/props_buildings/row_res_2_ascend_fullscale.mdl", "models/props_canal/canal_bridge01.mdl", "models/props_canal/canal_bridge02.mdl", "models/props_canal/canal_bridge03a.mdl", "models/props_canal/canal_bridge03b.mdl" }
  2. Delay = 0.3
  3. XDelay = 1
  4. function setup_propspawn(ply)
  5.         ply.denied = false
  6.         ply.d_time = 0
  7.         ply.t_time = 0
  8.         Msg(ply.d_time.. " \n")
  9. end
  10. hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
  11. function propspawn(ply, mdl)
  12.         if CurTime() < ply.d_time then
  13.                         wait_time = ply.d_time - math.Round(CurTime(),2)
  14.                         ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
  15.                         return false
  16.         end
  17.         for k, v in pairs( dlist ) do
  18.                 if string.find( mdl, v, 1, true ) then
  19.                         ply.d_time = math.Round(CurTime()) + XDelay
  20.                         return
  21.                 else   
  22.                         ply.d_time = math.Round(CurTime()) + Delay
  23.                 end
  24.         end
  25. end
  26. hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
  27. function gettool(ply, tr, toolmode)
  28.         if CurTime() > ply.t_time then
  29.                 if toolmode == "adv_duplicator" or toolmode == "duplicator" then
  30.                         ply.whitelist = true
  31.                         ply.t_time = math.Round(CurTime(),1) + Delay
  32.                         timer.Create( ply:Nick().. "timer", 0, 0, remove_delay, ply)
  33.                         timer.Create( ply:Nick().. "whitelist", 10, 0, timerreset, ply)
  34.                 else
  35.                         if toolmode == "ol_stacker" or toolmode == "dynamite" then
  36.                                 ply.t_time = math.Round(CurTime(), 2) + XDelay
  37.                         else
  38.                                 ply.t_time = 0
  39.                         end                      
  40.                 end                    
  41.         else
  42.                 t_wait_time = ply.t_time - math.Round(CurTime(), 2)
  43.                 ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..t_wait_time.. " second(s) before using another tool")
  44.                 ply.whitelist = false
  45.                 return false
  46.         end
  47. end
  48. hook.Add( "CanTool", "GetTool", gettool)
  49. function timerreset( ply )
  50.         ply.d_time = CurTime() + Delay
  51.         timer.Destroy( ply:Nick().. "timer" )
  52.         timer.Destroy( ply:Nick().. "whitelist" )
  53. end
  54. function remove_delay( ply )
  55.         ply.d_time = 0
  56. end
« Last Edit: May 28, 2008, 09:31:38 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 #143 on: May 31, 2008, 02:42:59 pm »
Ok, now I need to learn Vgui :D. I want a vgui to be collapsable, and show the players current warn status.

EX:
=================
=     Warning Status        =
=================
=  Warnings: #               =
=  Warns until Kick: #      =
=================

Of course prettier lol, but I think you get the point.

Here's the code I'm getting the warnings from.

Code: Lua
  1. // Potentially Harmful props have a longer delay in spawn time
  2. dlist = { "crane_frame.mdl", "models/props_phx/ball.mdl", "models/props_phx/oildrum001_explosive.mdl", "models/props_phx/mk-82.mdl", "models/props_phx/torpedo.mdl", "models/props_phx/ww2bomb.mdl", "models/props_phx/misc/flakshell_big.mdl", "models/props_junk/gascan001a.mdl", "models/props_junk/propane_tank001a.mdl", "models/props_c17/oildrum001_explosive.mdl", "models/props_phx/huge/tower.mdl", "models/props_phx/huge/evildisc_corp.mdl", "models/props_phx/playfield.mdl", "models/props_c17/utilitypole01d.mdl", "models/props_buildings/building_002a.mdl", "models/props_buildings/collapsedbuilding02b.mdl", "models/props_buildings/collapsedbuilding02c.mdl", "models/props_buildings/project_building01.mdl", "models/props_buildings/project_building02.mdl", "models/props_buildings/project_building03.mdl", "models/props_buildings/project_destroyedbuildings01.mdl", "models/props_buildings/row_church_fullscale.mdl", "models/props_buildings/row_corner_1_fullscale.mdl", "models/props_buildings/row_res_1_fullscale.mdl", "models/props_buildings/row_res_2_ascend_fullscale.mdl", "models/props_canal/canal_bridge01.mdl", "models/props_canal/canal_bridge02.mdl", "models/props_canal/canal_bridge03a.mdl", "models/props_canal/canal_bridge03b.mdl" }
  3. Delay = 0.3 // Delay for normal props
  4. XDelay = 1  // Delay for the props in the dlist
  5. Warn_Player = 5 // After what warning lvl should the player be warned?
  6. Max_Warn = 10 // Max number of times a player can be warned before getting kicked
  7.  
  8. //==============================DO NOT EDIT BELOW THIS POINT===================================//
  9.  
  10.  
  11.  
  12. function setup_propspawn(ply)
  13.         ply.denied = false
  14.         ply.d_time = 0
  15.         ply.t_time = 0
  16.         ply.warn = 0
  17. end
  18. hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
  19. function propspawn(ply, mdl)
  20.         if CurTime() < ply.d_time then
  21.                         wait_time = ply.d_time - math.Round(CurTime(),2)
  22.                         ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
  23.                         ply.warn = ply.warn + 1
  24.                         timer.Create( ply:Nick().. "cooldown", 60, 0, CoolDown, ply)
  25.                         timer.Simple( 0, Spammer_Kick, ply )
  26.                         return false
  27.         end
  28.         for k, v in pairs( dlist ) do
  29.                 if string.find( mdl, v, 1, true ) then
  30.                         if ply.whitelist then
  31.                                 ply.d_time = 0
  32.                         else
  33.                                 ply.d_time = math.Round(CurTime()) + XDelay
  34.                                 return
  35.                         end
  36.                 else
  37.                         if ply.whitelist then
  38.                                 ply.d_time = 0
  39.                         else
  40.                                 ply.d_time = math.Round(CurTime()) + Delay
  41.                         end
  42.                 end
  43.         end
  44. end
  45. hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
  46. function gettool(ply, tr, toolmode)
  47.         if CurTime() > ply.t_time then
  48.                 if toolmode == "adv_duplicator" or toolmode == "duplicator" then
  49.                         ply.t_time = math.Round(CurTime(),1) + Delay
  50.                         timer.Create( ply:Nick().. "timer", 0, 0, remove_delay, ply)
  51.                         timer.Create( ply:Nick().. "whitelist", 10, 0, timerreset, ply)                                        
  52.                 else
  53.                         if toolmode == "ol_stacker" or toolmode == "dynamite" then
  54.                                 ply.t_time = math.Round(CurTime(), 2) + XDelay
  55.                         else
  56.                                 ply.t_time = 0
  57.                         end                      
  58.                 end                    
  59.         else
  60.                 t_wait_time = ply.t_time - math.Round(CurTime(), 2)
  61.                 ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..t_wait_time.. " second(s) before using another tool")
  62.                 ply.whitelist = false
  63.                 return false
  64.         end
  65. end
  66. hook.Add( "CanTool", "GetTool", gettool)
  67. function timerreset( ply )
  68.         ply.d_time = CurTime() + Delay
  69.         timer.Destroy( ply:Nick().. "timer" )
  70.         timer.Destroy( ply:Nick().. "whitelist" )
  71.         ply.whitelist = false
  72. end
  73. function remove_delay( ply )
  74.         if !ply.whitelist then
  75.                 ply.whitelist = true
  76.         end
  77. end
  78. function CoolDown( ply )
  79.         if ply.warn > 0 then
  80.                 ply.warn = ply.warn - 1
  81.         else
  82.                 timer.Destroy( ply:Nick().. "cooldown" )
  83.                 ply.warn = 0
  84.         end
  85. end
  86. function Timer_Remove( ply )
  87.         if timer.IsTimer( ply:Nick().. "cooldown" ) then
  88.                 timer.Destroy( ply:Nick().. "cooldown" )
  89.         end
  90.         if timer.IsTimer( ply:Nick().. "timer" ) then
  91.                 timer.Destroy( ply:Nick().. "timer" )
  92.         end    
  93.         if timer.IsTimer( ply:Nick().. "whitelist" ) then
  94.                 timer.Destroy( ply:Nick().. "whitelist" )
  95.         end
  96. end
  97. hook.Add( "PlayerDisconnected", "Remove_Timers_Hook", Timer_Remove )
  98. function Spammer_Kick( ply )
  99.         if ply.warn >= Warn_Player then
  100.                 ply:PrintMessage(HUD_PRINTTALK, "If you continue to Spam, you will be kicked!")
  101.                 Warn_Left = Max_Warn - ply.warn
  102.                 game.ConsoleCommand( "ulx asay Player " ..ply:Nick().. " is spamming, and has a warn level of " ..ply.warn.. ". Kicking them after " ..Warn_Left.. " more warnings \n")
  103.         end
  104.         if ply.warn >= Max_Warn then
  105.                 ULib.kick(ply, "Quit Spamming")
  106.         end
  107. end
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 #144 on: May 31, 2008, 05:06:40 pm »
Heh. Have fun. I've not ever touched vgui since Gmod9.
I think Megiddo and spbogie did all our stuff.
I'll probably learn a little by watching.

Bet Mr.Pres could kick in a bit here. His survivor server has a heck of a lot vgui, at least for status updates, bar graphs, etc.
I don't remember menus, but, I've not hung out on it long enough. (Not into RP)
« Last Edit: May 31, 2008, 05:08:26 pm by JamminR »
"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 #145 on: May 31, 2008, 05:18:01 pm »
Lol, I'm just wanting this to learn and it would be useful for those rare occasions where you may accidentally spam due to a bad timer on a prop spawner ect.
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 #146 on: June 01, 2008, 05:37:34 pm »
How do I get the vgui to display ply.warn?

cl_init:
Code: [Select]
function ServerVGUI()
local ply = LocalPlayer()
         local DermaPanel = vgui.Create( "DFrame" )
         DermaPanel:SetPos( 0,0 )
         DermaPanel:SetSize( 150, 0 )
         DermaPanel:SetTitle( "Warning lvl:" ..ply.warn )
DermaPanel:SetVisible(true)
DermaPanel:ShowCloseButton( false )

end
concommand.Add( "vguitest", ServerVGUI )

init:
Code: [Select]
AddCSLuaFile("cl_init.lua");
ASpam:
Code: [Select]
// Potentially Harmful props have a longer delay in spawn time
dlist = { "crane_frame.mdl", "models/props_phx/ball.mdl", "models/props_phx/oildrum001_explosive.mdl", "models/props_phx/mk-82.mdl", "models/props_phx/torpedo.mdl", "models/props_phx/ww2bomb.mdl", "models/props_phx/misc/flakshell_big.mdl", "models/props_junk/gascan001a.mdl", "models/props_junk/propane_tank001a.mdl", "models/props_c17/oildrum001_explosive.mdl", "models/props_phx/huge/tower.mdl", "models/props_phx/huge/evildisc_corp.mdl", "models/props_phx/playfield.mdl", "models/props_c17/utilitypole01d.mdl", "models/props_buildings/building_002a.mdl", "models/props_buildings/collapsedbuilding02b.mdl", "models/props_buildings/collapsedbuilding02c.mdl", "models/props_buildings/project_building01.mdl", "models/props_buildings/project_building02.mdl", "models/props_buildings/project_building03.mdl", "models/props_buildings/project_destroyedbuildings01.mdl", "models/props_buildings/row_church_fullscale.mdl", "models/props_buildings/row_corner_1_fullscale.mdl", "models/props_buildings/row_res_1_fullscale.mdl", "models/props_buildings/row_res_2_ascend_fullscale.mdl", "models/props_canal/canal_bridge01.mdl", "models/props_canal/canal_bridge02.mdl", "models/props_canal/canal_bridge03a.mdl", "models/props_canal/canal_bridge03b.mdl" }
Delay = 0.3 // Delay for normal props
XDelay = 1  // Delay for the props in the dlist
Warn_Player = 5 // After what warning lvl should the player be warned?
Max_Warn = 10 // Max number of times a player can be warned before getting kicked

//==============================DO NOT EDIT BELOW THIS POINT===================================//
module( "ASpam", package.seeall )

function setup_propspawn(ply)
ply.denied = false
ply.d_time = 0
ply.t_time = 0
ply.warn = 0
ply:ConCommand("vguitest")
end
hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
function propspawn(ply, mdl)
if CurTime() < ply.d_time then
wait_time = ply.d_time - math.Round(CurTime(),2)
ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
ply.warn = ply.warn + 1
timer.Create( ply:Nick().. "cooldown", 60, 0, CoolDown, ply)
timer.Simple( 0, Spammer_Kick, ply )
return false
end
for k, v in pairs( dlist ) do
if string.find( mdl, v, 1, true ) then
if ply.whitelist then
ply.d_time = 0
else
ply.d_time = math.Round(CurTime()) + XDelay
return
end
else
if ply.whitelist then
ply.d_time = 0
else
ply.d_time = math.Round(CurTime()) + Delay
end
end
end
end
hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
function gettool(ply, tr, toolmode)
if CurTime() > ply.t_time then
if toolmode == "adv_duplicator" or toolmode == "duplicator" then
ply.t_time = math.Round(CurTime(),1) + Delay
timer.Create( ply:Nick().. "timer", 0, 0, remove_delay, ply)
timer.Create( ply:Nick().. "whitelist", 10, 0, timerreset, ply)
else
if toolmode == "ol_stacker" or toolmode == "dynamite" then
ply.t_time = math.Round(CurTime(), 2) + XDelay
else
ply.t_time = 0
end
end
else
t_wait_time = ply.t_time - math.Round(CurTime(), 2)
ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..t_wait_time.. " second(s) before using another tool")
ply.whitelist = false
return false
end
end
hook.Add( "CanTool", "GetTool", gettool)
function timerreset( ply )
ply.d_time = CurTime() + Delay
timer.Destroy( ply:Nick().. "timer" )
timer.Destroy( ply:Nick().. "whitelist" )
ply.whitelist = false
end
function remove_delay( ply )
if !ply.whitelist then
ply.whitelist = true
end
end
function CoolDown( ply )
if ply.warn > 0 then
ply.warn = ply.warn - 1
else
timer.Destroy( ply:Nick().. "cooldown" )
ply.warn = 0
end
end
function Timer_Remove( ply )
if timer.IsTimer( ply:Nick().. "cooldown" ) then
timer.Destroy( ply:Nick().. "cooldown" )
end
if timer.IsTimer( ply:Nick().. "timer" ) then
timer.Destroy( ply:Nick().. "timer" )
end
if timer.IsTimer( ply:Nick().. "whitelist" ) then
timer.Destroy( ply:Nick().. "whitelist" )
end
end
hook.Add( "PlayerDisconnected", "Remove_Timers_Hook", Timer_Remove )
function Spammer_Kick( ply )
if ply.warn >= Warn_Player then
ply:PrintMessage(HUD_PRINTTALK, "If you continue to Spam, you will be kicked!")
Warn_Left = Max_Warn - ply.warn
game.ConsoleCommand( "ulx asay Player " ..ply:Nick().. " is spamming, and has a warn level of " ..ply.warn.. ". Kicking them after " ..Warn_Left.. " more warnings \n")
end
if ply.warn >= Max_Warn then
ULib.kick(ply, "Quit Spamming")
end
end




Error I get with the cl_init:
Code: [Select]
autorun/cl_init.lua:11: attempt to concatenate field 'warn' (a nil value)
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 #147 on: June 01, 2008, 06:23:09 pm »
You need to send the 'warn' variable to the client somehow. Networked vars or usermessages are your options. Look 'em up on the wiki.
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 #148 on: June 01, 2008, 07:41:33 pm »
The warning lvl doesn't update now.

cl_init:
Code: [Select]
function ServerVGUI()
local ply = LocalPlayer()
         local DermaPanel = vgui.Create( "DFrame" )
         DermaPanel:SetPos( 0,0 )
         DermaPanel:SetSize( 150, 25 )
DermaPanel:SetTitle( "Warning lvl:" ..ply:GetNetworkedInt( "warn" ) )
DermaPanel:SetVisible(true)
DermaPanel:ShowCloseButton( false )
DermaPanel:SetDraggable( false )
end
concommand.Add( "vguitest", ServerVGUI )

ASpam:
Code: [Select]
// Potentially Harmful props have a longer delay in spawn time
dlist = { "crane_frame.mdl", "models/props_phx/ball.mdl", "models/props_phx/oildrum001_explosive.mdl", "models/props_phx/mk-82.mdl", "models/props_phx/torpedo.mdl", "models/props_phx/ww2bomb.mdl", "models/props_phx/misc/flakshell_big.mdl", "models/props_junk/gascan001a.mdl", "models/props_junk/propane_tank001a.mdl", "models/props_c17/oildrum001_explosive.mdl", "models/props_phx/huge/tower.mdl", "models/props_phx/huge/evildisc_corp.mdl", "models/props_phx/playfield.mdl", "models/props_c17/utilitypole01d.mdl", "models/props_buildings/building_002a.mdl", "models/props_buildings/collapsedbuilding02b.mdl", "models/props_buildings/collapsedbuilding02c.mdl", "models/props_buildings/project_building01.mdl", "models/props_buildings/project_building02.mdl", "models/props_buildings/project_building03.mdl", "models/props_buildings/project_destroyedbuildings01.mdl", "models/props_buildings/row_church_fullscale.mdl", "models/props_buildings/row_corner_1_fullscale.mdl", "models/props_buildings/row_res_1_fullscale.mdl", "models/props_buildings/row_res_2_ascend_fullscale.mdl", "models/props_canal/canal_bridge01.mdl", "models/props_canal/canal_bridge02.mdl", "models/props_canal/canal_bridge03a.mdl", "models/props_canal/canal_bridge03b.mdl" }
Delay = 0.3 // Delay for normal props
XDelay = 1  // Delay for the props in the dlist
Warn_Player = 5 // After what warning lvl should the player be warned?
Max_Warn = 10 // Max number of times a player can be warned before getting kicked

//==============================DO NOT EDIT BELOW THIS POINT===================================//


function setup_propspawn(ply)
ply.denied = false
ply.d_time = 0
ply.t_time = 0
ply.warn = 0
ply:SetNetworkedInt( "warn", ply.warn )
ply:ConCommand("vguitest")
end
hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
function propspawn(ply, mdl)
if CurTime() < ply.d_time then
wait_time = ply.d_time - math.Round(CurTime(),2)
ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
ply.warn = ply.warn + 1
ply:SetNetworkedInt( "warn", ply.warn )
timer.Create( ply:Nick().. "cooldown", 60, 0, CoolDown, ply)
timer.Simple( 0, Spammer_Kick, ply )
return false
end
for k, v in pairs( dlist ) do
if string.find( mdl, v, 1, true ) then
if ply.whitelist then
ply.d_time = 0
else
ply.d_time = math.Round(CurTime()) + XDelay
return
end
else
if ply.whitelist then
ply.d_time = 0
else
ply.d_time = math.Round(CurTime()) + Delay
end
end
end
end
hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
function gettool(ply, tr, toolmode)
if CurTime() > ply.t_time then
if toolmode == "adv_duplicator" or toolmode == "duplicator" then
ply.t_time = math.Round(CurTime(),1) + Delay
timer.Create( ply:Nick().. "timer", 0, 0, remove_delay, ply)
timer.Create( ply:Nick().. "whitelist", 10, 0, timerreset, ply)
else
if toolmode == "ol_stacker" or toolmode == "dynamite" then
ply.t_time = math.Round(CurTime(), 2) + XDelay
else
ply.t_time = 0
end
end
else
t_wait_time = ply.t_time - math.Round(CurTime(), 2)
ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..t_wait_time.. " second(s) before using another tool")
ply.whitelist = false
return false
end
end
hook.Add( "CanTool", "GetTool", gettool)
function timerreset( ply )
ply.d_time = CurTime() + Delay
timer.Destroy( ply:Nick().. "timer" )
timer.Destroy( ply:Nick().. "whitelist" )
ply.whitelist = false
end
function remove_delay( ply )
if !ply.whitelist then
ply.whitelist = true
end
end
function CoolDown( ply )
if ply.warn > 0 then
ply.warn = ply.warn - 1
ply:SetNetworkedInt( "warn", ply.warn )
ply:ConCommand("vguitest")
else
timer.Destroy( ply:Nick().. "cooldown" )
ply.warn = 0
ply:SetNetworkedInt( "warn", ply.warn )
ply:ConCommand("vguitest")
end
end
function Timer_Remove( ply )
if timer.IsTimer( ply:Nick().. "cooldown" ) then
timer.Destroy( ply:Nick().. "cooldown" )
end
if timer.IsTimer( ply:Nick().. "timer" ) then
timer.Destroy( ply:Nick().. "timer" )
end
if timer.IsTimer( ply:Nick().. "whitelist" ) then
timer.Destroy( ply:Nick().. "whitelist" )
end
end
hook.Add( "PlayerDisconnected", "Remove_Timers_Hook", Timer_Remove )
function Spammer_Kick( ply )
if ply.warn >= Warn_Player then
ply:PrintMessage(HUD_PRINTTALK, "If you continue to Spam, you will be kicked!")
Warn_Left = Max_Warn - ply.warn
game.ConsoleCommand( "ulx asay Player " ..ply:Nick().. " is spamming, and has a warn level of " ..ply.warn.. ". Kicking them after " ..Warn_Left.. " more warnings \n")
end
if ply.warn >= Max_Warn then
ULib.kick(ply, "Quit Spamming")
end
end
function Vgui_Updater( ply )
ply:ConCommand("vguitest")
end
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 #149 on: June 01, 2008, 09:41:12 pm »
Got it :D. Oh, and I rename cl_init to cl_ASpaminit for uniqueness. I didn't know if it could conflict with other scripts so to be safe I renamed it.

cl_ASpaminit:
Code: Lua
  1. function ServerVGUI()
  2.                  local ply = LocalPlayer()
  3.          local DermaPanel = vgui.Create( "DFrame" )
  4.          DermaPanel:SetPos( 0,0 )
  5.          DermaPanel:SetSize( 150, 25 )
  6.                  function think()
  7.                         DermaPanel:SetTitle( "Warning lvl:" ..ply:GetNetworkedInt( "warn" ) )
  8.                  end
  9.                  timer.Create( "ASpamThink", 0.1, 0, think )                   
  10.                  DermaPanel:SetVisible(true)
  11.                  DermaPanel:ShowCloseButton( false )
  12.                  DermaPanel:SetDraggable( false )
  13. end
  14. concommand.Add( "vguitest", ServerVGUI )

ASpam:
Code: Lua
  1. // Potentially Harmful props have a longer delay in spawn time
  2. dlist = { "crane_frame.mdl", "models/props_phx/ball.mdl", "models/props_phx/oildrum001_explosive.mdl", "models/props_phx/mk-82.mdl", "models/props_phx/torpedo.mdl", "models/props_phx/ww2bomb.mdl", "models/props_phx/misc/flakshell_big.mdl", "models/props_junk/gascan001a.mdl", "models/props_junk/propane_tank001a.mdl", "models/props_c17/oildrum001_explosive.mdl", "models/props_phx/huge/tower.mdl", "models/props_phx/huge/evildisc_corp.mdl", "models/props_phx/playfield.mdl", "models/props_c17/utilitypole01d.mdl", "models/props_buildings/building_002a.mdl", "models/props_buildings/collapsedbuilding02b.mdl", "models/props_buildings/collapsedbuilding02c.mdl", "models/props_buildings/project_building01.mdl", "models/props_buildings/project_building02.mdl", "models/props_buildings/project_building03.mdl", "models/props_buildings/project_destroyedbuildings01.mdl", "models/props_buildings/row_church_fullscale.mdl", "models/props_buildings/row_corner_1_fullscale.mdl", "models/props_buildings/row_res_1_fullscale.mdl", "models/props_buildings/row_res_2_ascend_fullscale.mdl", "models/props_canal/canal_bridge01.mdl", "models/props_canal/canal_bridge02.mdl", "models/props_canal/canal_bridge03a.mdl", "models/props_canal/canal_bridge03b.mdl" }
  3. Delay = 0.3 // Delay for normal props
  4. XDelay = 1  // Delay for the props in the dlist
  5. Warn_Player = 5 // After what warning lvl should the player be warned?
  6. Max_Warn = 10 // Max number of times a player can be warned before getting kicked
  7.  
  8. //==============================DO NOT EDIT BELOW THIS POINT===================================//
  9.  
  10. AddCSLuaFile("cl_ASpaminit.lua")
  11. function setup_propspawn(ply)
  12.         ply.denied = false
  13.         ply.d_time = 0
  14.         ply.t_time = 0
  15.         ply.warn = 0
  16.         ply:SetNetworkedInt( "warn", ply.warn )
  17.         ply:ConCommand("vguitest")
  18. end
  19. hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
  20. function propspawn(ply, mdl)
  21.         if CurTime() < ply.d_time then
  22.                         wait_time = ply.d_time - math.Round(CurTime(),2)
  23.                         ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
  24.                         ply.warn = ply.warn + 1
  25.                         ply:SetNetworkedInt( "warn", ply.warn )
  26.                         timer.Create( ply:Nick().. "cooldown", 60, 0, CoolDown, ply)
  27.                         timer.Simple( 0, Spammer_Kick, ply )
  28.                         return false
  29.         end
  30.         for k, v in pairs( dlist ) do
  31.                 if string.find( mdl, v, 1, true ) then
  32.                         if ply.whitelist then
  33.                                 ply.d_time = 0
  34.                         else
  35.                                 ply.d_time = math.Round(CurTime()) + XDelay
  36.                                 return
  37.                         end
  38.                 else
  39.                         if ply.whitelist then
  40.                                 ply.d_time = 0
  41.                         else
  42.                                 ply.d_time = math.Round(CurTime()) + Delay
  43.                         end
  44.                 end
  45.         end
  46. end
  47. hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
  48. function gettool(ply, tr, toolmode)
  49.         if CurTime() > ply.t_time then
  50.                 if toolmode == "adv_duplicator" or toolmode == "duplicator" then
  51.                         ply.t_time = math.Round(CurTime(),1) + Delay
  52.                         timer.Create( ply:Nick().. "timer", 0, 0, remove_delay, ply)
  53.                         timer.Create( ply:Nick().. "whitelist", 10, 0, timerreset, ply)                                        
  54.                 else
  55.                         if toolmode == "ol_stacker" or toolmode == "dynamite" then
  56.                                 ply.t_time = math.Round(CurTime(), 2) + XDelay
  57.                         else
  58.                                 ply.t_time = 0
  59.                         end                      
  60.                 end                    
  61.         else
  62.                 t_wait_time = ply.t_time - math.Round(CurTime(), 2)
  63.                 ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..t_wait_time.. " second(s) before using another tool")
  64.                 ply.whitelist = false
  65.                 return false
  66.         end
  67. end
  68. hook.Add( "CanTool", "GetTool", gettool)
  69. function timerreset( ply )
  70.         ply.d_time = CurTime() + Delay
  71.         timer.Destroy( ply:Nick().. "timer" )
  72.         timer.Destroy( ply:Nick().. "whitelist" )
  73.         ply.whitelist = false
  74. end
  75. function remove_delay( ply )
  76.         if !ply.whitelist then
  77.                 ply.whitelist = true
  78.         end
  79. end
  80. function CoolDown( ply )
  81.         if ply.warn > 0 then
  82.                 ply.warn = ply.warn - 1
  83.                 ply:SetNetworkedInt( "warn", ply.warn )
  84.         else
  85.                 timer.Destroy( ply:Nick().. "cooldown" )
  86.                 ply.warn = 0
  87.                 ply:SetNetworkedInt( "warn", ply.warn )
  88.         end
  89. end
  90. function Timer_Remove( ply )
  91.         if timer.IsTimer( ply:Nick().. "cooldown" ) then
  92.                 timer.Destroy( ply:Nick().. "cooldown" )
  93.         end
  94.         if timer.IsTimer( ply:Nick().. "timer" ) then
  95.                 timer.Destroy( ply:Nick().. "timer" )
  96.         end    
  97.         if timer.IsTimer( ply:Nick().. "whitelist" ) then
  98.                 timer.Destroy( ply:Nick().. "whitelist" )
  99.         end
  100. end
  101. hook.Add( "PlayerDisconnected", "Remove_Timers_Hook", Timer_Remove )
  102. function Spammer_Kick( ply )
  103.         if ply.warn >= Warn_Player then
  104.                 ply:PrintMessage(HUD_PRINTTALK, "If you continue to Spam, you will be kicked!")
  105.                 Warn_Left = Max_Warn - ply.warn
  106.                 game.ConsoleCommand( "ulx asay Player " ..ply:Nick().. " is spamming, and has a warn level of " ..ply.warn.. ". Kicking them after " ..Warn_Left.. " more warnings \n")
  107.         end
  108.         if ply.warn >= Max_Warn then
  109.                 ULib.kick(ply, "Quit Spamming")
  110.         end
  111. end

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

  • Print