Hi,
I create a client-side script for players to see images but when the player dies the image remains on the screen.
[CODE]local function horror022()
if LocalPlayer():GetNWBool("horror022") then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end[/CODE]
how to stop these images when respawn
thx for your help
best regard
[CODE]
if not LocalPlayer():Alive() then -- not sure if you want them dead or alive but you choose
-- draw stuff
end
[/CODE]
thx for your help
I tested this but no work I see flash pic :/
[QUOTE]if not LocalPlayer():Alive() then -- not sure if you want them dead or alive but you choose
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end[/QUOTE]
and this
[QUOTE]--if CLIENT then
local function deadhorror022()
if not LocalPlayer():GetNWBool("horror022") then -- not sure if you want them dead or alive but you choose
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror022/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() ) -- draw stuff
end
end
hook.Remove( "deadhorror022", "horror022" )
end[/QUOTE]
[QUOTE=ST3BL;50888965]thx for your help
I tested this but no work I see flash pic :/[/QUOTE]
Didn't you just mixed up LocalPlayer():Alive and LocalPlayer():GetNWBook("horror022") ? 5th line of your second quote.
yes
it's posible this ?
[QUOTE]if not LocalPlayer():Alive() then -- not sure if you want them dead or alive but you choose
player::SetNWBool("horror022", false)
end[/QUOTE]
Why are you using that network bool at all when it's faster to just use ply:Alive()?
sorry this is my 2nd little script :/[QUOTE=MPan1;50889093]Why are you using that network bool at all when it's faster to just use ply:Alive()?[/QUOTE]
This was already said but what I meant was:
[CODE]
local function horror022()
if LocalPlayer():Alive() then -- or not alive depending on what you want
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end
[/CODE]
[editline]15th August 2016[/editline]
Also, using Material in a HUDPaint hook is a bit slow so it's a good idea to cache the images beforehand, e.g.
[CODE]
local pics = {
Material("horror/pic1.jpg","noclamp smooth"), -- smooth makes it look... smoother
Material("horror/pic2.jpg","noclamp smooth"),
Material("horror/pic3.jpg","noclamp smooth")
}
local function horror022()
if LocalPlayer():Alive() then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( table.Random( pics ) )
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end
[/CODE]
[QUOTE=MPan1;50889122]:snip:[/QUOTE]
Please never use table.Random when it's sequential, it even notes this on the table.Random page.
I tested your but now when I spwan I see flash pic [QUOTE]local pics = {
Material("horror/pic1.jpg","noclamp smooth"), -- smooth makes it look... smoother
Material("horror/pic2.jpg","noclamp smooth"),
Material("horror/pic3.jpg","noclamp smooth")
}
local function horror022()
if LocalPlayer():Alive() then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( table.Random( pics ) )
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end but no when I spawn I see the pic flash [/QUOTE] [QUOTE=MPan1;50889122]This was already said but what I meant was:
[CODE]
local function horror022()
if LocalPlayer():Alive() then -- or not alive depending on what you want
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end
[/CODE]
[editline]15th August 2016[/editline]
Also, using Material in a HUDPaint hook is a bit slow so it's a good idea to cache the images beforehand, e.g.
[CODE]
local pics = {
Material("horror/pic1.jpg","noclamp smooth"), -- smooth makes it look... smoother
Material("horror/pic2.jpg","noclamp smooth"),
Material("horror/pic3.jpg","noclamp smooth")
}
local function horror022()
if LocalPlayer():Alive() then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( table.Random( pics ) )
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end
[/CODE][/QUOTE]
[editline]15th August 2016[/editline]
Pls help my script work great
I want just remove HudPaint when player die :/
you'll see them flash because they're changing every single frame, right?
right and when player respawn is finish[QUOTE=mib999;50889435]you'll see them flash because they're changing every single frame, right?[/QUOTE]
I can use fonction Player:Deaths() for close my local function horror022() when player die and respawn?
[CODE]local function horror022()
if LocalPlayer():GetNWBool("horror022") then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end[/CODE]
Smallup pls help me :/
Of course when you spawn you see the picture, if you want it to only show when you're dead then just change
[CODE]
if LocalPlayer():Alive() then
[/CODE]
To
[CODE]
if not LocalPlayer():Alive() then
[/CODE]
[editline]16th August 2016[/editline]
So it'd be
[CODE]
local pics = {
Material("horror/pic1.jpg","noclamp smooth"), -- smooth makes it look... smoother
Material("horror/pic2.jpg","noclamp smooth"),
Material("horror/pic3.jpg","noclamp smooth")
}
local function horror022()
if not LocalPlayer():Alive() then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( table.Random( pics ) )
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
[/CODE]
Then again, I'm just getting more and more confused over what you actually want to happen
[editline]16th August 2016[/editline]
Also, as said before, the pictures obviously flash since they change every frame. Do you not want them to flash? If so, then just use a variable
[CODE]
local pics = {
Material("horror/pic1.jpg","noclamp smooth"), -- smooth makes it look... smoother
Material("horror/pic2.jpg","noclamp smooth"),
Material("horror/pic3.jpg","noclamp smooth")
}
local randompic -- we can use this variable to stop the pictures from flashing - this will make only one different picture appear whenever you die
local function horror022()
if not LocalPlayer():Alive() then
randompic = randompic or table.Random( pics )
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( randompic )
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
else
randompic = nil
end
end
hook.Add("HUDPaint", "horror022", horror022)
[/CODE]
well sorry you have confused
my script work great player die and see pics
[CODE]if CLIENT then
local function horror022()
if LocalPlayer():GetNWBool("horror022") then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end[/CODE]
I want just creat another code for close this when player respawn
Try the thing I posted before just in case it actually works for what you want to do
no work ,my script is same player die and see pics
what I mean is when it respawn it should no longer see
[QUOTE=MPan1;50894029]Try the thing I posted before just in case it actually works for what you want to do[/QUOTE]
[editline]16th August 2016[/editline]
my script triggers pictures when he is alive and when he dies
but I see the pictures even when I respawn So it should be stopped
you understand
sorry for my bad english ;/
I Thank You for the time you give me
wtf you have a problem to the head ?[QUOTE=timz9;50895758]…………………,,-‘´ … _,,,,,’;:-,……………….
………………..,-(c\ `;-=´,_,-~-, `……………
………………,/ …¯’\, º ,/.’-~°,’ .¯`’-,………….
………………/ … …¯,_ ~–~’,, …’.………
……………..| … … . . ¯¨¨¨(̅_̅_̅_̅((_̅_̲̅м̲̅a̲̅я̲̅i̲̅j̲̅u̲̅a̲̅n̲̅_̅_ ̅_̅() ڪے
……………..| … … . , … .`’-, … |……….
……………./\ … … .“-,,,-’~-~’ … ’|……….
………….,/’`\,`’-, … … … … . . /.………
░█▀▄░█░█░█▀█░░█▀▀░▀█▀░█▀▀░█▀█░
░█░█░█░█░█▀▀█░▀▀█░░█░░█▀▀░█▀▀░
░▀▀░░▀▀▀░▀▀▀▀░▀▀▀░░▀░░▀▀▀░▀░░░[/QUOTE]
[QUOTE=ST3BL;50893997]well sorry you have confused
my script work great player die and see pics
[CODE]if CLIENT then
local function horror022()
if LocalPlayer():GetNWBool("horror022") then
surface.SetDrawColor( 255, 255, 255, 255 ) -- Next three lines draw the hand (your code)
surface.SetMaterial( Material("horror/pic"..math.random(1,3)..".jpg"))
surface.DrawTexturedRect( 0, 0, ScrW(), ScrH() )
end
end
hook.Add("HUDPaint", "horror022", horror022)
end[/CODE]
I want just creat another code for close this when player respawn[/QUOTE]
You don't seem to understand HUDPaint. HUDPaint is run on every frame. With the code you posted, it will check the NWBool "horror022" every frame, and if it is true, it will randomly pick one of the images every frame, and then draw the picked image every frame. All you have to do to make it go away is NOT draw it. So, if "horror022" became false, it would stop drawing the image every frame, and it would disappear.
Based on your description on when it should appear, it sounds like using LocalPlayer():Alive() instead of that NWBool would be better, since you won't have to manually set it to true or false. I would also suggest you listen to the advice about not calling 'Material' every frame, as it wastes performance with no benefit.
[QUOTE=ST3BL]Hi this script is for my SWEP
look you have understand
my SWEP
[CODE]*snip*[/CODE]
my client-side script
[CODE]*snip*[/CODE][/QUOTE]
Why did you send me a private message? Not only is it rude to the other participants of the thread, I was monitoring the thread [i]from work[/i] while [i]not logged in[/i]. I'm not gonna see your private message until I log in again.
Based on the script you sent, you appear to be setting the NWBool to true when the player uses the secondary fire of your SWEP, and the ONLY place that sets the NWBool to false is in the primary fire. Are you purposely keeping the image on the screen until the user presses the primary fire, even if they switch weapons? Personally, I wouldn't do this, as it reeks of bad design, but if this is what you want, you will need to remove the image either when they die, or when they respawn. These are the hooks you would need:
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PostPlayerDeath]GM:PostPlayerDeath[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url]
I think it would be better to have it expire automatically after a few seconds. You seem to know how timer.Simple works, so you can use that.
You should probably also use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawHUD]SWEP:DrawHUD[/url] instead of HUDPaint, as it only gets called while you have the weapon out.
sorry for this but
is it rude for my too to receive this [QUOTE]
timz9 posted:
…………………,,-‘´ … _,,,,,’;:-,……………….
………………..,-(c\ `;-=´,_,-~-, `……………
………………,/ …¯’\, º ,/.’-~°,’ .¯`’-,………….
………………/ … …¯,_ ~–~’,, …’.………
……………..| … … . . ¯¨¨¨(̅_̅_̅_̅((_̅_̲̅м̲̅a̲̅я̲̅i̲̅j̲̅u̲̅a̲̅n̲̅_̅_ ̅_̅() ڪے
……………..| … … . , … .`’-, … |……….
……………./\ … … .“-,,,-’~-~’ … ’|……….
………….,/’`\,`’-, … … … … . . /.………
░█▀▄░█░█░█▀█░░█▀▀░▀█▀░█▀▀░█▀█░
░█░█░█░█░█▀▀█░▀▀█░░█░░█▀▀░█▀▀░
░▀▀░░▀▀▀░▀▀▀▀░▀▀▀░░▀░░▀▀▀░▀░░░
[/QUOTE]
[QUOTE=Jcw87;50898033]Why did you send me a private message? Not only is it rude to the other participants of the thread, I was monitoring the thread [i]from work[/i] while [i]not logged in[/i]. I'm not gonna see your private message until I log in again.
Based on the script you sent, you appear to be setting the NWBool to true when the player uses the secondary fire of your SWEP, and the ONLY place that sets the NWBool to false is in the primary fire. Are you purposely keeping the image on the screen until the user presses the primary fire, even if they switch weapons? Personally, I wouldn't do this, as it reeks of bad design, but if this is what you want, you will need to remove the image either when they die, or when they respawn. These are the hooks you would need:
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PostPlayerDeath]GM:PostPlayerDeath[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url]
I think it would be better to have it expire automatically after a few seconds. You seem to know how timer.Simple works, so you can use that.
You should probably also use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawHUD]SWEP:DrawHUD[/url] instead of HUDPaint, as it only gets called while you have the weapon out.[/QUOTE]
[editline]17th August 2016[/editline]
well I tested this but I don't know why no work ;(
[CODE]if CLIENT then
local function spawn( ply )
ply:SetNWBool("horror022", false);
ply:SetMaterial("");
end
hook.Add( "PlayerSpawn", "diehorror022", spawn )
hook.Remove("HUDPaint", "horror022")
end[/CODE]
[QUOTE=ST3BL;50899807]sorry for this but
is it rude for my too to receive this
[editline]17th August 2016[/editline]
well I tested this but I don't know why no work ;(
[CODE]if CLIENT then
local function spawn( ply )
ply:SetNWBool("horror022", false);
ply:SetMaterial("");
end
hook.Add( "PlayerSpawn", "diehorror022", spawn )
hook.Remove("HUDPaint", "horror022")
end[/CODE][/QUOTE]
You don't want to hook.Remove the HUDPaint hook. That will stop it from ever rendering. Just set the NWBool to false.
Also, PlayerSpawn is a serverside hook, and serverside network variables can only be set serverside, so don't do the client check. Do a server check instead
thank you both it works perfectly now :)
very very thx :)
I kiss you
Sorry, you need to Log In to post a reply to this thread.