add OnPlayerMoneyChanged callback
This commit is contained in:
parent
fc7aeb2559
commit
2ed679b149
@ -19,6 +19,9 @@
|
|||||||
static stock
|
static stock
|
||||||
p_Cash [ MAX_PLAYERS ];
|
p_Cash [ MAX_PLAYERS ];
|
||||||
|
|
||||||
|
/* ** Forwards ** */
|
||||||
|
forward OnPlayerMoneyChanged ( playerid, before_amount, after_amount );
|
||||||
|
|
||||||
/* ** Hooks ** */
|
/* ** Hooks ** */
|
||||||
hook OnVehicleMod( playerid, vehicleid, componentid )
|
hook OnVehicleMod( playerid, vehicleid, componentid )
|
||||||
{
|
{
|
||||||
@ -229,23 +232,50 @@ hook OnVehicleRespray( playerid, vehicleid, color1, color2 )
|
|||||||
/* ** Functions ** */
|
/* ** Functions ** */
|
||||||
stock GivePlayerCash( playerid, money )
|
stock GivePlayerCash( playerid, money )
|
||||||
{
|
{
|
||||||
p_Cash[ playerid ] += money;
|
if ( CallRemoteFunction( "OnPlayerMoneyChanged", "ddd", playerid, p_Cash[ playerid ], p_Cash[ playerid ] + money ) )
|
||||||
ResetPlayerMoney( playerid );
|
{
|
||||||
GivePlayerMoney( playerid, p_Cash[ playerid ] );
|
p_Cash[ playerid ] += money;
|
||||||
|
ResetPlayerMoney( playerid );
|
||||||
|
GivePlayerMoney( playerid, p_Cash[ playerid ] );
|
||||||
|
}
|
||||||
|
#if defined DEBUG_MODE
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf( "GivePlayerCash( %d, %d ) prevented [Reason: OnPlayerMoneyChanged returned 0]", playerid, money );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
stock SetPlayerCash( playerid, money )
|
stock SetPlayerCash( playerid, money )
|
||||||
{
|
{
|
||||||
p_Cash[ playerid ] = money;
|
if ( CallRemoteFunction( "OnPlayerMoneyChanged", "ddd", playerid, p_Cash[ playerid ], money ) )
|
||||||
ResetPlayerMoney( playerid );
|
{
|
||||||
GivePlayerMoney( playerid, p_Cash[ playerid ] );
|
p_Cash[ playerid ] = money;
|
||||||
|
ResetPlayerMoney( playerid );
|
||||||
|
GivePlayerMoney( playerid, p_Cash[ playerid ] );
|
||||||
|
}
|
||||||
|
#if defined DEBUG_MODE
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf( "SetPlayerCash( %d, %d ) prevented [Reason: OnPlayerMoneyChanged returned 0]", playerid, money );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
stock ResetPlayerCash( playerid )
|
stock ResetPlayerCash( playerid )
|
||||||
{
|
{
|
||||||
p_Cash[ playerid ] = 0;
|
if ( CallRemoteFunction( "OnPlayerMoneyChanged", "ddd", playerid, p_Cash[ playerid ], 0 ) )
|
||||||
ResetPlayerMoney( playerid );
|
{
|
||||||
GivePlayerMoney( playerid, p_Cash[ playerid ] );
|
p_Cash[ playerid ] = 0;
|
||||||
|
ResetPlayerMoney( playerid );
|
||||||
|
GivePlayerMoney( playerid, p_Cash[ playerid ] );
|
||||||
|
}
|
||||||
|
#if defined DEBUG_MODE
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf( "ResetPlayerCash( %d ) prevented [Reason: OnPlayerMoneyChanged returned 0]", playerid );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
stock GetPlayerCash( playerid )
|
stock GetPlayerCash( playerid )
|
||||||
|
@ -5280,6 +5280,11 @@ function unpause_Player( playerid )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined AC_INCLUDED
|
#if defined AC_INCLUDED
|
||||||
|
public OnPlayerMoneyChanged( playerid, before_amount, after_amount )
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public OnPlayerCheatDetected( playerid, detection, params )
|
public OnPlayerCheatDetected( playerid, detection, params )
|
||||||
{
|
{
|
||||||
if ( detection == CHEAT_TYPE_REMOTE_JACK )
|
if ( detection == CHEAT_TYPE_REMOTE_JACK )
|
||||||
|
Loading…
Reference in New Issue
Block a user