Draw error

Here is the error::

ERROR: GAMEMODE:‘ShowHelp’ Failed: Roleplay/gamemode/init.lua:96: attempt to index global ‘draw’ (a nil value)

Here is the code portion:

[lua]function GM:ShowHelp( ply )
draw.DrawText(“TORTOISE ROLEPLAY TORTOISE ROLEPLAY TORTOISE ROLEPLAY”, “HUDNumber5”, ScrW() / 2 - 70, ScrH() - 63, Color(0,0,255,255),1)
umsg.Start(‘playermenu’, ply);
umsg.End();
end[/lua]

I get why it is erroring, But what can i do to fix it? A quick response would help me alot. Thanks.

Because you’re trying to draw on the server? Which is basically console so it can’t have a menu?

What, I just need to know how i can get this to work…

[lua]function GM:ShowHelp( ply )
ply:SendLua(“HelpMenu()”)
end[/lua]

You’d define HelpMenu() in a client-side file. And that’s how you make that player call it. shrug

… The helpmenu is not the problem… I need to use a draw.DrawText, And it is erroring. THE DRAWTEXT. =]

Oh sorry. Maybe…:

[lua]function GM:ShowHelp( ply )
ply:SendLua(“hook.Add(“HUDPaint”, “DrawThatText”, function () draw.DrawText(“TORTOISE ROLEPLAY TORTOISE ROLEPLAY TORTOISE ROLEPLAY”, “HUDNumber5”, ScrW() / 2 - 70, ScrH() - 63, Color(0,0,255,255),1)end)”)
umsg.Start(‘playermenu’, ply);
umsg.End();
end[/lua]

…? Why do you wanna draw? If you’re using panels, you can use a DLabel, and position it wherever with that text. shrug

Alright, That worked, How can i make it so it will only draw if ShowHelp is active?

That’s the problem. You have to do hook.Remove(“HUDPaint”,“DrawThatText”) on the client at some point. But I’m not sure where you’d wanna do that. Sorry =P I don’t get how you’re setting up the help menu so I’m pretty limited.

add me to steam wargamerz@yahoo.com is my steam account name, Add me.

Just put it in a cloentside file! This is not Gmod 9, Serveride only scripts are dead’

I’ve got it working. I need a way to only make it draw when the f1 when is active (open)

You might want to use input.IsKeyDown in a think hook and have it send an usermessage when the key is first pressed to open your clientside menu then another when the key is released to close it.

edit : you have to realise you’d be sending the whole menu to them each time with sendlua everytime they press F1! That’s a lot of useless traffic! Really just put your draw hooks in cl_init.lua and use usermessages.

I know, I got it figured out mate =]