Raised This Month: $51 Target: $400
 12% 

Solved if(!is_user_alive(id))


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shadow728988
Member
Join Date: Sep 2017
Old 05-25-2018 , 01:44   if(!is_user_alive(id))
Reply With Quote #1

Hey, i tried making this plugin that shows a hud message after a player is dead just to him but its not working.
Code:
public hudmsg(id)
{

  if(!is_user_alive(id))
    {
       set_task(1.0, "ShowHud", id) 
    }
}

public ShowHud(id) 
{  
    set_dhudmessage(0, 255, 0, -1.0, -1.0, 0, 2.0, 6.0, 0.8, 0.8)
	show_dhudmessage(id,"Your Text here")
     
}
thank you for your help

Last edited by shadow728988; 05-26-2018 at 23:59. Reason: oops
shadow728988 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-25-2018 , 01:51   Re: if(!is_user_alive(id))
Reply With Quote #2

What part isn't working? Is hudmsg() being called? If so, how?

Did you try putting a simple client_print() in there also to see if the functions are getting called properly?

Also, you should check if the user is connected in ShowHud() before calling show_dhudmessage().
__________________
fysiks is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 05-25-2018 , 02:52   Re: if(!is_user_alive(id))
Reply With Quote #3

https://forums.alliedmods.net/showpo...22&postcount=7
__________________
CrAzY MaN is offline
shadow728988
Member
Join Date: Sep 2017
Old 05-25-2018 , 03:50   Re: if(!is_user_alive(id))
Reply With Quote #4

i tested it using a /test command for chat to see if working and it was..but not without it
shadow728988 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-25-2018 , 04:25   Re: if(!is_user_alive(id))
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
What part isn't working? Is hudmsg() being called? If so, how?

Did you try putting a simple client_print() in there also to see if the functions are getting called properly?

Also, you should check if the user is connected in ShowHud() before calling show_dhudmessage().
Answer this questions.
That's how you fix bugs, it's called DEBUGGING. There's no way to write working code without learning or wanting to debug your code.
__________________

Last edited by HamletEagle; 05-25-2018 at 04:26.
HamletEagle is offline
shadow728988
Member
Join Date: Sep 2017
Old 05-25-2018 , 08:53   Re: if(!is_user_alive(id))
Reply With Quote #6

ok now i see..hudmsg() was not being called sorry xD...i've made it like this
public client_putinserver(id)
{
set_task(1.0, "showMessage", id)
}
shadow728988 is offline
shadow728988
Member
Join Date: Sep 2017
Old 05-25-2018 , 09:55   Re: if(!is_user_alive(id))
Reply With Quote #7

the plugin is working perfectly now but can you help me so the player using a cmd like /off can switch it off..

Code:
public client_putinserver(id) 
{ 
    set_task(1.0, "showMessage", id, _, _, "b") 
} 

public showMessage(id) 
{ 
    if(!is_user_connected(id))
        return; 
         
     
    if(is_user_connected(id) && !is_user_alive(id)) 
    { 
        set_dhudmessage(178, 21, 236, -1.0, 0.20, 0, 1.0, 5.0, 0.1, 0.2) 
        show_dhudmessage(id, "NEW IPS HERE") 
    } 
         
}
thankyou crazyman and fysiks and hamlet eagle

Last edited by shadow728988; 05-25-2018 at 10:52. Reason: reasons
shadow728988 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 05-25-2018 , 10:30   Re: if(!is_user_alive(id))
Reply With Quote #8

Maybe...

PHP Code:
new VarMessage

public plugin_init()
{
    
VarMessage register_cvar ("amx_show_message""1")
}

public 
client_putinserver(id
{
    if(
get_pcvar_num(VarMessage)
        
set_task(1.0"showMessage"id__"b"
        
    return 
PLUGIN_HANDLED


public 
showMessage(id

    if(
is_user_connected(id) && !is_user_alive(id))  
    { 
        
set_dhudmessage(17821236, -1.00.2001.05.00.10.2
        
show_dhudmessage(id"NEW IPS HERE"
    }
    return;     


Last edited by iceeedr; 05-26-2018 at 00:57. Reason: Thanks for correct me.
iceeedr is offline
Send a message via Skype™ to iceeedr
shadow728988
Member
Join Date: Sep 2017
Old 05-25-2018 , 10:51   Re: if(!is_user_alive(id))
Reply With Quote #9

by toggle i mean for the player indivisually...sorry for not being clear

Last edited by shadow728988; 05-25-2018 at 10:53. Reason: i am bad at this
shadow728988 is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 05-25-2018 , 13:01   Re: if(!is_user_alive(id))
Reply With Quote #10

Quote:
Originally Posted by shadow728988 View Post
by toggle i mean for the player indivisually...sorry for not being clear
Explain your idea better, I could not understand ...
iceeedr is offline
Send a message via Skype™ to iceeedr
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode