Healup
#1

Trying to make a command where if the victim his health is >40 it sets it to 60 but its not working.
What am I doing wrong?
Thanks in advance.

PHP код:
CMD:healup(playeridparams[])
{
    new 
victimhealth;
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(victimXYZ);
    if(
PlayerInfo[playerid][pFaction] != 3) return SCM(playeridCOLOR_LIGHTRED"You are not a police officer.");
    if(
sscanf(params"ud"victim)) return SendClientMessage(playeridCOLOR_GREY"/healup (id)");
    if(
victim == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_LIGHTRED"That player is not connected.");
     if (
GetDistanceBetweenPlayers(playerid,victim) < 5)
    {
    
GetPlayerHealth(victimhealth);
    if (
health 40)
     
SetPlayerHealth(victim60);
    }
    else return 
SCM(playeridCOLOR_LIGHTRED"You're not close to that player.");
      return 
1;

Reply
#2

sscanf to check if he put an victim id should be ontop ur making it get the victim location while victim which is player id is 0 so that's how it should work
Код:
CMD:healup(playerid,*params[])
{
****new*victim,*health;
	if(sscanf(params,*"ud",*victim))*return*SendClientMessage(playerid,*COLOR_GREY,*"/healup*(id)");
	if(PlayerInfo[playerid][pFaction]*!=*3)*return*SCM(playerid,*COLOR_LIGHTRED,*"You*are*not*a*police*officer.");
****if(victim*==*INVALID_PLAYER_ID)*return*SendClientMessage(playerid,*COLOR_LIGHTRED,*"That*player*is*not*connected.");
****new*Float:X,*Float:Y,*Float:Z;
****GetPlayerPos(victim,*X,*Y,*Z);
****if*(GetDistanceBetweenPlayers(playerid,victim)*<*5)
****{
****	GetPlayerHealth(victim,*health);
****	if*(health*<*40)
*****	SetPlayerHealth(victim,*60);
****}
****else*return*SCM(playerid,*COLOR_LIGHTRED,*"You're*not*close*to*that*player.");
****return*1;
}*
ur welcome
Reply
#3

forget about the *** idk why it is like this just put the sscanf and the playerinfo above the GetPlayerPos(victim and it should work
Reply
#4

The upper guy is still wrong by the way. Try this one
Код:
CMD:healup(playerid, params[])
{
    new victim,Float:health;
    if(PlayerInfo[playerid][pFaction] != 3) return SCM(playerid, COLOR_LIGHTRED, "You are not a police officer.");
    if(sscanf(params, "u", victim)) return SendClientMessage(playerid, COLOR_GREY, "/healup (id)");
    if(victim == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_LIGHTRED, "That player is not connected.");

     if (GetDistanceBetweenPlayers(playerid,victim) < 5)
    {
    GetPlayerHealth(victim, health);
    if (health < 40)
     SetPlayerHealth(victim, 60);
    }
    else return SCM(playerid, COLOR_LIGHTRED, "You're not close to that player.");
      return 1;
}
The problem was that you were using wrong sscanf parameters, " u " is for getting player id , but you also have " d " which is for a number, but because you don't need it so i removed, and the second problem was that health should've to be a float, and you were using Float, y , z for no reason, now it'll works fine..
Reply
#5

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
The upper guy is still wrong by the way. Try this one
Код:
CMD:healup(playerid, params[])
{
    new victim,Float:health;
    if(PlayerInfo[playerid][pFaction] != 3) return SCM(playerid, COLOR_LIGHTRED, "You are not a police officer.");
    if(sscanf(params, "u", victim)) return SendClientMessage(playerid, COLOR_GREY, "/healup (id)");
    if(victim == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_LIGHTRED, "That player is not connected.");

     if (GetDistanceBetweenPlayers(playerid,victim) < 5)
    {
    GetPlayerHealth(victim, health);
    if (health < 40)
     SetPlayerHealth(victim, 60);
    }
    else return SCM(playerid, COLOR_LIGHTRED, "You're not close to that player.");
      return 1;
}
The problem was that you were using wrong sscanf parameters, " u " is for getting player id , but you also have " d " which is for a number, but because you don't need it so i removed, and the second problem was that health should've to be a float, and you were using Float, y , z for no reason, now it'll works fine..
Thank-a-YOU. Works perfect now +Rep'd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)