Advertisement
Crayder

Crayders Cash

Mar 6th, 2014
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.19 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. /*  |=========================================|  *\
  4.     |                                         |     To use this script properly, you MUST set this timer under
  5.     |             Crayder's Cash              |     OnGameModeInit.     SetTimer("Cash_Update", 25, true);
  6.     |    This script was made for all those   |     If this timer isn't set, having this script is pointless.
  7.     |  Server owner's who hate Money-Hackers! |
  8.     |                                         |     To use foreach instead of those terrible MAX_PLAYER loops,
  9.     |   Thanks to me, SAMP team, and Y-Less   |     just include foreach before this script in your gamemode.
  10.     |                                         |     (DO NOT INCLUDE IT IN THIS SCRIPT AND YOUR GAMEMODE)
  11. \*  |=========================================|  */
  12.  
  13. //Settings
  14. new bool:SCRIPT_MESSAGE_SHOWED=     false//Change to true if you don't want the script message to show when loading.
  15.    
  16.     bool:AllowLessCashHack=     true;   //This allows players to hack their cash to be less, but not more.
  17.                                         //Changing to false will not allow players to change their cash at all!
  18.  
  19. /*  ==========================================  *\
  20.     native SetPlayerCash(playerid, amount);         -Sets their cash to the specified amount.
  21.     native TakePlayerCash(playerid, amount);        -Takes the specified amount of cash from them.
  22.     native GivePlayerCash(playerid, amount);        -Gives the specified amount of cash to them.
  23.     native ResetPlayerCash(playerid, amount);       -Resets their cash.
  24.     native GetPlayerCash(playerid, amount);         -Returns the amount of cash.
  25. \*  ==========================================  */
  26.  
  27. new C_PlayersCash[MAX_PLAYERS];
  28.  
  29. stock SetPlayerCash(playerid, amount)
  30. {
  31.     C_PlayersCash[playerid] = amount;
  32.     ResetPlayerMoney(playerid);
  33.     GivePlayerMoney(playerid, C_PlayersCash[playerid]);
  34.     return 1;
  35. }
  36. stock TakePlayerCash(playerid, amount)
  37. {
  38.     C_PlayersCash[playerid] = (C_PlayersCash[playerid] - amount);
  39.     ResetPlayerMoney(playerid);
  40.     GivePlayerMoney(playerid, C_PlayersCash[playerid]);
  41.     return 1;
  42. }
  43. stock GivePlayerCash(playerid, amount)
  44. {
  45.     C_PlayersCash[playerid] = (C_PlayersCash[playerid] + amount);
  46.     ResetPlayerMoney(playerid);
  47.     GivePlayerMoney(playerid, C_PlayersCash[playerid]);
  48.     return 1;
  49. }
  50. stock ResetPlayerCash(playerid)
  51. {
  52.     C_PlayersCash[playerid] = 0;
  53.     ResetPlayerMoney(playerid);
  54.     return 1;
  55. }
  56. stock GetPlayerCash(playerid)
  57. {
  58.     return C_PlayersCash[playerid];
  59. }
  60.  
  61. forward Cash_Update();
  62. public Cash_Update()
  63. {
  64.     if(SCRIPT_MESSAGE_SHOWED==false)
  65.     {
  66.         print("\n|============================|");
  67.         print("|       Crayder's Cash       |");
  68.         print("|     Server-Sided Money     |");
  69.         print("|           Loaded           |");
  70.         print("|============================|\n");
  71.         SCRIPT_MESSAGE_SHOWED=true;
  72.     }
  73.     #if defined _FOREACH_BOT //Checks to see if foreach is included.
  74.     foreach(Player, playerid) //For Each Player Loop.
  75.     {
  76.         if(GetPlayerMoney(playerid) != C_PlayersCash[playerid] && !AllowLessCashHack) //If their cash isn't right.
  77.         {
  78.             ResetPlayerMoney(playerid); //Reset their cash.
  79.             GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
  80.         }
  81.         else if(GetPlayerMoney(playerid) > C_PlayersCash[playerid] && AllowLessCashHack) //If their cash is more than right.
  82.         {
  83.             ResetPlayerMoney(playerid); //Reset their cash.
  84.             GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
  85.         }
  86.     }
  87.     #else //If foreach is not included.
  88.     for(new playerid; playerid < MAX_PLAYERS; playerid++) //Loops through all players.
  89.     {
  90.         if(!IsPlayerConnected(playerid)) continue; //If they are not connected, goto the next playerid.
  91.         if(GetPlayerMoney(playerid) != C_PlayersCash[playerid] && !AllowLessCashHack) //If their cash isn't right.
  92.         {
  93.             ResetPlayerMoney(playerid); //Reset their cash.
  94.             GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
  95.         }
  96.         else if(GetPlayerMoney(playerid) > C_PlayersCash[playerid] && AllowLessCashHack) //If their cash is more than right.
  97.         {
  98.             ResetPlayerMoney(playerid); //Reset their cash.
  99.             GivePlayerMoney(playerid, C_PlayersCash[playerid]); //Give them the cash the server says they should have.
  100.         }
  101.     }
  102.     #endif
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement