• Draw HUD on Player/Caller's screen after ENT:Use
    3 replies, posted
Hi, I have an entity, and the player can use it to change to a random pool of player-models for 60 seconds, then they return to their origianl playermodel. This all works 100%, however, I want to be able to draw on the Player's screen with a HUD. How can I do this? How can I tell when ENT:Use has been used, to draw HUD for the client? Edit: Another problem I'm having - Not allowing them to disgusie whilst already disguised. [lua] function ENT:Use(activator, caller) if IsDisguised == true then caller:PrintMessage(3, "You are already disguised!") else IsDisguised = true local InitialModel = caller:GetModel() PossiblePModels = { "models/player/alyx.mdl", "models/player/barney.mdl", "models/player/breen.mdl", "models/player/eli.mdl", "models/player/gman_high.mdl" } caller:SetModel( table.Random(PossiblePModels) ) timer.Simple(5, function() caller:SetModel(InitialModel) isDisguised = false end ) self:Remove() end end [/lua] I'm trying to make it so they can't use the disguise whilst they're already disguised. However, it works initially, but then it doesn't let disguise again even though I'm at my original model. Something wrong with my booleans?
Where are you declaring your "IsDisguised" variable? I think you will want to use NW variables for this particular situation. [url]https://wiki.garrysmod.com/page/Entity/GetNWBool[/url] [url]https://wiki.garrysmod.com/page/Entity/SetNWBool[/url] In init.lua you should do the following Use a "SetNWBool" function when on a player spawn hook. So it should look something like this ply:SetNWBool( "isDisguised", false ) In your disguising code whenever you need to check the variable use... caller:GetNWBool( "isDisguised" ) Or if you need to change it... caller:SetNWBool( "isDisguised" ,true/false) Then in cl_init.lua assuming you already know how to draw a HUD you can access the player with local ply = LocalPlayer() then when you want to check if the player is disguised and then maybe draw something relating to it... if ply:GetNWBool( "isDisguised" ) then //put code that draws what you want end If you don't know anything about HUD drawing take a look at this [url]https://wiki.garrysmod.com/page/GM/HUDPaint[/url]
use net lib not NW vars
[QUOTE=pierre0158;52358688]use net lib not NW vars[/QUOTE] Did some research on this and net lib seems like it would be the better solution. I've personally never used it just because I've never heard of it but according to some other people the reason why this is better is because setting NWvars can strain your server more than necessary. Here is a thread I found. [url]https://facepunch.com/showthread.php?t=1495349[/url]
Sorry, you need to Log In to post a reply to this thread.