Advertisement
Guest User

cents.inc

a guest
Aug 14th, 2011
1,270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.47 KB | None | 0 0
  1. //==========================================================
  2. //        Cents include version 1.0 by MadeMan
  3. //==========================================================
  4.  
  5. #if defined _cents_included
  6.     #endinput
  7. #endif
  8. #define _cents_included
  9.  
  10. stock Cents_GivePlayerMoney(playerid, dollars, cents=0)
  11. {
  12.     new _cents = GetPVarInt(playerid, "Cents");
  13.     _cents += cents;
  14.     while(_cents > 99)
  15.     {
  16.         dollars++; _cents -= 100;
  17.     }
  18.     while(_cents < -99)
  19.     {
  20.         dollars--; _cents += 100;
  21.     }
  22.     new _cents_money = GetPlayerMoney(playerid)+dollars;
  23.     if(_cents_money > 0 && _cents < 0)
  24.     {
  25.         dollars--; _cents += 100;
  26.     }
  27.     if(_cents_money < 0 && _cents > 0)
  28.     {
  29.         dollars++; _cents -= 100;
  30.     }
  31.     SetPVarInt(playerid, "Cents", _cents);
  32.     new _cents_string[16];
  33.     format(_cents_string, sizeof(_cents_string), "%02d", _cents);
  34.     if(_cents_string[0] == '-') strdel(_cents_string, 0, 1);
  35.     if(_cents < 0 || (_cents == 0 && _cents_money < 0)) strins(_cents_string, "~r~.", 0);
  36.     else strins(_cents_string, "~g~.", 0);
  37.     CallRemoteFunction("UpdateCentsDisplay", "ds", playerid, _cents_string);
  38.     return GivePlayerMoney(playerid, dollars);
  39. }
  40.  
  41. stock Cents_ResetPlayerMoney(playerid)
  42. {
  43.     SetPVarInt(playerid, "Cents", 0);
  44.     CallRemoteFunction("UpdateCentsDisplay", "ds", playerid, "~g~.00");
  45.     return ResetPlayerMoney(playerid);
  46. }
  47.  
  48. #define GivePlayerMoney Cents_GivePlayerMoney
  49. #define ResetPlayerMoney Cents_ResetPlayerMoney
  50.  
  51. stock GetPlayerCents(playerid)
  52. {
  53.     return GetPVarInt(playerid, "Cents");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement