The Next Generation Gamers

The Next Generation Gamers

The Next Generation Gamers Community
 
HomePortalCalendarGalleryFAQSearchMemberlistUsergroupsRegisterLog in

Share
 

 SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)

Go down 
AuthorMessage
Deaglez
TNG Designer
Deaglez

Posts : 231
Points : 295
Join date : 2012-10-01
Age : 19
Location : Malaysia

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeSat Nov 03, 2012 3:42 am

In this tutorial, I will show you how to heal player with the TEAM MEDIC. So lets get started.

First, you need this three include added on top of your script:

Code:
#include <a_samp>
#include <zcmd>
#include<sscanf2>




Code:
#include <zcmd>

This include is a simple fast command proccessor. You can download and watch the tutorial here.



Code:
#include <sscanf2>

This include is simple to use. It will target the player id that you want to heal. You can download and watch the tutorial here



OK, now. Go to the bottom of your script and add this:

Code:
CMD:heal(playerid, params[])

This one is based on the ZCMD. You see? Looks very easy to use this.


Next, add two brackets under the command function and it should be look like this:

Code:
CMD:heal(playerid, params[])
{

}


Then, add all of this and it should be looked like this:

Code:
CMD:heal(playerid, params[])
{
    if(gTeam[playerid] == TEAM_MEDIC)
    {
    new id; // this one is the target id variable
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "Usage: /heal [id]");
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "The player you are trying to heal is not connected"); // If the player id is not connected, showing the message.
    SetPlayerHealth(id, 100);
    SendClientMessage(playerid, -1, "You have successfully healed the targeted player");
    GameTextForPlayer(id, "~r~Healed", 3000, 0);
    }
    return 1;
}



Once you do that, you're done. Look? How easy was that!


CREDITS:
Me - Scriptor
ZCMD - Simple CMD
SSCANF

_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Zivw8AP

"Frightness is weak"

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) ZJKHPlF Troll

|| STARS Member || SA-MP Big Clucker || Photoshop Professional || Ex-STARS Corporal ||
Back to top Go down
View user profile
Prophet
S.T.A.R.S
Prophet

Posts : 553
Points : 682
Join date : 2012-10-03
Age : 22
Location : Classified

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeSat Nov 03, 2012 11:26 am

How can you make it so the HP will be +30 ? would it look like this?

CMD:heal(playerid, params[])
{
if(gTeam[playerid] == TEAM_MEDIC)
{
new id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1, "Usage: /heal [id]");
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "The player you are trying to heal is not connected");
SetPlayerHealth(id, +30); //<-------------------------------------------
SendClientMessage(playerid, -1, "You have successfully healed the targeted player");
GameTextForPlayer(id, "~r~Healed", 3000, 0);
}
return 1;
}

_________________

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) CIO5r1U
--------------------------------------------------------------
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 2iqzdle
||U.C RANK 1||TNG HEAD MAPPER||PROFESSIONAL LAGSHOOTER||TOP 3 MOST EXP||
||EX TNG MODERATOR||EX S.T.A.R.S MEMBER||EX PROTOTYPE MEMBER||
Back to top Go down
View user profile
Deaglez
TNG Designer
Deaglez

Posts : 231
Points : 295
Join date : 2012-10-01
Age : 19
Location : Malaysia

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeSat Nov 03, 2012 12:38 pm

Nope. Just do it like this

Code:
SetPlayerHealth(id, GetPlayerHealth(id) +30); // make the health +30



You may also do more kind of stuff with this. Example

Code:
SetPlayerArmour(id, GetPlayerArmour(id) +30); //Will make the armour +30

Hope it helps ya Smile


_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Zivw8AP

"Frightness is weak"

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) ZJKHPlF Troll

|| STARS Member || SA-MP Big Clucker || Photoshop Professional || Ex-STARS Corporal ||
Back to top Go down
View user profile
Prophet
S.T.A.R.S
Prophet

Posts : 553
Points : 682
Join date : 2012-10-03
Age : 22
Location : Classified

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeSat Nov 03, 2012 12:47 pm

thanks!

_________________

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) CIO5r1U
--------------------------------------------------------------
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 2iqzdle
||U.C RANK 1||TNG HEAD MAPPER||PROFESSIONAL LAGSHOOTER||TOP 3 MOST EXP||
||EX TNG MODERATOR||EX S.T.A.R.S MEMBER||EX PROTOTYPE MEMBER||
Back to top Go down
View user profile
BigETI
Community Developer


Posts : 214
Points : 252
Join date : 2012-10-01

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeSat Nov 03, 2012 2:38 pm

GetPlayerHealth doesn't return the health of the player.
http://wiki.sa-mp.com/wiki/GetPlayerHealth
Same belongs to GetPlayerArmour aswell!
http://wiki.sa-mp.com/wiki/GetPlayerArmour

Requires a_samp

This is how to heal somebody if there is a health limit set (Do not think this is a copy from any of my game modes since the code below is not anti cheat friendly!)
Code:
#define MAX_HEALTH (80.0) //Some definition
// Let say the max health of a player shall be set to 80 health points.
//...
//At some callback which gives us the ability to use the player ID (playerid)
new Float:pHp; //This is the variable where we will store the current health of the player.
GetPlayerHealth(playerid, pHp); //Gets player health
SetPlayerHealth(playerid, ((pHp+5.0) > MAX_HEALTH) ? MAX_HEALTH : (pHp+5.0)); //Sets player health
//...

*sigh*
Code:
SetPlayerTrueHealth(playerid, AC_Info[playerid][AC_Health]+(MAX_H_HEALTH*0.2) > MAX_HEALTH ? MAX_H_HEALTH : AC_Info[playerid][AC_Health]+(MAX_H_HEALTH*0.2));
...

_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) BigETI_Signatur_zpsbf609e3d
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Mca

Titros - A Tetris Clone on Indie DB
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 22400
http://www.indiedb.com/games/titros-a-tetris-clone
Back to top Go down
View user profile
ERROR
Professional Survivor
Professional Survivor
ERROR

Posts : 297
Points : 388
Join date : 2012-10-05
Location : ERROR

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: =)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeWed Nov 07, 2012 7:35 pm

i already knew all that stuff since i am a scripter,but this is REALY REALY good for people who dont know how to ,but want to do it,you made an awsome tut. there,also,big etis advice was good aswell

_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 260ehc0


||Low time scripter+designer|| ||Professional survivor|| ||Zombie slayer|| ||Movie uploader||
__________________________________________________________________________________________________________________________________________________________________________________________
Q:What does Nemesis say when hes hungry?
A:STARS!!
Back to top Go down
View user profile
ERROR
Professional Survivor
Professional Survivor
ERROR

Posts : 297
Points : 388
Join date : 2012-10-05
Location : ERROR

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeWed Nov 07, 2012 7:37 pm

i must say,deaglez is a good designer and at scripting,and this will help many people,try to make more of these

_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 260ehc0


||Low time scripter+designer|| ||Professional survivor|| ||Zombie slayer|| ||Movie uploader||
__________________________________________________________________________________________________________________________________________________________________________________________
Q:What does Nemesis say when hes hungry?
A:STARS!!
Back to top Go down
View user profile
Prophet
S.T.A.R.S
Prophet

Posts : 553
Points : 682
Join date : 2012-10-03
Age : 22
Location : Classified

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeWed Nov 07, 2012 7:37 pm

I agree with wesker and please close this.

btw wesker please dont bump older topics.

_________________

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) CIO5r1U
--------------------------------------------------------------
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 2iqzdle
||U.C RANK 1||TNG HEAD MAPPER||PROFESSIONAL LAGSHOOTER||TOP 3 MOST EXP||
||EX TNG MODERATOR||EX S.T.A.R.S MEMBER||EX PROTOTYPE MEMBER||
Back to top Go down
View user profile
ERROR
Professional Survivor
Professional Survivor
ERROR

Posts : 297
Points : 388
Join date : 2012-10-05
Location : ERROR

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeWed Nov 07, 2012 10:34 pm

XD,i bumped it since it wasnt closed,and from when are you acting like an admin

_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 260ehc0


||Low time scripter+designer|| ||Professional survivor|| ||Zombie slayer|| ||Movie uploader||
__________________________________________________________________________________________________________________________________________________________________________________________
Q:What does Nemesis say when hes hungry?
A:STARS!!
Back to top Go down
View user profile
Prophet
S.T.A.R.S
Prophet

Posts : 553
Points : 682
Join date : 2012-10-03
Age : 22
Location : Classified

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeThu Nov 08, 2012 9:42 am

Because i am one lol but not on OSF

_________________

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) CIO5r1U
--------------------------------------------------------------
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 2iqzdle
||U.C RANK 1||TNG HEAD MAPPER||PROFESSIONAL LAGSHOOTER||TOP 3 MOST EXP||
||EX TNG MODERATOR||EX S.T.A.R.S MEMBER||EX PROTOTYPE MEMBER||
Back to top Go down
View user profile
ERROR
Professional Survivor
Professional Survivor
ERROR

Posts : 297
Points : 388
Join date : 2012-10-05
Location : ERROR

SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitimeThu Nov 08, 2012 6:29 pm

i am an admin too but not on osf either,or any TNG/UG server

_________________
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) 260ehc0


||Low time scripter+designer|| ||Professional survivor|| ||Zombie slayer|| ||Movie uploader||
__________________________________________________________________________________________________________________________________________________________________________________________
Q:What does Nemesis say when hes hungry?
A:STARS!!
Back to top Go down
View user profile
Sponsored content




SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) Empty
PostSubject: Re: SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)   SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf) I_icon_minitime

Back to top Go down
 
SA-MP Script Tutorial - Making a /heal [id] (a_samp, zcmd,sscanf)
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
The Next Generation Gamers-
Jump to: