Heal CMD
#1

Hey,

How would i make the heal command with a payout? because at the moment the player will receive 1k ever heal so this means if the player is 99% health the will still get 1000$ how can i edit this so that the player will receive say 10$ ?

This is the command i am using:

pawn Код:
CMD:heal(playerid,params[])
{
    new pID;
    if(gTeam[playerid] == Medic) return SendClientMessage(playerid,COLOR_RED,"You must be a medic to use this command");
    else if(sscanf(params, "u", pID)) SendClientMessage(playerid,COLOR_YELLOW,"Please use /heal [playerid]");
    else if(GetPlayerHealthEx(pID) == 100) SendError(playerid,"This player is already full health");
    else if(PlayerFromPlayer(playerid,pID,4)) SendClientMessage(playerid,COLOR_YELLOW,"%s is not close enough to heal");
    else if(!IsPlayerConnected(pID)) SendClientMessage(playerid,COLOR_YELLOW,"That player is not connected!");
    else if(pID == playerid) SendClientMessage(playerid,COLOR_YELLOW,"You cannot use this command to heal your self");
    else
    {
    SetPlayerHealth(pID,100);
    GivePlayerMoney(playerid,1000);
    GivePlayerMoney(pID,-1000);
    SendClientMessageFormatted(playerid,COLOR_YELLOW,"You have healed %s", ReturnPlayerName(pID),pID);
    SendClientMessageFormatted(pID,COLOR_YELLOW,"You have been healed by %s for $1000", ReturnPlayerName(playerid),playerid);
    }
    return 1;
}
Reply
#2

You want that the person get paid for each 1% health? So:
1% = 10$
10% = 100$
and go on.

?
Reply
#3

use https://sampwiki.blast.hk/wiki/GetPlayerHealth
lets say you store the health in the variable x.
the player has 95 heal, so (x is a float...) x = 95.
the prize for healed 100 health is 1000$ so, for 1 hp it's 10$
now you do:
new prize = (100-floatround(x))*10);
we need to floatround so we don't get a float value, but a value with no dots.
Reply
#4

pawn Код:
new Float:health;
GetPlayerHealth(playerid,health);
SetPlayerHealth(pID,100);
GivePlayerMoney(playerid,(100-floatround(health))*10);
GivePlayerMoney(pID,-((100-floatround(health))*10));
Reply
#5

2 warnings tag mismatch ?
Reply
#6

Quote:
Originally Posted by Michael[NBK]
Посмотреть сообщение
2 warnings tag mismatch ?
Code?
Reply
#7

pawn Код:
CMD:heal(playerid,params[])
{
    new pID;
    new Float:health;
    if(gTeam[playerid] == Medic) return SendClientMessage(playerid,COLOR_RED,"You must be a medic to use this command");
    else if(sscanf(params, "u", pID)) SendClientMessage(playerid,COLOR_YELLOW,"Please use /heal [playerid]");
    else if(GetPlayerHealthEx(pID) == 100) SendError(playerid,"This player is already full health");
    else if(PlayerFromPlayer(playerid,pID,4)) SendClientMessage(playerid,COLOR_YELLOW,"%s is not close enough to heal");
    else if(!IsPlayerConnected(pID)) SendClientMessage(playerid,COLOR_YELLOW,"That player is not connected!");
    else if(pID == playerid) SendClientMessage(playerid,COLOR_YELLOW,"You cannot use this command to heal your self");
    else
    {
    GetPlayerHealth(playerid,health);
    SetPlayerHealth(pID,100);
    GivePlayerMoney(playerid,(100-health)*10);
    GivePlayerMoney(pID,-((100-health)*10));
    SendClientMessageFormatted(playerid,COLOR_YELLOW,"You have healed %s", ReturnPlayerName(pID),pID);
    SendClientMessageFormatted(pID,COLOR_YELLOW,"You have been healed by %s", ReturnPlayerName(playerid),playerid);
    }
    return 1;
}
Код:
C:\Users\Admin\Desktop\SAMP\Midnight Drifts\pawno\MaddMikesCNR.pwn(145) : warning 213: tag mismatch
C:\Users\Admin\Desktop\SAMP\Midnight Drifts\pawno\MaddMikesCNR.pwn(146) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Reply
#8

Quote:
Originally Posted by Michael[NBK]
Посмотреть сообщение
pawn Код:
CMD:heal(playerid,params[])
{
    new pID;
    new Float:health;
    if(gTeam[playerid] == Medic) return SendClientMessage(playerid,COLOR_RED,"You must be a medic to use this command");
    else if(sscanf(params, "u", pID)) SendClientMessage(playerid,COLOR_YELLOW,"Please use /heal [playerid]");
    else if(GetPlayerHealthEx(pID) == 100) SendError(playerid,"This player is already full health");
    else if(PlayerFromPlayer(playerid,pID,4)) SendClientMessage(playerid,COLOR_YELLOW,"%s is not close enough to heal");
    else if(!IsPlayerConnected(pID)) SendClientMessage(playerid,COLOR_YELLOW,"That player is not connected!");
    else if(pID == playerid) SendClientMessage(playerid,COLOR_YELLOW,"You cannot use this command to heal your self");
    else
    {
    GetPlayerHealth(playerid,health);
    SetPlayerHealth(pID,100);
    GivePlayerMoney(playerid,(100-health)*10);
    GivePlayerMoney(pID,-((100-health)*10));
    SendClientMessageFormatted(playerid,COLOR_YELLOW,"You have healed %s", ReturnPlayerName(pID),pID);
    SendClientMessageFormatted(pID,COLOR_YELLOW,"You have been healed by %s", ReturnPlayerName(playerid),playerid);
    }
    return 1;
}
Код:
C:\Users\Admin\Desktop\SAMP\Midnight Drifts\pawno\MaddMikesCNR.pwn(145) : warning 213: tag mismatch
C:\Users\Admin\Desktop\SAMP\Midnight Drifts\pawno\MaddMikesCNR.pwn(146) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
It's:

Quote:
Originally Posted by =WoR=Varth
Посмотреть сообщение
pawn Код:
new Float:health;
GetPlayerHealth(playerid,health);
SetPlayerHealth(pID,100);
GivePlayerMoney(playerid,(100-floatround(health))*10);
GivePlayerMoney(pID,-((100-floatround(health))*10));
Reply
#9

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)