• Ply:ChatPrint() running too many times?
    4 replies, posted
Okay, so... I was wondering why when I have the following code in my script, it seems to execute it 3 times: [lua] if CLIENT then self.Owner:ChatPrint( "There are "..math.Round((timed - CurTime())).." seconds until you can use this again!") end [/lua] So, for example, it will print: "There are 13 seconds until you can use this again!" "There are 13 seconds until you can use this again!" "There are 13 seconds until you can use this again!" Any ideas? [highlight](User was banned for this post ("wrong section" - postal))[/highlight]
Where are you using this? ChatPrint runs when the function does, so if it's on Think (hint don't do this) or something that gets called extremely often, it'll get a bit spammy
the fact that it's using self.Owner leads me to believe its probably a swep. it's probably in an attack function, so change [LUA]if CLIENT then[/LUA] to [LUA]if CLIENT and IsFirstTimePredicted() then[/LUA] because the client will perform the action as many times as it takes until the server responds, and we only need to execute this once.
Also since it's clientside use chat.AddText(), chatprint is so ugly :(
[QUOTE=rejax;44777764]snip[/QUOTE] Thanks! That helps.
Sorry, you need to Log In to post a reply to this thread.