diff --git a/gamemodes/irresistible/cnr/features/player/bank.pwn b/gamemodes/irresistible/cnr/features/player/bank.pwn index 2726f65..0b9bae3 100644 --- a/gamemodes/irresistible/cnr/features/player/bank.pwn +++ b/gamemodes/irresistible/cnr/features/player/bank.pwn @@ -29,17 +29,17 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) { case 0: { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_WITHDRAW, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Withdraw", "Back" ); } case 1: { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_DEPOSIT, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Deposit", "Back" ); } case 2: { - format( szBigString, sizeof( szBigString ), ""COL_GREY"Current Balance:"COL_WHITE" %s\n"COL_GREY"Current Money:{FFFFFF} %s", cash_format( p_BankMoney[ playerid ] ), cash_format( GetPlayerCash( playerid ) ) ); + format( szBigString, sizeof( szBigString ), ""COL_GREY"Current Balance:"COL_WHITE" %s\n"COL_GREY"Current Money:{FFFFFF} %s", cash_format( GetPlayerBankMoney( playerid ) ), cash_format( GetPlayerCash( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_INFO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Personal Account", szBigString, "Ok", "Back" ); } // ... cases 3, 4, 5 handled in cnr\features\gangs\gbank.pwn @@ -57,33 +57,33 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) format( money_withdraw, sizeof( money_withdraw ), "%s", inputtext ); if ( strmatch( money_withdraw, "MAX" ) || strmatch( money_withdraw, "ALL" ) ) { - format( money_withdraw, sizeof( money_withdraw ), "%d", p_BankMoney[ playerid ] ); + format( money_withdraw, sizeof( money_withdraw ), "%d", GetPlayerBankMoney( playerid ) ); } if ( ! strlen( money_withdraw ) ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_WITHDRAW, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Withdraw", "Back" ); } else if ( ! IsNumeric( money_withdraw ) ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_WITHDRAW, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Withdraw", "Back" ); } else if ( strval( money_withdraw ) > 99999999 || strval( money_withdraw ) <= 0 ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_WITHDRAW, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Withdraw", "Back" ); } - else if ( strval( money_withdraw ) > p_BankMoney[ playerid ] ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Insufficient balance, therefore withdrawal failed.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + else if ( strval( money_withdraw ) > GetPlayerBankMoney( playerid ) ) { + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to withdraw from your bank account.\n\n"COL_RED"Insufficient balance, therefore withdrawal failed.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_WITHDRAW, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Withdraw", "Back" ); } else { new iWithdraw = strval( money_withdraw ); - p_BankMoney[ playerid ] -= iWithdraw; + GivePlayerBankMoney( playerid, -iWithdraw ); GivePlayerCash( playerid, iWithdraw ); - format( szBigString, sizeof( szBigString ), ""COL_GREY"Amount Withdrawn:"COL_WHITE" %s\n"COL_GREY"Current Balance:"COL_WHITE" %s\n"COL_GREY"Current Money:{FFFFFF} %s", cash_format( iWithdraw ), cash_format( p_BankMoney[ playerid ] ), cash_format( GetPlayerCash( playerid ) ) ); + format( szBigString, sizeof( szBigString ), ""COL_GREY"Amount Withdrawn:"COL_WHITE" %s\n"COL_GREY"Current Balance:"COL_WHITE" %s\n"COL_GREY"Current Money:{FFFFFF} %s", cash_format( iWithdraw ), cash_format( GetPlayerBankMoney( playerid ) ), cash_format( GetPlayerCash( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_INFO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Personal Account", szBigString, "Ok", "Back" ); } return 1; @@ -106,28 +106,28 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) // validate amount if ( !strlen( money_deposit ) ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_DEPOSIT, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Deposit", "Back" ); } else if ( ! IsNumeric( money_deposit ) ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_DEPOSIT, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Deposit", "Back" ); } else if ( strval( money_deposit ) > GetPlayerCash( playerid ) ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Insufficient balance, therefore deposition failed.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Insufficient balance, therefore deposition failed.\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_DEPOSIT, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Deposit", "Back" ); } else if ( strval( money_deposit ) > 99999999 || strval( money_deposit ) <= 0 ) { - format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( p_BankMoney[ playerid ] ) ); + format( szBigString, sizeof( szBigString ), "{FFFFFF}Enter the amount that you are willing to deposit into your bank account below.\n\n"COL_RED"Invalid amount entered!\n\n"COL_GREY"Current Balance:"COL_WHITE" %s", cash_format( GetPlayerBankMoney( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_DEPOSIT, DIALOG_STYLE_INPUT, "{FFFFFF}Personal Account", szBigString, "Deposit", "Back" ); } else { new iDeposit = strval( money_deposit ); - p_BankMoney[ playerid ] += iDeposit; + GivePlayerBankMoney( playerid, iDeposit ); GivePlayerCash( playerid, -iDeposit ); - format( szBigString, sizeof( szBigString ), ""COL_GREY"Amount Deposited:"COL_WHITE" %s\n"COL_GREY"Current Balance:"COL_WHITE" %s\n"COL_GREY"Current Money:{FFFFFF} %s", cash_format( iDeposit ), cash_format( p_BankMoney[ playerid ] ), cash_format( GetPlayerCash( playerid ) ) ); + format( szBigString, sizeof( szBigString ), ""COL_GREY"Amount Deposited:"COL_WHITE" %s\n"COL_GREY"Current Balance:"COL_WHITE" %s\n"COL_GREY"Current Money:{FFFFFF} %s", cash_format( iDeposit ), cash_format( GetPlayerBankMoney( playerid ) ), cash_format( GetPlayerCash( playerid ) ) ); ShowPlayerDialog( playerid, DIALOG_BANK_INFO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Personal Account", szBigString, "Ok", "Back" ); } } @@ -144,7 +144,18 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) } hook OnPlayerDisconnect( playerid, reason ) { - p_BankMoney[ playerid ] = 0; + p_BankMoney[ playerid ] = 0; + return 1; +} + +/* ** Callbacks ** */ +public OnPlayerBankMoneyChanged( playerid, amount ) +{ + // save player bank money on each monetary movement + if ( IsPlayerLoggedIn( playerid ) ) + { + mysql_single_query( sprintf( "UPDATE `USERS` SET `BANKMONEY` = %d WHERE `ID` = %d", GetPlayerBankMoney( playerid ), GetPlayerAccountID( playerid ) ) ); + } return 1; } @@ -159,6 +170,7 @@ stock SetPlayerBankMoney( playerid, money ) { stock GivePlayerBankMoney( playerid, money ) { p_BankMoney[ playerid ] += money; + CallRemoteFunction( "OnPlayerBankMoneyChanged", "dd", playerid, money ); } stock ShowPlayerBankMenuDialog( playerid ) diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index a0480f7..b5f8fc0 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -4609,16 +4609,6 @@ function unpause_Player( playerid ) return 1; } - public OnPlayerBankMoneyChanged( playerid, amount ) - { - // save player bank money on each monetary movement - if ( IsPlayerLoggedIn( playerid ) ) - { - mysql_single_query( sprintf( "UPDATE `USERS` SET `BANKMONEY` = %d WHERE `ID` = %d", GetPlayerBankMoney( playerid ), GetPlayerAccountID( playerid ) ) ); - } - return 1; - } - public OnPlayerCheatDetected( playerid, detection, params ) { if ( detection == CHEAT_TYPE_REMOTE_JACK )