Raised This Month: $ Target: $400
 0% 

[HELP] alive vs. dead (is_user_alive)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-08-2013 , 18:10   Re: [HELP] alive vs. dead (is_user_alive)
Reply With Quote #3

Quote:
Originally Posted by n0br41ner View Post
PHP Code:
// This code is written by me to show you what is the best way (i hope) to do what you want to do.
#include < amxmodx >

public plugin_init( ) {
    
register_plugin"Alive Checker""0.1""n0br41ner" );
    
    
register_clcmd"say /check""ClCmd_AliveCheck" );
}

public 
ClCmd_AliveCheckiPlayerID ) {
    if( 
is_user_aliveiPlayerID ) ) {
        
client_printiPlayerIDprint_chat"You are alive!" );
    } else {
        
client_printiPlayerIDprint_chat"You are not alive!" );
    }

-----------------

1. You do not need "engine" so no need to include it.
2. In this case its not "register_event" but rather "register_clcmd", since the "say /check" is a command that user is issuing and not an event. (An event would be like "DeathMsg" a.k.a. when someone dies)
NOTE: you can also use "register_concmd" but in this case its easier to use "register_clcmd"
3. In the arguments of "CheckerAlive", you are NOT obliged to put "id", you can name it whatever you want, in this case you want to name it "user" so the word "user" is good by it self.
4. When using if/else structure means that if the condition stated is not met do everything inside "else", but if the condition is met then do everything inside "if" (when i say inside i mean the body). In this case you are saying that IF user is alive do
PHP Code:
client_print(user,print_chat,"[AMXX] You'r alive!"); 
BUT if he is not alive do
PHP Code:
 client_print(user,print_chat,"[AMXX] You'r dead!"); 
, so you do not need the extra check, therefore this
PHP Code:
if(!is_user_alive(user)) 
is not needed.

So,
PHP Code:
if (is_user_alive(user))
    {
        
client_print(user,print_chat,"[AMXX] You'r alive!");
        
//return;
    
}
    else if(!
is_user_alive(user))
    {
        
client_print(user,print_chat,"[AMXX] You'r dead!");

would better be ->

PHP Code:
if (is_user_alive(user))
    {
        
client_print(user,print_chat,"[AMXX] You'r alive!");
        
//return;
    
}
    else { 
// when we arrive here, that means the user is already dead (since he is not alive - previous check)
        
client_print(user,print_chat,"[AMXX] You'r dead!");

ohhhh, ok! Thank you so much! I will try to make it right now!, and I'll post it here If it works!
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
 



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 20:32.


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