Recent Posts

Pages: [1] 2 3 ... 10
Off-Topic / Re: Help setting immunity on touching props
« Last post by MrPresident on Today 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.
Off-Topic / Help setting immunity on touching props
« Last post by that1nub on Today 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?
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
  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 )
  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.
Though it's possible you do it elsewhere that I don't see, you aren't setting 'v' in v:SetNWBool.
(Though, I'd be surprised if there's not a server console error stating V is nil or invalid entity)

Is that a variable that's supposed to be attached to player "ply" entity?

If the entity is limited to admins, the group in question needs to inherit from the admin group.
Ha, Noice. This works. So, I tried the different ways that you have shown and I went with the second to last one( a bit Shorter one). The only thing that I saw was that the "or" did not work. When I had the "or" there it would run the code, no matter what. So I replaced the "or" with a "and" and now it runs perfectly. When I switch to any of the weapons that are listed in the code it skips the if and keeps going. *Horray!  ;D!*

Code: Lua
  1.         if newwep ~= "weapon_physgun" and newwep ~= "gmod_camera" and newwep ~= "gmod_tool" then

Now all that is left to do is add it to all together and see if it works!. Hopefully, it does.

EDIT: It did not.  :-[ There are no errors in the code but it seems like my code that I have added does not even run at all. I am testing this on a real server that I own and I don't know if that makes a difference. I did put it into the server autorun file, but still nothing. I tried to drop it into a for loop that was already there that looked like it was for checking if the player should be spawn protected or not but it did not work either.
Though you can use operators in an if statement;
1) you can't do it the way you're trying
- you must compare the variable each time. I'm 95% sure you can't use short circuit if comparisons, even though you can use short circuit variable assignments
2) You're mixing comparison methods. Don't use "a ~= b" along with "not b == c".
- Sure, both would work, but pick a style and flow through out your code.

My personal preference when learning is to make code "readable", or in my case, as close to english as possible.
So, try this line out for your line 6 in your example
Code: [Select]
if not newwep == "weapon_physgun" or not newwep == "gmod_camera" or not newwep == "gmod_tool" thenIf you prefer, and using a few characters less (which in real world large project coding, can save hundreds of bytes of course)
Code: [Select]
if newwep ~= "weapon_physgun" or newwep ~= "gmod_camera" or newwep ~= "gmod_tool" then
Both code lines would perform same check.

If I'm wrong about short circuit comparisons, you might get this to work; (feel free to try it, no, please do).
Code: [Select]
if not newwep == "weapon_physgun" or "gmod_camera" or "gmod_tool" then
Off-Topic / M9K Weapons List & Ammo Spreadsheet
« Last post by BraveNM22 on Yesterday at 12:18:53 PM »
 idk if this needs to go in off-topic, but hey! thought some people would want this. I know i really did, so i made my own.
its anonymous so no need to worry. Thanks for checking this out!

oh and really helped me out in making this so check that out too  :)
What you have given me is working great. I have found a way to make it work with what I need. The only thing that I am running into now is that because they are all separate if statements spawn protection is disabled even if I switch to the gmod_tool, or camera, or physics gun. I know that in Java you can do or statements to check multiple conditions with one if statement and i have tried this with the code by doing this.

Code: Lua
  1. local function CheckSwitch(ply , OW , NW)
  2.     oldwep = OW:GetClass()
  3.     newwep = NW:GetClass()
  4.     print("Starting check...")
  6.     if newwep ~= "weapon_physgun" or not "gmod_camera" or not "gmod_tool" then
  7.                 v:SetNWBool("SpawnProtected", false)                                                                      --this is for the disabling of the spawn protect
  8.                 print ( ply:Nick() .. "'s New Weapon was not a " .. oldwep ", but instead a " .. newwep )
  9.     end
  11.     print("Past checks")
  12.     print( ply:Nick() .. " just attempted to switch from " .. oldwep .. " to " .. newwep .. ".")
  13. end
  15. hook.Add("PlayerSwitchWeapon", "Check_allow_switch" , CheckSwitch)

This works but not with the "or not" conditions that I have added. When I switch to then physics gun it skips the if and does what I need it to, but when I go to the other two it still runs the if statement.
Pages: [1] 2 3 ... 10