SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 22/05/2017, 05:44 PM   #1
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default INVALID_PLAYER_ID Help +REP

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
Ahmed21 is offline   Reply With Quote
Old 22/05/2017, 05:47 PM   #2
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 408
Reputation: 32
Default Re: INVALID_PLAYER_ID Help +REP

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?
Banditul18 is offline   Reply With Quote
Old 22/05/2017, 05:52 PM   #3
Ahmed21
Big Clucker
 
Join Date: Jul 2016
Posts: 158
Reputation: 3
Default Re: INVALID_PLAYER_ID Help +REP

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.
Ahmed21 is offline   Reply With Quote
Old 22/05/2017, 05:58 PM   #4
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: INVALID_PLAYER_ID Help +REP

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

__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 22/05/2017, 06:15 PM   #5
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 579
Reputation: 134
Default Re: INVALID_PLAYER_ID Help +REP

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

iLearner is offline   Reply With Quote
Old 22/05/2017, 07:50 PM   #6
YouHack
Banned
 
Join Date: Jan 2017
Posts: 293
Reputation: 28
Default Re: INVALID_PLAYER_ID Help +REP

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.
YouHack is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
EnablePlayerCameraTarget INVALID_PLAYER_ID Mic_H Scripting Help 3 01/06/2015 01:31 PM
How does INVALID_PLAYER_ID actually work? Puppy Scripting Help 14 28/01/2015 10:17 PM
INVALID_PLAYER_ID never works... Twisted_Insane Scripting Help 6 22/03/2012 10:36 PM
INVALID_PLAYER_ID russiany Help Archive 13 24/05/2009 09:32 AM


All times are GMT. The time now is 09:11 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.