client-side script

Hi,

I create a client-side script for players to see images but when the player dies the image remains on the screen.


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

how to stop these images when respawn

thx for your help

best regard



if not LocalPlayer():Alive() then -- not sure if you want them dead or alive but you choose
-- draw stuff
end


thx for your help

I tested this but no work I see flash pic :confused:

and this

Didn’t you just mixed up LocalPlayer():Alive and LocalPlayer():GetNWBook(“horror022”) ? 5th line of your second quote.

yes

it’s posible this ?

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 :confused:

This was already said but what I meant was:



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


[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.



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


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

[editline]15th August 2016[/editline]

Pls help my script work great

I want just remove HudPaint when player die :confused:

you’ll see them flash because they’re changing every single frame, right?

right and when player respawn is finish

I can use fonction Player:Deaths() for close my local function horror022() when player die and respawn?


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

Smallup pls help me :confused:

Of course when you spawn you see the picture, if you want it to only show when you’re dead then just change



if LocalPlayer():Alive() then


To



if not LocalPlayer():Alive() then


[editline]16th August 2016[/editline]

So it’d be



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)


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



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)


well sorry you have confused

my script work great player die and see pics


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

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

[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

…………………,-‘´ … _,’;:-,……………….
…………………,-(c\ ;-=´,_,-~-, ……………
………………,/ …¯’, º ,/.’-~°,’ .¯’-,…………. ………………/ … …¯,_ ~–~’,, …’.……… ……………..| … … . . ¯¨¨¨(̅_̅_̅_̅((_̅_̲̅м̲̅a̲̅я̲̅i̲̅j̲̅u̲̅a̲̅n̲̅_̅_ ̅_̅() ڪے ……………..| … … . , … .’-, … |……….
……………./\ … … .“-,-’~-~’ … ’|……….
………….,/’\,’-, … … … … . . /.………
░█▀▄░█░█░█▀█░░█▀▀░▀█▀░█▀▀░█▀█░
░█░█░█░█░█▀▀█░▀▀█░░█░░█▀▀░█▀▀░
░▀▀░░▀▀▀░▀▀▀▀░▀▀▀░░▀░░▀▀▀░▀░░░


(User was banned for this post ("Shit posting again." - postal))

wtf you have a problem to the head ?