Medical fees
#1

Well, I'm trying . If player has money less than 50k in bank. So, It should take money from player's hand cash.
If player has more more than 50k in bank so it should use bank cash.


Example:

I have less than 50k in bank. It should be take cash from my hand.
I have more than 50k in bank . It should take money from bank.

Here's code: I tried but can't get this.

PHP код:
if(pInfo[playerid][pBankMoney] < 50000)
    {
          new 
string2[500];
          new 
wealth GetPlayerCash(playerid) + pInfo[playerid][pBankMoney];
          new 
medfee = (12*wealth)/100;
          
GivePlayerCashEx(playerid,-medfee);
          
format(stringsizeof(string), "%s (%d) has paid $%d in medical fees.",GetName(playerid),playeridmedfee);
          
SendClientMessageToAll(COLOR_CYAN,string);
          
format(string2sizeof(string2), "You have died. The hospital has charged you $%d in medical fees.",medfee);
          
SendClientMessage(playeridCOLOR_CYANstring2);
    }
    else
    {
          new 
string2[500], string3[500];
          new 
wealth GetPlayerCash(playerid) + pInfo[playerid][pBankMoney];
          new 
medfee = (12*wealth)/100;
          
pInfo[playerid][pBankMoney] = pInfo[playerid][pBankMoney] - medfee;
          
format(stringsizeof(string), "%s (%d) has paid $%d in medical fees.",GetName(playerid),playeridmedfee);
          
SendClientMessageToAll(COLOR_CYAN,string);
          
format(string2sizeof(string2), "You have died. The hospital has charged you $%d in medical fees. You have used your bank account to paid your medical fees.",medfee);
          
SendClientMessage(playeridCOLOR_CYANstring2);
          
format(string3sizeof(string3), "Now, your total balance is: $%d",pInfo[playerid][pBankMoney]);
          
SendClientMessage(playeridCOLOR_CYANstring3);
    } 
Reply
#2

Anyone?
Reply
#3

what is it doing when you attempt to test this?
Reply
#4

Try this code:
Код:
if(pInfo[playerid][pBankMoney] < 50000) 
    { 
          new string2[500]; 
          new wealth = GetPlayerCash(playerid); 
          new medfee = (12*wealth)/100; 
          GivePlayerCashEx(playerid,-medfee); 
          format(string, sizeof(string), "%s (%d) has paid $%d in medical fees.",GetName(playerid),playerid, medfee); 
          SendClientMessageToAll(COLOR_CYAN,string); 
          format(string2, sizeof(string2), "You have died. The hospital has charged you $%d in medical fees.",medfee); 
          SendClientMessage(playerid, COLOR_CYAN, string2); 
    } 
    else if(pInfo[playerid][pBankMoney] >= 50000)
    { 
          new string2[500], string3[500]; 
          new wealth = pInfo[playerid][pBankMoney]; 
          new medfee = (12*wealth)/100; 
          pInfo[playerid][pBankMoney] -= medfee; 
          format(string, sizeof(string), "%s (%d) has paid $%d in medical fees.",GetName(playerid),playerid, medfee); 
          SendClientMessageToAll(COLOR_CYAN,string); 
          format(string2, sizeof(string2), "You have died. The hospital has charged you $%d in medical fees. You have used your bank account to paid your medical fees.",medfee); 
          SendClientMessage(playerid, COLOR_CYAN, string2); 
          format(string3, sizeof(string3), "Now, your total balance is: $%d",pInfo[playerid][pBankMoney]); 
          SendClientMessage(playerid, COLOR_CYAN, string3); 
    }
I think problem was u are taking player money from hand + from bank in both cases
Reply
#5

^^ didn't work. It doesn't counting bank money. Just checking Player's hand money.
Reply
#6

if its only checking players hand money are u sure then to ur bank money is saved and loaded in player variable pBankMoney

and give us stock GetPlayerCash
Reply
#7

Well, My mistake i forgot to do -= medfee. But i added it now and tested.

It works like this.

It works good when i have less than 50k in bank and more than 50k on player's hand. it works good. here.

But when i have more than 50k in bank so it takes money from player's hand and bank also. it Should takes money from bank only.

PHP код:
if(pInfo[playerid][pBankMoney] < 50000)
    {
          new 
string2[256];
          new 
wealth GetPlayerCash(playerid) + pInfo[playerid][pBankMoney];
          new 
medfee = (12*wealth)/100;
          
GivePlayerCashEx(playerid,-medfee);
          
format(stringsizeof(string), "%s (%d) has paid $%d in medical fees.",GetName(playerid),playeridmedfee);
          
SendClientMessageToAll(COLOR_CYAN,string);
          
format(string2sizeof(string2), "You have died. The hospital has charged you $%d in medical fees.",medfee);
          
SendClientMessage(playeridCOLOR_CYANstring2);
    }
    else if(
pInfo[playerid][pBankMoney] >= 50000)
    {
          new 
string2[256], string3[256];
          new 
wealth GetPlayerCash(playerid) + pInfo[playerid][pBankMoney];
          new 
medfee = (12*wealth)/100;
          
pInfo[playerid][pBankMoney] -= medfee;
          
format(stringsizeof(string), "%s (%d) has paid $%d in medical fees.",GetName(playerid),playeridmedfee);
          
SendClientMessageToAll(COLOR_CYAN,string);
          
format(string2sizeof(string2), "You have died. The hospital has charged you $%d in medical fees. You have used your bank account to paid your medical fees.",medfee);
          
SendClientMessage(playeridCOLOR_CYANstring2);
          
format(string3sizeof(string3), "Now, your total balance is: $%d",pInfo[playerid][pBankMoney]);
          
SendClientMessage(playeridCOLOR_CYANstring3);
    } 
new wealth = GetPlayerCash(playerid) + pInfo[playerid][pBankMoney];

I'm using this because i want it count hands and bank money and take medical fees from it. But i want it should remove money from bank if bank has more than 50k.
Reply
#8

Hmm, i just tested this code and its working perfect for me, i dont know how can take your money from hand and bank too if u have more then 50k in bank...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)