INVALID_PLAYER_ID Help +REP
#1

Hello there,

I've made one simple IF statement on OnPlayerTakeDamage callback.

The if statement is supposed to check if the issuerid (Who made the damage) is valid.

PHP Code:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID) return 0// If issuerid is valid ID then it returns 0;
    
     
new string[128];
    
format(stringsizeof(string), "Damager: %d || Damaged: %d || bodypart: %d"issueridplayeridbodypart);
    
SCM(playerid, -1string);
    return 
1;

I've checked it many times, and I'm pretty sure that the code is correct.

Please, tell me what is the problem in this
Reply
#2

if(issuerid != INVALID_PLAYER_ID) return 0; // If issuerid is valid ID then it returns 0;

if(issuerid == INVALID_PLAYER_ID) return 0; // If issuerid is valid ID then it returns 0;

You want to check if is valid, and if is return 0? Or to check is invalid to return 0?
Reply
#3

Quote:
Originally Posted by Banditul18
View Post
if(issuerid != INVALID_PLAYER_ID) return 0; // If issuerid is valid ID then it returns 0;

if(issuerid == INVALID_PLAYER_ID) return 0; // If issuerid is valid ID then it returns 0;

You want to check if is valid, and if is return 0? Or to check is invalid to return 0?
I want to check if someone has damaged playerid, if someone damaged him then return 0. It sounds weird for some people but that's what I want to make.
Reply
#4

I guess that should work :
PHP Code:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart

    if(
IsPlayerConnected(issuerid))
        return 
0// If issuerid is valid ID then it returns 0; 
     
    
new string[128]; 
    
format(stringsizeof(string), "Damager: %d || Damaged: %d || bodypart: %d"issueridplayeridbodypart); 
    
SCM(playerid, -1string); 
    return 
1

Reply
#5

PHP Code:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart

    if(
issuerid == INVALID_PLAYER_ID) return 0// If issuerid is valid ID then it returns 0; 
     
     
new string[128]; 
    
format(stringsizeof(string), "Damager: %d || Damaged: %d || bodypart: %d"issueridplayeridbodypart); 
    
SCM(playerid, -1string); 
    return 
1

Reply
#6

if(issuerid == INVALID_PLAYER_ID) return 0;
This checks if issuerid is invalid, if yes, it returns 0. but in your code it returns 0 if the issuer's valid. so it'll return 0 mostly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)