Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- /* |=========================================| *\
- | | To use this script properly, you MUST set this timer under
- | Crayder's Cash | OnGameModeInit. SetTimer("Cash_Update", 25, true);
- | This script was made for all those | If this timer isn't set, having this script is pointless.
- | Server owner's who hate Money-Hackers! |
- | | To use foreach instead of those terrible MAX_PLAYER loops,
- | Thanks to me, SAMP team, and Y-Less | just include foreach before this script in your gamemode.
- | | (DO NOT INCLUDE IT IN THIS SCRIPT AND YOUR GAMEMODE)
- \* |=========================================| */
- //Settings
- new bool:SCRIPT_MESSAGE_SHOWED= false, //Change to true if you don't want the script message to show when loading.
- bool:AllowLessCashHack= true; //This allows players to hack their cash to be less, but not more.
- //Changing to false will not allow players to change their cash at all!
- /* ========================================== *\
- native SetPlayerCash(playerid, amount); -Sets their cash to the specified amount.
- native TakePlayerCash(playerid, amount); -Takes the specified amount of cash from them.
- native GivePlayerCash(playerid, amount); -Gives the specified amount of cash to them.
- native ResetPlayerCash(playerid, amount); -Resets their cash.
- native GetPlayerCash(playerid, amount); -Returns the amount of cash.
- \* ========================================== */
- new C_PlayersCash[MAX_PLAYERS];
- stock SetPlayerCash(playerid, amount)
- {
- C_PlayersCash[playerid] = amount;
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, C_PlayersCash[playerid]);
- return 1;
- }
- stock TakePlayerCash(playerid, amount)
- {
- C_PlayersCash[playerid] = (C_PlayersCash[playerid] - amount);
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, C_PlayersCash[playerid]);
- return 1;
- }
- stock GivePlayerCash(playerid, amount)
- {
- C_PlayersCash[playerid] = (C_PlayersCash[playerid] + amount);
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid, C_PlayersCash[playerid]);
- return 1;
- }
- stock ResetPlayerCash(playerid)
- {
- C_PlayersCash[playerid] = 0;
- ResetPlayerMoney(playerid);
- return 1;
- }
- stock GetPlayerCash(playerid)
- {
- return C_PlayersCash[playerid];
- }
- forward Cash_Update();
- public Cash_Update()
- {
- if(SCRIPT_MESSAGE_SHOWED==false)
- {
- print("\n|============================|");
- print("| Crayder's Cash |");
- print("| Server-Sided Money |");
- print("| Loaded |");
- print("|============================|\n");
- SCRIPT_MESSAGE_SHOWED=true;
- }
- #if defined _FOREACH_BOT //Checks to see if foreach is included.
- foreach(Player, playerid) //For Each Player Loop.
- {
- if(GetPlayerMoney(playerid) != C_PlayersCash[playerid] && !AllowLessCashHack) //If their cash isn't right.
- {
- ResetPlayerMoney(playerid); //Reset their cash.
- GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
- }
- else if(GetPlayerMoney(playerid) > C_PlayersCash[playerid] && AllowLessCashHack) //If their cash is more than right.
- {
- ResetPlayerMoney(playerid); //Reset their cash.
- GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
- }
- }
- #else //If foreach is not included.
- for(new playerid; playerid < MAX_PLAYERS; playerid++) //Loops through all players.
- {
- if(!IsPlayerConnected(playerid)) continue; //If they are not connected, goto the next playerid.
- if(GetPlayerMoney(playerid) != C_PlayersCash[playerid] && !AllowLessCashHack) //If their cash isn't right.
- {
- ResetPlayerMoney(playerid); //Reset their cash.
- GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
- }
- else if(GetPlayerMoney(playerid) > C_PlayersCash[playerid] && AllowLessCashHack) //If their cash is more than right.
- {
- ResetPlayerMoney(playerid); //Reset their cash.
- GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
- }
- }
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement