Cost cash according to lost health
#1

Hello there everyone,

Actually i'm trying to script that if a player purchases Health from any shop ingame, he should cost the money according to his lost health.
for example if player has 30% health and he need to refile 70% to full his health.
So it cost money of 70% health not the 100% health money.

Thank you in advance.
Reply
#2

Use GetPlayerHealth.
Reply
#3

And subtract the health from a 100 which would be x (100 - 70 = 30, x = 30)
Reply
#4

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
And subtract the health from a 100 which would be x (100 - 70 = 30, x = 30)
case 0:
{
new Float:Health, string[128];
GetPlayerHealth(playerid,Health);
new Health3 = 100 - GetPlayerHealth(playerid,Health);
if (GetPlayerMoney(playerid) < Health3*100) return SendScreenMessage(playerid, LOCALE_MESSAGE_CANNOTAFFORD);
TakePlayerCash(playerid, Health3*100);
SetPlayerHealth(playerid, Health3);
format(string,sizeof(string),"You have bought a %s First-Aid Kit and used it for $%d.",Health3,Health3*100);
SendClientMessage(playerid, COLOR_NOTIFY,string);
DisplayPlayerDialog(playerid, DIALOG_SHOP);
}

here is the code, can you setup the code for me please?
thank you
Reply
#5

PHP код:
case 0:
{
    new 
xFloat:Healthstring[128];
    
GetPlayerHealth(playeridHealth);
    
Health 100
    if(
GetPlayerMoney(playerid) < x) return SendScreenMessage(playeridLOCALE_MESSAGE_CANNOTAFFORD);

    
TakePlayerCash(playeridx);

    
SetPlayerHealth(playeridHealth x);

    
format(stringsizeof string"You have bought a %s First-Aid Kit and used it for $%d."xx);// %s is for strings, x is an integer %i instead
    
SendClientMessage(playeridCOLOR_NOTIFY,string);

    
DisplayPlayerDialog(playeridDIALOG_SHOP);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)