• Best hook to drawing SimpleText with a player object
    4 replies, posted
Hello, I am "VERY" new to lua coding and I am not familiar with any hooks for drawing a SimpleText function with a player object. My code is below: [CODE]function spawnStuff( ply ) draw.SimpleText( "Hello "..ply:Nick().."! Welcome to my server!", "Default", 1, 1, Color( 50, 50, 50 ) ) end hook.Add( "HUDPaint", "SpawnStuff", spawnStuff )[/CODE] Note that I tried HUDPaint and it doesn't pass the player object into the function. What would be a good hook for doing so?
[QUOTE=trippymodzhq;47840401]Hello, I am "VERY" new to lua coding and I am not familiar with any hooks for drawing a SimpleText function with a player object. My code is below: [CODE]function spawnStuff( ply ) draw.SimpleText( "Hello "..ply:Nick().."! Welcome to my server!", "Default", 1, 1, Color( 50, 50, 50 ) ) end hook.Add( "HUDPaint", "SpawnStuff", spawnStuff )[/CODE] Note that I tried HUDPaint and it doesn't pass the player object into the function. What would be a good hook for doing so?[/QUOTE] HUDPaint will work perfectly. Don't use ply though, as it isn't an argument for HUDPaint. Use LocalPlayer() instead of ply.
[QUOTE=A Fghtr Pilot;47840454]HUDPaint will work perfectly. Don't use ply though, as it isn't an argument for HUDPaint. Use LocalPlayer() instead of ply.[/QUOTE] So just to be clear, would it look like this? [code]function spawnStuff() draw.SimpleText( "Hello "..LocalPlayer().."! Welcome to my server!", "Default", 1, 1, Color( 50, 50, 50 ) ) end hook.Add( "HUDPaint", "SpawnStuff", spawnStuff )[/code]
ply is mostly used to refer to the Player Object. Clientside, you can use LocalPlayer() as the client Player Object. So out of ply:Nick() would be LocalPlayer():Nick()
Its working now! Thanks for the help guys :smile:
Sorry, you need to Log In to post a reply to this thread.