• attempt to index local 'arguments' (a number value)
    7 replies, posted
[CODE] if (string.find(arguments[1], 0) or string.find(arguments[1], 1)) then if (arguments == 0) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You disabled your spotlight!"); end;[/CODE] Errors attempt to index local 'arguments' (a number value)
Paste the whole function. arguments is a number in that context, thus string functions won't work
[CODE]local COMMAND = Clockwork.command:New("ScannerSpotlight"); COMMAND.tip = "Enable the spotlight (as a scanner)."; COMMAND.text = "<number Value>"; COMMAND.arguments = 1; -- Called when the command has been run. function COMMAND:OnRun(player, arguments) if (Schema.scanners[player]) then local scanner = Schema.scanners[player][1]; if (IsValid(scanner)) then local arguments = tonumber(arguments[1]) if (string.find(arguments[1], 0) or string.find(arguments[1], 1)) then if (arguments == 0) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You disabled your spotlight!"); end; elseif (arguments == 1) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You enabled your spotlight!"); else Clockwork.player:Notify(player, "You can only choose 0 or 1!"); end; end; else Clockwork.player:Notify(player, "You are not a scanner!"); end; end; COMMAND:Register();[/CODE]
The string.find check is useless. [code]if (IsValid(scanner)) then local arguments = tonumber(arguments[1]) if (arguments == 0) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You disabled your spotlight!"); elseif (arguments == 1) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You enabled your spotlight!"); else Clockwork.player:Notify(player, "You can only choose 0 or 1!"); end; end;[/code]
[QUOTE=code_gs;51198983]The string.find check is useless. [code]if (IsValid(scanner)) then local arguments = tonumber(arguments[1]) if (arguments == 0) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You disabled your spotlight!"); elseif (arguments == 1) then scanner:KeyValue("SpotlightDisabled", arguments); Clockwork.player:Notify(player, "You enabled your spotlight!"); else Clockwork.player:Notify(player, "You can only choose 0 or 1!"); end; end;[/code][/QUOTE] there is another one saying 'TEXT' inside sv_hooks [CODE]-- Called when a player switches their flashlight on or off. function Schema:PlayerSwitchFlashlight(player, on) if (on and (player:GetSharedVar("tied") != 0)) then return false; end; if (on and (self.scanners[player])) then Clockwork.player:RunClockworkCommand(player, "ScannerSpotlight", 1); elseif off then Clockwork.player:RunClockworkCommand(player, "ScannerSpotlight", 0); end; end;[/CODE] problem number 3 [url]https://developer.valvesoftware.com/wiki/Npc_cscanner[/url] SpotlightDisabled is a keyvalue when I used KeyValue it said that it didn't know what that is, when I used SetKeyValue I think it created one cause nothing happend. There is an input called "DisableSpotlight" but I am not sure what it does. Does it also have 0 or 1? What I tried at sv_hooks is that instead of having access to flashlight that it can change his scannerspotlight. It still does have access to it.
[code]elseif off then[/code] off isn't defined. Did you mean "not on"? SetKeyValue accepts a string only, so doing the tonumber conversion might cause it to not work. Also, from the description, DisableSpotlight only spawns the scanner without the spotlight enabled, but doesn't completely disable it. You might want to try setting the length and width of the spotlight to 0.
[QUOTE=code_gs;51200009][code]elseif off then[/code] off isn't defined. Did you mean "not on"? SetKeyValue accepts a string only, so doing the tonumber conversion might cause it to not work. Also, from the description, DisableSpotlight only spawns the scanner without the spotlight enabled, but doesn't completely disable it. You might want to try setting the length and width of the spotlight to 0.[/QUOTE] [QUOTE=code_gs;51200009][code]elseif off then[/code] You might want to try setting the length and width of the spotlight to 0.[/QUOTE] SpotlightLength does this go through walls I don't guess so? Is there a default length? SpotlightWidth same for this. [url]https://developer.valvesoftware.com/wiki/Integer[/url] I am not doing a command for this. If its on 1 its enabled and then it needs a spotlightwidth and length
[QUOTE=code_gs;51200009][code]elseif off then[/code] off isn't defined. Did you mean "not on"? SetKeyValue accepts a string only, so doing the tonumber conversion might cause it to not work. Also, from the description, DisableSpotlight only spawns the scanner without the spotlight enabled, but doesn't completely disable it. You might want to try setting the length and width of the spotlight to 0.[/QUOTE] I removed the hook but making a spotlightlength and spotlightwidth didn't help. There is something where scanners enable its spotlight. SpotlightDisabled 0 turns the spotlight NORMALY on well its wrong spotlightdisabled means it will stay disabled for the scanner. There is DisableSpotlight and this needs to have something and I am using the map editor to find this out. Do you know a solution to this?
Sorry, you need to Log In to post a reply to this thread.