• Print

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

0 Members and 1 Guest 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 #120 on: May 22, 2008, 06:36:49 pm »
Your (what I will soon start naming 'fruity') loops are causing issues again. :D

Lets say you have "item 1" and "item 2" in dlist.
You loop through it when player spawns "item 1".
Blacklist gets set true
Then, loop finishes, setting blacklist to false (item 2 wasn't spawned)
So, item 1 doesn't get blocked.
"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 #121 on: May 22, 2008, 06:41:01 pm »
I noticed this here :
Code: [Select]
False
False
False
False
False
False
False
False
False
True
False
False
False
False
Is there a way to fix this? I can't think completely atm.
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 #122 on: May 22, 2008, 06:45:44 pm »
Lol, probably going to be another moment when I find the fix while you're posting, but oh well. Here it is :D

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" }
  2. Delay = 0.3
  3. XDelay = 1
  4. function setup_propspawn(ply)
  5.         ply.denied = false
  6.         ply.d_time = 0
  7.         Msg(ply.d_time.. " \n")
  8. end
  9. hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
  10. function propspawn(ply, mdl)
  11.         if CurTime() < ply.d_time then
  12.                         wait_time = ply.d_time - math.Round(CurTime())
  13.                         ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
  14.                         return false
  15.         end
  16.         for k, v in pairs( dlist ) do
  17.                 if string.find( mdl, v, 1, true ) then
  18.                         ply.d_time = math.Round(CurTime()) + XDelay
  19.                         Msg("True \n")
  20.                         return
  21.                 else
  22.                         ply.d_time = math.Round(CurTime()) + Delay
  23.                         Msg("False \n")
  24.                 end
  25.         end
  26. end
  27. hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )

Next step: Get a toolgun whitelist. EX: advduplicator
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 #123 on: May 22, 2008, 06:53:28 pm »
If you return true you're telling GMod to ignore all other hooks after yours. Breakage++
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 #124 on: May 22, 2008, 06:56:06 pm »
Returning true doesn't just break the loop/function, it breaks all Hooks after it? That's Strange, but I guess I can see it being useful in more advanced codes for an experienced coder, but for the noobs :'(
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 #125 on: May 22, 2008, 07:46:22 pm »
Now to find the hook I need for the adv dupe check. I tried to use cantool just for the toolmode output, but it's not right.
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 #126 on: May 22, 2008, 08:29:11 pm »
Now to find the hook I need for the adv dupe check. I tried to use cantool just for the toolmode output, but it's not right.

Adv dupe does use the cantool hook. It may not be "advdupe" though so try debugging it a bit.
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 #127 on: May 22, 2008, 09:05:39 pm »
Here's my semi-working version of the code. The tool check is a little wrong. After you use the advdupe, ply.whitelist stays true until you use another tool, meaning you're free to spam after use advdupe :"(
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" }
  2. Delay = 0.3
  3. XDelay = 1
  4. function setup_propspawn(ply)
  5.         ply.denied = false
  6.         ply.d_time = 0
  7.         Msg(ply.d_time.. " \n")
  8. end
  9. hook.Add( "PlayerInitialSpawn", "Setup_PropSpawn", setup_propspawn );
  10. function propspawn(ply, mdl)
  11.         if CurTime() < ply.d_time then
  12.                         wait_time = ply.d_time - math.Round(CurTime())
  13.                         ply:PrintMessage(HUD_PRINTTALK, "You must wait " ..wait_time.. " second(s) before spawning another prop")
  14.                         return false
  15.         end
  16.         for k, v in pairs( dlist ) do
  17.                 if string.find( mdl, v, 1, true ) then
  18.                         if ply.whitelist then
  19.                                 ply.d_time = 0
  20.                         else
  21.                                 ply.d_time = math.Round(CurTime()) + XDelay
  22.                                 Msg("True \n")
  23.                         end
  24.                         return
  25.                 else
  26.                         if ply.whitelist then
  27.                                 ply.d_time = 0
  28.                         else                   
  29.                                 ply.d_time = math.Round(CurTime()) + Delay
  30.                                 Msg("False \n")
  31.                         end
  32.                 end
  33.         end
  34. end
  35. hook.Add( "PlayerSpawnProp", "PropSpawn", propspawn )
  36. function gettool(ply, tr, toolmode)
  37.         if toolmode == "adv_duplicator" then
  38.                 ply.whitelist = true
  39.         else
  40.                 ply.whitelist = false
  41.         end
  42. end
  43. hook.Add( "CanTool", "GetTool", gettool)

==EDIT==
 I only want ply.whitelist to be true when the tool is in use. It tried TOOL:Think().
http://wiki.garrysmod.com/wiki/?title=TOOL:Think
Code: [Select]
function toolmode:Think()
     ply.whitelist = true
end
^^-- This one says something about toolmode being a string value, and
the two below both say either "adv_duplicator" or "TOOL" is a nil value.
Code: [Select]
function adv_duplicator:Think()
     ply.whitelist = true
end
Code: [Select]
function TOOL:Think()
     ply.whitelist = true
end
« Last Edit: May 23, 2008, 01:23:04 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 #128 on: May 23, 2008, 04:28:16 pm »
I am totally lost now. Idk how I get this toolmode check thing to work.
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 #129 on: May 26, 2008, 08:29:00 am »
Any idea of how to get it to check and see if the adv_duplicator is in use?
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 #130 on: May 26, 2008, 08:30:06 am »
Does it matter? If you code it right it will function the same either way. ;)
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 #131 on: May 26, 2008, 07:46:09 pm »
Quote
Does it matter? If you code it right it will function the same either way. Wink

I don't understand, is there a way to see if the adv_dupe is actually pasting? So that you could spam even with the gun out. Right now if you use the adv_dupe, you can spam until you change guns.
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 #132 on: May 26, 2008, 08:05:39 pm »

I don't understand, is there a way to see if the adv_dupe is actually pasting? So that you could spam even with the gun out. Right now if you use the adv_dupe, you can spam until you change guns.

I'm betting you could look over adv_dupe code and find out how Tad2020 monitors. He's set up something that draws a status bar client side that finishes at 100% once the 'dupe' is done spawning.
Though probably a usermessage, perhaps you could do similiar or find something useful.

Perhaps find out a way to monitor/queue the amount spawned within a certain time too. I think adv_dupe has some configs to set up time/etc.

Anyone (Meg,spbogie,kyzer,Mr.Pres, any other experienced coders), can a single usermessage be listened for twice?
That is, if adv_dupe sends a usermessage status of some sort, one of which is a 'adv_dupe_finished_spawn' ... could another script listen for that same usermessage without breaking the other?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
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 #134 on: May 26, 2008, 08:55:16 pm »
Code: [Select]
Timer Error: attempt to call a nil value
^^ I really don't understand this one. Unless I'm missing something, I should not be getting this error.

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 timereset( ply )
  50.         ply.d_time = CurTime() + Delay
  51.         ply.t_time = 0
  52.         timer.Destroy( ply:Nick().. "whitelist" )
  53. 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