Raised This Month: $ Target: $400
 0% 

If player is alive, it means, that he is connected to server?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 01-11-2015 , 09:00   If player is alive, it means, that he is connected to server?
Reply With Quote #1

Hello, I found this, and now I wonder, if player is not alive, it means, that he is connected to server or not?
@edit - wrong named topic - I meant IS NOT ALIVE, not ALIVE
PHP Code:
static cell AMX_NATIVE_CALL is_user_connected(AMX *amxcell *params/* 1 param */
{
    
int index params[1];
    
    if (
index || index gpGlobals->maxClients)
        return 
0;
    
    
CPlayerpPlayer GET_PLAYER_POINTER_I(index);
    
    return(
pPlayer->ingame 0);
}

extern bool g_bmod_tfc;
static 
cell AMX_NATIVE_CALL is_user_alive(AMX *amxcell *params/* 1 param */
{
    
int index params[1];
    
    if (
index || index gpGlobals->maxClients)
    {
        return 
0;
    }
    
    
CPlayerpPlayer GET_PLAYER_POINTER_I(index);

    if (
g_bmod_tfc)
    {
        
edict_t *pPlayer->pEdict;
        if (
e->v.flags FL_SPECTATOR || 
            (!
e->v.team || !e->v.playerclass))
        {
            return 
0;
        }
    }
    
    return((
pPlayer->ingame && pPlayer->IsAlive()) ? 0);


Last edited by danonix; 01-11-2015 at 09:02.
danonix is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 01-11-2015 , 09:07   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #2

Player still connecting to the server.
zmd94 is offline
danonix
Senior Member
Join Date: Dec 2012
Old 01-11-2015 , 09:11   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #3

Quote:
Originally Posted by zmd94 View Post
Player still connecting to the server.
So player which is not alive is connected to server? I am right?

Last edited by danonix; 01-11-2015 at 09:14.
danonix is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 01-11-2015 , 09:15   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #4

if player is not alive you have to check is_user_connected to find out if he is in the server

is_user_alive returns true if player is alive and false when player is not alive or not connected to the server
jimaway is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-11-2015 , 09:18   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #5

If a player is alive how he could not be connected to server ? So:
1. is_user_alive check if player is connected and if player is alive.
2. is_user_connected checks only if player is connected, it can be alive or dead.
3. checking just is_user_alive to know if player is connected or not is not accurate, because it can be dead but still connected(like he was killed during the round and wait for respawn).
__________________

Last edited by HamletEagle; 01-11-2015 at 09:18.
HamletEagle is offline
danonix
Senior Member
Join Date: Dec 2012
Old 01-11-2015 , 09:22   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
If a player is alive how he could not be connected to server ? So:
1. is_user_alive check if player is connected and if player is alive.
2. is_user_connected checks only if player is connected, it can be alive or dead.
3. checking just is_user_alive to know if player is connected or not is not accurate, because it can be dead but still connected(like he was killed during the round and wait for respawn).
Well, I know that if is player alive, he must be connected to server, but though, that if player is not alive, it still means that he is connected to server because of this piece of code
Code:
 return((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);
But still - player in game ( returns 1 ) && player is alive( returns 1) - player alive - returns 1
player in game ( returns 1 ) && player is not alive ( returns 0 ) function returns 0
player in game ( returns 0 ) && player is not alive ( returns 0 ) function returns 0

So, if player is not alive i have to check, that if he is connected to server.
danonix is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-11-2015 , 10:06   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #7

Yes, if not alive then you need to check if he is connected, but this depend on the context.
__________________
HamletEagle is offline
danonix
Senior Member
Join Date: Dec 2012
Old 01-11-2015 , 11:25   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
Yes, if not alive then you need to check if he is connected, but this depend on the context.
Could you explain?
danonix is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 01-11-2015 , 10:29   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #9

very interesting question
the conclusion is that if is_user_alive returns 0 it does not necessarily mean he's connected to the server
you can go ahead and continue a function if(is_user_alive)
but in the else{ you'll have to do an is_user_connected check}

by means of optimization, theoretically , this is the best way, other than first checking if he's connected or not and then the alive or not
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 01-11-2015 , 11:38   Re: If player is alive, it means, that he is connected to server?
Reply With Quote #10

It is better if you tell what you want to do. Then, it is more easier for us to help you.

Last edited by zmd94; 01-11-2015 at 11:38.
zmd94 is offline
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 15:19.


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