• Script Error: syntax error near 'timer'
    12 replies, posted
Hello guys. I am receiving this script error: syntax error near 'timer'. I don't know and don't understand the motivation of this error. I have already searched this error on the web but I haven't found anything! This are the "Script": function AdvertForPing() local LocalPlayer(ply) timer.Create( "AFPCheck", 1, 0, function() --<------- HERE IS THE ERROR, NEAR TIMER if ply:Ping() >= kickping then print( "Your ping is too high" ) else print( "Your ping isn't too high!" ) end end ) end Thank You!
Change it to local ply = LocalPlayer()
[QUOTE=code_gs;48936083]Change it to local ply = LocalPlayer()[/QUOTE] Ow, wow, thank you! Please can you give me some example of when I have to write a script in server folder or in client folder? I haven't understand this. For example, this: function AdvertForPing() local LocalPlayer(ply) timer.Create( "AFPCheck", 1, 0, function() if ply:Ping() >= kickping then print( "Your ping is too high" ) else print( "Your ping isn't too high!" ) end end ) end I have to write it in the client folder or in the server folder?
This would need to be in the client folder, because LocalPlayer() is only available clientside. Please use CODE tags the next time, so it is easier to read the code.
this file already is in client folder but don't works! In server folder I have created an other file, this is the code: [CODE] util.AddNetworkString( "KFPS" ) function KickForPing( kfp ) kfp:PrintMessage( HUD_PRINTTALK, "Ciao, " ..kfp:Nick() .. "! Hai 0 avvertimenti del ping.") net.Start("KFPS") end hook.Add( "PlayerInitialSpawn", "Start The Script", KickForPing ) [/CODE] in the client file i have added these lines: [CODE] net.Receive("KFPS", function() RunConsoleCommand("KFPSC") print("It works") end) concommand.Add("KFPSC", KickForPing) [/CODE] When I Spawn, in chat there is the message Ciao, Predator..... but the script don't automatically start, and in console there isn't the message "It works", So i think (net.Receive) don't works!
[QUOTE=J4FPredator;48936527] [CODE] util.AddNetworkString( "KFPS" ) function KickForPing( kfp ) kfp:PrintMessage( HUD_PRINTTALK, "Ciao, " ..kfp:Nick() .. "! Hai 0 avvertimenti del ping.") net.Start("KFPS") end hook.Add( "PlayerInitialSpawn", "Start The Script", KickForPing ) [/CODE] [/QUOTE] You are starting a net, but you are'nt sending it. [CODE]net.Send(kfp)[/CODE] should work. Also this script will only check the ping when the player spawns the first time. You should implement the script in a timer or something like that and run the check function every x seconds.
Sorry, i have edit the previous Reply! Re- Read my previous reply. You are using net.Send(KFP), I am using net.Start(KFP), is this the problem?
[QUOTE=J4FPredator;48936585]Sorry, i have edit the previous Reply! Re- Read my previous reply. You are using net.Send(KFP), I am using net.Start(KFP), is this the problem?[/QUOTE] Start the message like you're doing right now, but then send it to the player object in PlayerInitialSpawn. [lua] util.AddNetworkString( "KFPS" ) function KickForPing( kfp ) kfp:PrintMessage( HUD_PRINTTALK, "Ciao, " ..kfp:Nick() .. "! Hai 0 avvertimenti del ping.") net.Start("KFPS") --Start the message net.Send(kfp) --Send the message to kfp; player who is spawning. end hook.Add( "PlayerInitialSpawn", "Start The Script", KickForPing ) [/lua]
Thank you Greetings, but now the game give me other errors! [CODE] function KickForPing() local ply = LocalPlayer() timer.Create( "KFPCheck", 1, 0, function() --<---------- Second Error, Timer Failed if ply:Ping() >= kickping then --<--------- First Error print( "Your ping is too high" ) else print( "Your ping isn't too high" ) end end ) end [/CODE] [ERROR] addons/pscript_kickforping/lua/autorun/client/kfpconfig.lua:15: attempt to compare nil with number 1. unknown - addons/pscript_kickforping/lua/autorun/client/kfpconfig.lua:15 Timer Failed! [KFPCheck][@addons/pscript_kickforping/lua/autorun/client/kfpconfig.lua (line 14)]
Is kickping defined?
[QUOTE=code_gs;48936856]Is kickping defined?[/QUOTE] Sure local kickping = 500
Post the entire code
Fixed! before local KFP = {} KFP.kickping = 500 now local kickping = 500 Thank you!
Sorry, you need to Log In to post a reply to this thread.