SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/06/2017, 05:48 PM   #21
FaLLenGirL
Huge Clucker
 
FaLLenGirL's Avatar
 
Join Date: Jan 2016
Location: Romania
Posts: 200
Reputation: 34
Default Re: givehp gethp?

PHP Code:
pInfoplayerid ][ pHealth 
Do you reset this at OnPlayerConnect and Disconect?
__________________
FaLLenGirL is offline   Reply With Quote
Old 12/06/2017, 05:49 PM   #22
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,140
Reputation: 445
Default Re: givehp gethp?

Quote:
Originally Posted by Crystallize View Post
stock GetHealth( playerid, Floathp ) return pInfo[ playerid ][ pHealth ] = xhp;
stock GiveHealth( playerid, Floathp ) return pInfo[ playerid ][ pHealth ] += xhp;
I'm not getting your code logic, there's no reason to have = xhp when you're simply returning the already set value. Should be something such as this:
pawn Code:
Float: GetHealth(playerid) return pInfo[playerid][pHealth];
GiveHealth(playerid, Float: xhp)
{
       pInfo[playerid][pHealth] += xhp;
       return 1;
}

You should also try using pickups or something else other than a timer for the healing, this method is inefficient and will decrease server performance as more players connect.

Last edited by Abagail; 12/06/2017 at 06:34 PM.
Abagail is offline   Reply With Quote
Old 12/06/2017, 06:03 PM   #23
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,504
Reputation: 314
Default Re: givehp gethp?

Quote:
Originally Posted by Abagail View Post
I'm not getting your code logic, there's no reason to have = xhp when you're simply returning the already set value. Should be something such as this:
pawn Code:
Float: GetHealth(playerid, Float: xhp) return pInfo[playerid][pHealth];
GiveHealth(playerid, Float: xhp)
{
       pInfo[playerid][pHealth] += xhp;
       return 1;
}

You should also try using pickups or something else other than a timer for the healing, this method is inefficient and will decrease server performance as more players connect.
warning 213: tag mismatch
warning 208: function with tag result used before definition, forcing reparse
on
Code:
Float: GetHealth(playerid, Float: xhp) return pInfo[playerid][pHealth];
Crystallize is offline   Reply With Quote
Old 12/06/2017, 06:05 PM   #24
Whatname
Big Clucker
 
Join Date: Aug 2016
Posts: 178
Reputation: 12
Default Re: givehp gethp?

PHP Code:
FloatGetHealth(playerid) return pInfo[playerid][pHealth]; 
Whatname is offline   Reply With Quote
Old 12/06/2017, 06:10 PM   #25
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,504
Reputation: 314
Default Re: givehp gethp?

Quote:
Originally Posted by Whatname View Post
PHP Code:
FloatGetHealth(playerid) return pInfo[playerid][pHealth]; 
Code:
C:\Users\xc0de\Desktop\tst\gamemodes\zm1.pwn(2793) : warning 213: tag mismatch
C:\Users\xc0de\Desktop\tst\gamemodes\zm1.pwn(2805) : warning 202: number of arguments does not match definition
Crystallize is offline   Reply With Quote
Old 12/06/2017, 06:11 PM   #26
Whatname
Big Clucker
 
Join Date: Aug 2016
Posts: 178
Reputation: 12
Default Re: givehp gethp?

Use GetHealth(playerid);
Whatname is offline   Reply With Quote
Old 12/06/2017, 06:12 PM   #27
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,504
Reputation: 314
Default Re: givehp gethp?

Quote:
Originally Posted by Whatname View Post
Use GetHealth(
warning 202: number of arguments does not match definition
throws this error ...
GetHealth( i, hp );
Crystallize is offline   Reply With Quote
Old 12/06/2017, 06:15 PM   #28
Whatname
Big Clucker
 
Join Date: Aug 2016
Posts: 178
Reputation: 12
Default Re: givehp gethp?

Quote:
Originally Posted by Crystallize View Post
warning 202: number of arguments does not match definition
throws this error ...
GetHealth( i, hp );
PHP Code:
hp GetHealth(i); //without hp 
Whatname is offline   Reply With Quote
Old 12/06/2017, 06:17 PM   #29
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,504
Reputation: 314
Default Re: givehp gethp?

Quote:
Originally Posted by Whatname View Post
PHP Code:
hp GetHealth(i); //without hp 
Finally, thanks a lot
Crystallize is offline   Reply With Quote
Old 12/06/2017, 06:18 PM   #30
Whatname
Big Clucker
 
Join Date: Aug 2016
Posts: 178
Reputation: 12
Default Re: givehp gethp?

Yw
Whatname 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
/gethp DerickClark Scripting Help 14 07/03/2013 03:28 AM
/gethp DerickClark Scripting Help 9 05/03/2013 10:16 PM
My own /givehp playerid health Guitar Scripting Help 4 21/08/2012 04:42 PM
[Tutorial] Basic Commands 1 (ZCMD)- /explode, /gethp SKAzini Tutorials 0 19/08/2012 06:27 PM


All times are GMT. The time now is 05:43 AM.


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