server-sided money is now a part of the anticheat modules

This commit is contained in:
Lorenc Pekaj 2018-09-11 07:15:04 +10:00
parent eeb3a33e8b
commit d5a9c7f8a3
6 changed files with 70 additions and 59 deletions

View File

@ -41,7 +41,6 @@ enum
}; };
static stock static stock
bool: bIsDetectionEnabled [ AC_MAX_DETECTIONS ] = { true, ... },
bool: p_acSpawned [ MAX_PLAYERS char ], bool: p_acSpawned [ MAX_PLAYERS char ],
p_acUpdateTime [ MAX_PLAYERS ] p_acUpdateTime [ MAX_PLAYERS ]
; ;
@ -156,6 +155,7 @@ stock AC_SetPlayerSpawned( playerid, bool: spawned ) {
} }
/* ** Modules (remove to disable) ** */ /* ** Modules (remove to disable) ** */
#include "irresistible\anticheat\money.pwn"
#include "irresistible\anticheat\hitpoints.pwn" #include "irresistible\anticheat\hitpoints.pwn"
#include "irresistible\anticheat\weapon.pwn" #include "irresistible\anticheat\weapon.pwn"
#include "irresistible\anticheat\airbrake.pwn" #include "irresistible\anticheat\airbrake.pwn"

View File

@ -0,0 +1,37 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj
* Module: anticheat\money.pwn
* Purpose: server-sided money
*/
/* ** Variables ** */
static stock
p_Cash [ MAX_PLAYERS ];
/* ** Functions ** */
stock GivePlayerCash( playerid, money )
{
p_Cash[ playerid ] += money;
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, p_Cash[ playerid ] );
}
stock SetPlayerCash( playerid, money )
{
p_Cash[ playerid ] = money;
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, p_Cash[ playerid ] );
}
stock ResetPlayerCash( playerid )
{
p_Cash[ playerid ] = 0;
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, p_Cash[ playerid ] );
}
stock GetPlayerCash( playerid )
{
return p_Cash[ playerid ];
}

View File

@ -0,0 +1,17 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc Pekaj
* Module:
* Purpose:
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Definitions ** */
/* ** Variables ** */
/* ** Hooks ** */
/* ** Functions ** */

View File

@ -431,7 +431,8 @@ CMD:h( playerid, params[ ] )
if ( g_houseData[ i ] [ E_COST ] == 1337 && !p_VIPLevel[ playerid ] ) if ( g_houseData[ i ] [ E_COST ] == 1337 && !p_VIPLevel[ playerid ] )
return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" );
GivePlayerCash( playerid, -( g_houseData[ i ] [ E_COST ] ), .force_save = true ); GivePlayerCash( playerid, -( g_houseData[ i ] [ E_COST ] ) );
autosaveStart( playerid, true ); // force_save
SendServerMessage( playerid, "You have bought this home for "COL_GOLD"%s"COL_WHITE"!", number_format( g_houseData[ i ] [ E_COST ] ) ); SendServerMessage( playerid, "You have bought this home for "COL_GOLD"%s"COL_WHITE"!", number_format( g_houseData[ i ] [ E_COST ] ) );
SetHouseOwner( i, ReturnPlayerName( playerid ) ); SetHouseOwner( i, ReturnPlayerName( playerid ) );

View File

@ -23,7 +23,6 @@ new
p_LastVehicle [ MAX_PLAYERS ] = { INVALID_VEHICLE_ID, ... }, p_LastVehicle [ MAX_PLAYERS ] = { INVALID_VEHICLE_ID, ... },
bool: p_Cuffed [ MAX_PLAYERS char ], bool: p_Cuffed [ MAX_PLAYERS char ],
p_CuffAbuseTimer [ MAX_PLAYERS ], p_CuffAbuseTimer [ MAX_PLAYERS ],
p_Cash [ MAX_PLAYERS ],
p_AntiRobSpam [ MAX_PLAYERS ], p_AntiRobSpam [ MAX_PLAYERS ],
p_AntiRapeSpam [ MAX_PLAYERS ], p_AntiRapeSpam [ MAX_PLAYERS ],
bool: p_Tied [ MAX_PLAYERS char ], bool: p_Tied [ MAX_PLAYERS char ],

