• [BUG?] OnPlayerChat hook
    10 replies, posted
I have been working on an addon for chat in ttt, and I have been using this clientside hook. [IMG]http://gyazo.com/1a23a4ec20b7c38dda4a2880aa310ff0.png?1365997315[/IMG] I have been transferring it into a table that looks like this. [IMG]http://gyazo.com/dc7e663baa4718a299b38ffc4df2faf8.png?1365997937[/IMG] I have been having issues with code later on so I eventually worked my way back to the original transfer, and printed out the info table. [IMG]http://gyazo.com/863b5341246a57a4a9640b388fae06d1.png?1365997559[/IMG] What I have noticed. index ply = <what i type> isDead = ceases to exist text & teamchat are set to bools Please help me. I am completely and utterly stuck. I don't know what else to think other than there is a bug with that hook **EDIT** I have narrowed down the problem to the fact player is not passed to the hook. WTF and why? **EDIT2** I'll give this post a good day before i x-post to bug reports
[QUOTE=Ludicium;40285835][IMG]http://gyazo.com/dc7e663baa4718a299b38ffc4df2faf8.png?1365997937[/IMG] [/QUOTE] You can't do [lua]info.ply = player[/lua] since the word "player" is already a function (or something else) Try change it to "ply".
[QUOTE=Nak;40286305]You can't do [lua]info.ply = player[/lua] since the word "player" is already a function (or something else) Try change it to "ply".[/QUOTE] I don't think so, in this case because he gave the entity that's being returned by the hook the name of player, it refers to the entity rather than the class. As for your code, why're you setting up a table and sending it to the server? There is GM.PlayerSay.
[QUOTE=jrj996;40286571]I don't think so, in this case because he gave the entity that's being returned by the hook the name of player, it refers to the entity rather than the class. As for your code, why're you setting up a table and sending it to the server? There is GM.PlayerSay.[/QUOTE] I suppose that makes a lot more sense, but it still doesn't explain why the hook is either broken or documented incorrectly.
Okay, just as a test, change the code to this: [lua] function ChatText( _player, strText, bTeamOnly, bPlayerIsDead ) print( _player ) print( strText ) print( bTeamOnly ) print( bPlayerIsDead ) end hook.Add( "OnPlayerChat", "PlayerChat", ChatText ) [/lua] And paste the output when you type. I was just messing around with this hook the other day and it was working as intended.
[QUOTE=TheCloak;40288740]Okay, just as a test, change the code to this: [lua] function ChatText( _player, strText, bTeamOnly, bPlayerIsDead ) print( _player ) print( strText ) print( bTeamOnly ) print( bPlayerIsDead ) end hook.Add( "OnPlayerChat", "PlayerChat", ChatText ) [/lua] And paste the output when you type. I was just messing around with this hook the other day and it was working as intended.[/QUOTE] I'll give that a try when i get home.
[QUOTE=Ludicium;40290871]I'll give that a try when i get home.[/QUOTE] I just did it: [code]Player [1]['Apple] This is my text false false[/code] This is my output. Which means it may have something to do with the WriteTable function, which is what I suspected in the first place. I'll test it and report back Testing PrintTable: [code]TeamOnly = false myname = Player [1]['Apple] mytext = Testing printtable IsPlayerDead = false 'Apple: Testing printtable [/code] Works as intended. Testing WriteTable: [code]TeamOnly = false myname = Player [1]['Apple] mytext = Testing writetable IsPlayerDead = false f[/code] Everything is running as intended. I can't really see what the problem would be on your side.
**SOLVED**
Nice job asking for help then not posting your solution. I'm sure users will eventually google this question and get led to this thread, to no avail.
Could you go into more detail please? Just so people with the same problem down the road know what you did to fix this. [B]Edit:[/B] -Kinda ninja'd
Oh, I eventually made the function not apart of the LCC table and changed player to _player. That worked.
Sorry, you need to Log In to post a reply to this thread.