• Annoying error that shouldn't be there?
    12 replies, posted
So I was writing a ULX command that would gag someone for a certain amount of time. [CODE]function ulx.tgag( calling_ply, target_ply, time ) target_ply:SetNWBool("ulx_gagged", true) timer.Create( "tgagged_"..target_ply:Nick(), time * 60, 1, function() target_ply:SetNWBool("ulx_gagged", false) ulx.fancyLogAdmin( target_ply, "#T has been auto ungagged.") end ) ulx.fancyLogAdmin( calling_ply, "#A gagged #T for #Y minutes.", target_ply, time ) end local tgag = ulx.command( CATEGORY_NAME, "ulx tgag", ulx.tgag, "!tgag" ) tgag:addParam{ type=ULib.cmds.PlayersArg } tgag:addParam{ type=ULib.cmds.NumArg, min=1, default=1, hint="Use normal gag to gag forever", ULib.cmds.round } tgag:addParam{ type=ULib.cmds.BoolArg, invisible=true } tgag:defaultAccess( ULib.ACCESS_ADMIN ) tgag:help( "Gag target, disables microphone for X amount of minutes." )[/CODE] The problem is, whenever I run it on someone, I get this. [CODE][ERROR] addons/linkjayulx/lua/ulx/modules/sh/linksstuff.lua:414: attempt to call method 'SetNWBool' (a nil value) 1. call - addons/linkjayulx/lua/ulx/modules/sh/linksstuff.lua:414 2. __fn - addons/ulib/lua/ulib/shared/commands.lua:943 3. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296[/CODE] Line 414 refers to the SetNWBool. I even brought it up to Niandra Lades and even she didn't know what to make of the error. Any help will help.
Is that error pointing to the first SetNWBool or the second? Because you aren't checking if the player is still valid after the timer.
[QUOTE=code_gs;50528163]Is that error pointing to the first SetNWBool or the second? Because you aren't checking if the player is still valid after the timer.[/QUOTE] Happens on the first one.
Is this called clientside or serverside?
[QUOTE=code_gs;50528665]Is this called clientside or serverside?[/QUOTE] In the SH so both. I checked the NW bool lua page and it says it can be called from either.
[QUOTE=linkjay1;50528744]In the SH so both. I checked the NW bool lua page and it says it can be called from either.[/QUOTE] You can set it on the LocalPlayer or any player from the server, but not another player from the calling player's client.
Your amazing plugin can be circumvented by rejoining the server, and will error if the player exits the server before the timer is ran. ( i.e. the timer will be ran after the player has left, and it will still attempt to "ungag" the player )
[QUOTE=code_gs;50528911]You can set it on the LocalPlayer or any player from the server, but not another player from the calling player's client.[/QUOTE] What? Am confuse. Clarify some more? [editline]16th June 2016[/editline] [QUOTE=Robotboy655;50528914]Your amazing plugin can be circumvented by rejoining the server, and will error if the player exits the server before the timer is ran. ( i.e. the timer will be ran after the player has left, and it will still attempt to "ungag" the player )[/QUOTE] That is something I am yet to work out. Thank you for pointing that out. One thing at a time though.
Only set it serverside. You can't set it on a player clientside when it's not their client.
[QUOTE=code_gs;50531987]Only set it serverside. You can't set it on a player clientside when it's not their client.[/QUOTE] See, but then it makes it a whole lot more complicated because ULX commands are generally called on SH so that would mean I would need to completely redo it to make it a serverside addon. Also, the normal gag command is also calls the exact same Network Boolean in the same SH side.
[QUOTE=linkjay1;50536895]See, but then it makes it a whole lot more complicated because ULX commands are generally called on SH so that would mean I would need to completely redo it to make it a serverside addon. Also, the normal gag command is also calls the exact same Network Boolean in the same SH side.[/QUOTE] if SERVER then?
[QUOTE=linkjay1;50536895]See, but then it makes it a whole lot more complicated because ULX commands are generally called on SH so that would mean I would need to completely redo it to make it a serverside addon. Also, the normal gag command is also calls the exact same Network Boolean in the same SH side.[/QUOTE] There is no such thing as shared. Shared is just what we call code that runs BOTH on the server and client. You think we have 3 sides, CLIENT SERVER and SHARED, which is wrong. We only have CLIENT and SERVER. Shared code runs two times, once on server and once on client. So to make it only run on the server, just use a simple if statement like code_gs said: [code]if SERVER then[/code] On the server, the global SERVER variable is set to true and false on the client.
[QUOTE=Metamist;50543064]There is no such thing as shared. Shared is just what we call code that runs BOTH on the server and client. You think we have 3 sides, CLIENT SERVER and SHARED, which is wrong. We only have CLIENT and SERVER. Shared code runs two times, once on server and once on client. So to make it only run on the server, just use a simple if statement like code_gs said: [code]if SERVER then[/code] On the server, the global SERVER variable is set to true and false on the client.[/QUOTE] Okay, going to go try that.
Sorry, you need to Log In to post a reply to this thread.