View File

@ -76,7 +76,7 @@ new bool: False = false;
#define hasTickcountPassed(%1,%2) ((GetTickCount()-%1)>(%2)) #define hasTickcountPassed(%1,%2) ((GetTickCount()-%1)>(%2))
#define Ach_Unlock(%0,%1) (%0 >= %1 ?("{6EF83C}"):("{FFFFFF}")) #define Ach_Unlock(%0,%1) (%0 >= %1 ?("{6EF83C}"):("{FFFFFF}"))
#define UpdatePlayerTime(%0) SetPlayerTime(%0,floatround(g_WorldClockSeconds/60),g_WorldClockSeconds-floatround((g_WorldClockSeconds/60)*60)) #define UpdatePlayerTime(%0) SetPlayerTime(%0,floatround(g_WorldClockSeconds/60),g_WorldClockSeconds-floatround((g_WorldClockSeconds/60)*60))
#define GetPlayerTotalCash(%0) (p_BankMoney[%0] + p_Cash[%0]) // Bank Money and Money #define GetPlayerTotalCash(%0) (p_BankMoney[%0] + GetPlayerCash(%0)) // Bank Money and Money
#define GetPlayerMethLabVehicle(%0) (GetPlayerVirtualWorld(%0)-VW_METH) #define GetPlayerMethLabVehicle(%0) (GetPlayerVirtualWorld(%0)-VW_METH)
#define IsPlayerLorenc(%0) (p_AccountID[%0]==1) #define IsPlayerLorenc(%0) (p_AccountID[%0]==1)
#define Achievement:: ach_ #define Achievement:: ach_
@ -259,14 +259,6 @@ new stock
DCC_Role: discordRoleVoice DCC_Role: discordRoleVoice
; ;
/* ** Random Messages ** */
stock const
killedWords[ ] [ ] =
{
{ "murked" }, { "killed" }, { "ended" }, { "slain" }, { "massacred" }, { "destroyed" }, { "screwed" }
}
;
/* ** Bribe Data ** */ /* ** Bribe Data ** */
#define MAX_BRIBES ( 200 ) #define MAX_BRIBES ( 200 )
#define MAX_BRIBE_WAIT ( 300000 ) #define MAX_BRIBE_WAIT ( 300000 )
@ -1758,22 +1750,6 @@ new
Iterator:garages<MAX_GARAGES> Iterator:garages<MAX_GARAGES>
; ;
/* ** Anti RDM Zones *
#define MAX_RDM_ZONES ( 18 )
#define MAX_RDM_GANGZONES ( 14 )
enum E_RDM_ZONE
{
E_CIRCLE, E_GANGZONES[ MAX_RDM_GANGZONES ],
};
new
g_antiDeathmatchZoneData [ MAX_RDM_ZONES ] [ E_RDM_ZONE ],
// Iterator
Iterator:rdmzone<MAX_RDM_ZONES>
;*/
/* ** Sprunk ** */ /* ** Sprunk ** */
enum E_VENDING_MACHINE enum E_VENDING_MACHINE
{ {
@ -6336,6 +6312,7 @@ public OnPlayerDeath( playerid, killerid, reason )
{ {
if ( p_WantedLevel[ playerid ] > 5 ) if ( p_WantedLevel[ playerid ] > 5 )
{ {
static const killedWords[ ] [ ] = { { "murked" }, { "killed" }, { "ended" }, { "slain" }, { "massacred" }, { "destroyed" }, { "screwed" } };
new cashEarned = ( p_WantedLevel[ playerid ] < MAX_WANTED_LVL ? p_WantedLevel[ playerid ] : MAX_WANTED_LVL ) * ( reason == 38 ? 170 : 270 ); new cashEarned = ( p_WantedLevel[ playerid ] < MAX_WANTED_LVL ? p_WantedLevel[ playerid ] : MAX_WANTED_LVL ) * ( reason == 38 ? 170 : 270 );
GivePlayerCash( killerid, cashEarned ); GivePlayerCash( killerid, cashEarned );
GivePlayerScore( killerid, 2 ); GivePlayerScore( killerid, 2 );
@ -7596,7 +7573,8 @@ CMD:business( playerid, params[ ] )
g_businessData[ b ] [ E_OWNER_ID ] = p_AccountID[ playerid ]; g_businessData[ b ] [ E_OWNER_ID ] = p_AccountID[ playerid ];
UpdateBusinessData( b ); UpdateBusinessData( b );
UpdateBusinessTitle( b ); UpdateBusinessTitle( b );
GivePlayerCash( playerid, -( g_businessData[ b ] [ E_COST ] ), .force_save = true ); GivePlayerCash( playerid, -( g_businessData[ b ] [ E_COST ] ) );
autosaveStart( playerid, true );
SendClientMessageFormatted( playerid, -1, ""COL_GREY"[BUSINESS]"COL_WHITE" You have bought this business for "COL_GOLD"%s"COL_WHITE".", cash_format( g_businessData[ b ] [ E_COST ] ) ); SendClientMessageFormatted( playerid, -1, ""COL_GREY"[BUSINESS]"COL_WHITE" You have bought this business for "COL_GOLD"%s"COL_WHITE".", cash_format( g_businessData[ b ] [ E_COST ] ) );
return 1; return 1;
} }
@ -8171,7 +8149,8 @@ CMD:garage( playerid, params[ ] )
g_garageData[ g ] [ E_OWNER_ID ] = p_AccountID[ playerid ]; g_garageData[ g ] [ E_OWNER_ID ] = p_AccountID[ playerid ];
UpdateGarageData( g ); UpdateGarageData( g );
UpdateGarageTitle( g ); UpdateGarageTitle( g );
GivePlayerCash( playerid, -( g_garageData[ g ] [ E_PRICE ] ), .force_save = true ); GivePlayerCash( playerid, -( g_garageData[ g ] [ E_PRICE ] ) );
autosaveStart( playerid, true ); // auto-save
SendClientMessageFormatted( playerid, -1, ""COL_GREY"[GARAGE]"COL_WHITE" You have bought this garage for "COL_GOLD"%s"COL_WHITE".", cash_format( g_garageData[ g ] [ E_PRICE ] ) ); SendClientMessageFormatted( playerid, -1, ""COL_GREY"[GARAGE]"COL_WHITE" You have bought this garage for "COL_GOLD"%s"COL_WHITE".", cash_format( g_garageData[ g ] [ E_PRICE ] ) );
return 1; return 1;
} }
@ -9143,7 +9122,7 @@ CMD:ransom( playerid, params[ ] )
else if ( p_PlayerSettings[ victimid ] { SETTING_RANSOMS } ) return SendError( playerid, "This player has disabled ransom offers." ); else if ( p_PlayerSettings[ victimid ] { SETTING_RANSOMS } ) return SendError( playerid, "This player has disabled ransom offers." );
else if ( amount < 50 || amount > 20000 ) return SendError( playerid, "You may place a ransom from $50 to $20,000." ); else if ( amount < 50 || amount > 20000 ) return SendError( playerid, "You may place a ransom from $50 to $20,000." );
else if ( amount > 99999999 || amount < 0 ) return SendError( playerid, "You may place a ransom from $50 to $20,000."); // Making cash go over billions... else if ( amount > 99999999 || amount < 0 ) return SendError( playerid, "You may place a ransom from $50 to $20,000."); // Making cash go over billions...
else if ( amount > p_Cash[ victimid ] ) return SendError( playerid, "This person doesn't have enough money to pay this amount." ); else if ( amount > GetPlayerCash( victimid ) ) return SendError( playerid, "This person doesn't have enough money to pay this amount." );
else if ( p_RansomTimestamp[ victimid ] > g_iTime ) return SendError( playerid, "You must wait %d seconds before offering a ransom to this person.", p_RansomTimestamp[ victimid ] - g_iTime ); else if ( p_RansomTimestamp[ victimid ] > g_iTime ) return SendError( playerid, "You must wait %d seconds before offering a ransom to this person.", p_RansomTimestamp[ victimid ] - g_iTime );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) ) else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
{ {
@ -18415,7 +18394,8 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
new bID = CreateBuyableVehicle( playerid, model, random( 126 ), random( 126 ), X, Y, Z, fA, g_BuyableVehicleData[ data_id ] [ E_PRICE ] ); new bID = CreateBuyableVehicle( playerid, model, random( 126 ), random( 126 ), X, Y, Z, fA, g_BuyableVehicleData[ data_id ] [ E_PRICE ] );
if ( bID == -1 ) return SendClientMessage( playerid, -1, ""COL_GREY"[VEHICLE]"COL_WHITE" Unable to create a vehicle due to a unexpected error." ); if ( bID == -1 ) return SendClientMessage( playerid, -1, ""COL_GREY"[VEHICLE]"COL_WHITE" Unable to create a vehicle due to a unexpected error." );
GivePlayerCash( playerid, -g_BuyableVehicleData[ data_id ] [ E_PRICE ], .force_save = true ); GivePlayerCash( playerid, -g_BuyableVehicleData[ data_id ] [ E_PRICE ] );
autosaveStart( playerid, true ); // auto-save
GetVehicleParamsEx( g_vehicleData[ playerid ] [ bID ] [ E_VEHICLE_ID ], engine, lights, alarm, doors, bonnet, boot, objective ); GetVehicleParamsEx( g_vehicleData[ playerid ] [ bID ] [ E_VEHICLE_ID ], engine, lights, alarm, doors, bonnet, boot, objective );
SetVehicleParamsEx( g_vehicleData[ playerid ] [ bID ] [ E_VEHICLE_ID ], VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective ); SetVehicleParamsEx( g_vehicleData[ playerid ] [ bID ] [ E_VEHICLE_ID ], VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective );
@ -18853,7 +18833,8 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
if ( GetPlayerCash( playerid ) < 5000000 ) if ( GetPlayerCash( playerid ) < 5000000 )
return SendError( playerid, "You don't have enough money for this ($5,000,000)." ); return SendError( playerid, "You don't have enough money for this ($5,000,000)." );
GivePlayerCash( playerid, -5000000, .force_save = true ); GivePlayerCash( playerid, -5000000 );
autosaveStart( playerid, true ); // auto-save
new aID = p_ApartmentEnter{ playerid }; new aID = p_ApartmentEnter{ playerid };
g_apartmentData[ aID ] [ E_CREATED ] = true; g_apartmentData[ aID ] [ E_CREATED ] = true;
@ -21659,30 +21640,6 @@ stock ClearPlayerWantedLevel( playerid )
SetPlayerColorToTeam( playerid ); SetPlayerColorToTeam( playerid );
} }
stock GetPlayerCash( playerid ) return p_Cash[ playerid ];
stock GivePlayerCash( playerid, money, bool: force_save = false )
{
p_Cash[ playerid ] += money;
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, p_Cash[ playerid ] );
autosaveStart( playerid, force_save ); // auto-save
}
stock SetPlayerCash( playerid, money )
{
p_Cash[ playerid ] = money;
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, p_Cash[ playerid ] );
}
stock ResetPlayerCash( playerid )
{
p_Cash[ playerid ] = 0;
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, p_Cash[ playerid ] );
}
stock IsWeaponBanned( weaponid ) { stock IsWeaponBanned( weaponid ) {
return 0 <= weaponid < MAX_WEAPONS && ( weaponid == 36 || weaponid == 37 || weaponid == 38 || weaponid == 39 || weaponid == 44 || weaponid == 45 ); return 0 <= weaponid < MAX_WEAPONS && ( weaponid == 36 || weaponid == 37 || weaponid == 38 || weaponid == 39 || weaponid == 44 || weaponid == 45 );
} }