Recent Posts

Pages: [1] 2 3 ... 10
1
Off-Topic / Re: Help setting immunity on touching props
« Last post by MrPresident on Yesterday at 09:47:44 PM »
To sum up what JamminR said..

do we look like the FPP forums? You wouldn't go to an Apple store with a busted android phone.
2
Welcome. Small steps - looks like your making good learning process.
3
Yes, i am checking if the player spawned is switching between the weapons. BUT, I am checking that ANYTHING other than those 3 weapons that they spawn will make them lose their spawn protection. I have got it working now and it disables their spawn protection when they take out a gun (That is what I needed).

First, I want to thank you for all your help. I would not have got it done without you. I will be continuing to learn Lua because my end goal is to be able to make my own mods for my servers and modify mods if I need. I'm sure I will be back looking for help again lol. Thanks again!
5
RE: Where to put file - reference https://wiki.garrysmod.com/page/Beginner_Tutorial_Intro
Place your file in garrysmod\lua\autorun\server, unless the mod you're working with has a recommendation already.
(Example, our ULib library, and ULX admin mod have a modules folder similar to the Gmod autorun - difference? Our folders only load modules after our libraries and functions have been initialized. A function written for ULib could error if a Ulib command was called on the server before ULib had loaded (same for ULX, before ULX loaded)

Re: Ensure code is running constantly
1) A) You can't test this in a single player game. Reference the very top of the PlayerSwitchWeapon hook - it's a predicted hook that requires server comms - not run in client domain unless on server too.
    B) I _think_ this could be tested on a listen server (server started while in game client, not srcds)
2) It's a hook - Hooks are always 'running', that is, trying to hook into a game event, in this case, a weapon switch. They do have 'domains' - server, client, shared. This hooks is a shared hook, with a limitation (see #1A)

LOGIC
I see a challenge here.
Let me verify - you want to make sure the person being spawned is ONLY switching to a tool, camera, or physgun, right?
Think TRUE or FALSE.
With your IF statement the way it is now, _ANY_ item not matching the other two comes out false.

if newwep ~= "weapon_physgun" and newwep ~= "gmod_camera" and newwep ~= "gmod_tool" then
Say I switch to a camera.
(true and false and true) == false
switch to physgun
(false and true and true) == false
switch to any tool
(true and true and false) == false

Try checking to see if newwep IS any of the 3, and use OR, but with a negate in front of the check, and parenthesis to group.
if not (newwep == "weapon_physgun" or newwep == "gmod_camera" or newwep == "gmod_tool") then
physgun
not (true or false or false) == false (not true = false)
camera
not (false or true or false) == false (not true = false)
tool
not (false or false or true) == false (not true = false)
WEAPON
not (false or false or false) == TRUE (not false = true - KILL PROTECTION)

6
Off-Topic / Re: Help setting immunity on touching props
« Last post by that1nub on Yesterday at 03:43:32 PM »
ULX doesn't handle props. You'll need some sort of prop protection addon.

Look for SPP or FPP. FPP might work best for you if you have FAdmin.
I do have FPP, but I still can't set immunity, I have the highest rank but people lower than my rank can still touch my props. How do I fix this?
8
Off-Topic / Re: Help setting immunity on touching props
« Last post by MrPresident on Yesterday at 07:33:25 AM »
ULX doesn't handle props. You'll need some sort of prop protection addon.

Look for SPP or FPP. FPP might work best for you if you have FAdmin.
9
Off-Topic / Help setting immunity on touching props
« Last post by that1nub on Yesterday at 12:20:52 AM »
I have been looking around, and cannot find what I'm looking for. I am wanting to make it so people can touch props, but can't find an option in ULX's menu. I do have FAdmin, but immunity doesn't seem to work and lower ranks can still touch my props. I would disabled FAdmin, because I did read that FAdmin conflicts with ULX, but my issue is that I see no option on the ULX menu for touching props. Is there a plugin I need?
10
This is part of an addon that is complete. That is where the "v" is coming from. The "v" was defined further up by the coder who made the addon and he uses it a few times in that format (That is why I thought that is how he was turning off spawn protection when need be). Though, I did find a simple way of disabling spawn protection and am now using it instead. I will not be using   "v:SetNWBool("SpawnProtected", false)" anymore. I can send you the complete add-on if you would like to look at the code and see where I added my code into, But this is what my code now looks like. Again there are no errors, might be because it not running it at all, but I don't know where to properly place my code in order for it to run constantly and see if a player on the server is switching weapons.
Code: Lua
  1. local function CheckSwitch(ply , OW , NW)                               --Added code starts here
  2.     oldwep = OW:GetClass()
  3.     newwep = NW:GetClass()
  4.     print("Starting check...")
  5.         if newwep ~= "weapon_physgun" and newwep ~= "gmod_camera" and newwep ~= "gmod_tool" then
  6.                 ply.PreviouslyProtected = true
  7.                
  8.                 print ( ply:Nick() .. "'s New Weapon was not a " .. oldwep .. ", but instead a " .. newwep )
  9.                 print (ply:Nick() .. " Spawn Protection has been set to " .. SpawnProtected )
  10.     end
  11.         hook.Add( "PlayerSay", "Checkwep", function( ply, text, public ) --Check if code is even being ran at all
  12.         if ( string.lower( text ) == "!wep" ) then
  13.                 print(oldwep)
  14.                 return "[Global]" .. oldwep
  15.         end
  16. end )
  17.        
  18.     print("Past checks")
  19.     print( ply:Nick() .. " just attempted to switch from " .. oldwep .. " to " .. newwep .. ".")
  20. end
  21. end
  22. hook.Add("PlayerSwitchWeapon", "Check_allow_switch" , CheckSwitch)                      --Added code ends here
The "ply.PreviouslyProtected = true" is a part of the addon where if a player leaves spawn and comes back in he will not be protected again and I am using that to make it seem like when a player switches weapons to make the code think that he has left spawn and came back in. And that way spawn protection will be disabled.
Pages: [1] 2 3 ... 10