• Gmod quadro aberto quando o jogador morre
    2 replies, posted
[CODE] function ADS(victim, attacker, DFrame) if victim != attacker and victim:IsPlayer() then local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Advisement" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( false ) Frame:MakePopup() local html = vgui.Create( "HTML", frame ) html:Dock( FILL ) html:OpenURL( "wiki.garrysmod.com" ) timer.Simple( 10, function() Frame:Close() end ) end elseif victim == attacker and victim:IsPlayer() then local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Advisement" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( false ) Frame:MakePopup() local html = vgui.Create( "HTML", frame ) html:Dock( FILL ) html:OpenURL( "wiki.garrysmod.com" ) timer.Simple( 10, function() Frame:Close() end ) end hook.Add( "PlayerDeath", "DFrame", ADS ) [/CODE] [B]I'm trying to make this code. When the player dies, open a frame that is an html page (if the player killed by another player or even killed)[/B] but i don't have idea for why don't work. help [url]https://wiki.garrysmod.com/page/GM/PlayerDeath[/url] [url]https://wiki.garrysmod.com/page/Derma_Basic_Guide[/url] [url]https://wiki.garrysmod.com/page/Panel/OpenURL[/url]
Look at the pages you linked. PlayerDeath is a serverside hook. You should either network the client's death to them or use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/gameevent/Listen]gameevent.Listen[/url] and make an entity_killed hook.
I added some indentation and comments to show some of the other problems with your code [lua]function ADS(victim, attacker, DFrame) --the inflictor is the second argument of playerdeath, attacker is the third if victim != attacker and victim:IsPlayer() then local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Advisement" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( false ) Frame:MakePopup() local html = vgui.Create( "HTML", frame ) --frame doesn't exist, lua is case sensitive html:Dock( FILL ) html:OpenURL( "wiki.garrysmod.com" ) timer.Simple( 10, function() Frame:Close() end ) end --elseif for an if statement that already ended --unnecessary, just remove the "victim != attacker" part in the first if statement elseif victim == attacker and victim:IsPlayer() then local Frame = vgui.Create( "DFrame" ) Frame:SetPos( 5, 5 ) Frame:SetSize( 300, 150 ) Frame:SetTitle( "Advisement" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( false ) Frame:MakePopup() local html = vgui.Create( "HTML", frame ) html:Dock( FILL ) html:OpenURL( "wiki.garrysmod.com" ) timer.Simple( 10, function() Frame:Close() end ) end --the function has no end hook.Add( "PlayerDeath", "DFrame", ADS ) --as txike already pointed out, playerdeath is serverside[/lua] Also, if you're trying to play an advertisement whenever a player dies, please don't.
Sorry, you need to Log In to post a reply to this thread.