AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved if(!is_user_alive(id)) (https://forums.alliedmods.net/showthread.php?t=307789)

shadow728988 05-25-2018 01:44

if(!is_user_alive(id))
 
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

fysiks 05-25-2018 01:51

Re: if(!is_user_alive(id))
 
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().

CrAzY MaN 05-25-2018 02:52

Re: if(!is_user_alive(id))
 
https://forums.alliedmods.net/showpo...22&postcount=7

shadow728988 05-25-2018 03:50

Re: if(!is_user_alive(id))
 
i tested it using a /test command for chat to see if working and it was..but not without it

HamletEagle 05-25-2018 04:25

Re: if(!is_user_alive(id))
 
Quote:

Originally Posted by fysiks (Post 2593739)
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.

shadow728988 05-25-2018 08:53

Re: if(!is_user_alive(id))
 
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 05-25-2018 09:55

Re: if(!is_user_alive(id))
 
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

iceeedr 05-25-2018 10:30

Re: if(!is_user_alive(id))
 
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;     



shadow728988 05-25-2018 10:51

Re: if(!is_user_alive(id))
 
by toggle i mean for the player indivisually...sorry for not being clear

iceeedr 05-25-2018 13:01

Re: if(!is_user_alive(id))
 
Quote:

Originally Posted by shadow728988 (Post 2593812)
by toggle i mean for the player indivisually...sorry for not being clear

Explain your idea better, I could not understand ...


All times are GMT -4. The time now is 04:40.

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