How do I display a GUI to a single player, via a function for my gamemode?
ATM this is what I'm trying to use:
[Lua]
function PaintPlayer( pl )
if LocalPlayer() != pl then return end
--GUI code here
end
[/Lua]
..and its failing :(.
Make the player run the client console command? That won't make it open for everyone.
Yes you would probably use a console command. This might help :
[b][url=http://wiki.garrysmod.com/?title=Player.ConCommand]Player.ConCommand [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=http://wiki.garrysmod.com/?title=G.RunConsoleCommand]G.RunConsoleCommand [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
It's not probably..if you want a derma to open for a single player only then use
[lua]RunConsoleCommand("concommandher")[/lua]
No one will see it but the people who meet the criteria to run it.
[QUOTE=pyroboytodumax;26378259]Yes you would probably use a console command[/QUOTE]
Thank you lol, I was having a mental blank with this one :(, but how do I send an entity using it?
If you don't want to use a console command you can also do a UserMessage and hook that into a function which displays the gui.
My code...
[lua]
function DuelProcess( Sub, tar )
print( Sub )
print( tar )
tar:ConCommand("recieve" )
function recieve(pl,cmd,args)
--In this bit the "Sub" player entity is the player not the "tar" like its meant to
end
concommand.Add("recieve",recieve)
end
[/lua]
Any help?
Everything is fine, the tar and Sub are the correct players when I print them, it just doesn't show the GUI to the right person!
What is the factor that makes someone the "right person"? We can't help you if we don't know.
[QUOTE=jeff223;26396649]What is the factor that makes someone the "right person"? We can't help you if we don't know.[/QUOTE]
The function is receiving the players as it's supposed to, but for some reason the concommand always goes to the "Sub" player, no matter what I put there.
Not sure if you already saw it, but if you didn't:
[QUOTE=PortalGod;26389167]The way I would do that is like this:
[lua]
function DrawStuff()
if(LocalPlayer():GetNWBool("ShouldDraw")) then
//Woo
end
end
hook.Add("HUDPaint", "DrawStuff", DrawStuff)
[/lua]
Then, on the server, all you would have to do is <Player>:SetNWBool("ShouldDraw", true) on the server.
Don't forget to set it to the default on init.[/quote]
Sorry, you need to Log In to post a reply to this thread.