HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #pragma semicolon 1
  2.  
  3. /*
  4.  * SM Bank
  5.  * by MaTTe (mateo10)
  6.  *
  7.  * Fordította: BBk
  8.  */
  9.  
  10. #define VERSION "1.0"
  11.  
  12. public Plugin:myinfo =
  13. {
  14. name = "SM Bank",
  15. author = "MaTTe",
  16. description = "A jatekos penzt helyezhet el a bankjaban es kiveheti onnan, amikor szuksege van ra",
  17. version = VERSION,
  18. url = "http://www.sourcemod.net/"
  19. };
  20.  
  21. new g_iBank[MAXPLAYERS + 1];
  22. new g_iAccount = -1;
  23.  
  24. public OnPluginStart()
  25. {
  26. CreateConVar("smbank_version", VERSION, "SM Bank Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  27.  
  28. LoadTranslations("plugin.smbank");
  29.  
  30. RegConsoleCmd("deposit", Deposit);
  31. RegConsoleCmd("withdraw", WithDraw);
  32. RegConsoleCmd("bankstatus", BankStatus);
  33.  
  34. g_iAccount = FindSendPropOffs("CCSPlayer", "m_iAccount");
  35.  
  36. HookEvent("round_start", EventRoundStart);
  37. }
  38.  
  39. public OnClientPutInServer(client)
  40. {
  41. g_iBank[client] = 0;
  42. }
  43.  
  44. public EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  45. {
  46. PrintToChatAll("%t", "Available commands", "\x04", "\x01");
  47. }
  48.  
  49. public Action:Deposit(client, args)
  50. {
  51. if(args < 1)
  52. {
  53. PrintToChat(client, "%t", "Deposit usage", "\x04", "\x01");
  54. return Plugin_Handled;
  55. }
  56.  
  57. new String:szCmd[12];
  58. GetCmdArg(1, szCmd, sizeof(szCmd));
  59.  
  60. if(StrEqual(szCmd, "all"))
  61. {
  62. g_iBank[client] += GetMoney(client);
  63. PrintToChat(client, "%t", "Deposit successfully", GetMoney(client), "\x04", "\x01");
  64. SetMoney(client, 0);
  65. }
  66. else
  67. {
  68. new iMoney = StringToInt(szCmd);
  69.  
  70. if(GetMoney(client) < iMoney)
  71. {
  72. PrintToChat(client, "%t", "Deposit not enough money", "\x04", "\x01");
  73. }
  74. else
  75. {
  76. g_iBank[client] += iMoney;
  77. SetMoney(client, GetMoney(client) - iMoney);
  78. PrintToChat(client, "%t", "Deposit successfully", iMoney, "\x04", "\x01");
  79. }
  80. }
  81.  
  82. return Plugin_Handled;
  83. }
  84.  
  85. public Action:WithDraw(client, args)
  86. {
  87. if(args < 1)
  88. {
  89. PrintToChat(client, "%t", "Withdraw usage", "\x04", "\x01");
  90. }
  91.  
  92. new String:szCmd[12];
  93. GetCmdArg(1, szCmd, sizeof(szCmd));
  94.  
  95. if(StrEqual(szCmd, "all"))
  96. {
  97. new iBalance = 16000 - GetMoney(client);
  98.  
  99. if(g_iBank[client] < iBalance)
  100. {
  101. SetMoney(client, GetMoney(client) + g_iBank[client]);
  102. PrintToChat(client, "%t", "Withdraw successfully", g_iBank[client], "\x04", "\x01");
  103. g_iBank[client] = 0;
  104. }
  105. else
  106. {
  107. SetMoney(client, 16000);
  108. PrintToChat(client, "%t", "Withdraw successfully", iBalance, "\x04", "\x01");
  109. g_iBank[client] -= iBalance;
  110. }
  111. }
  112. else
  113. {
  114. new iMoney = StringToInt(szCmd);
  115.  
  116. if(g_iBank[client] < iMoney)
  117. {
  118. PrintToChat(client, "%t", "Withdraw not enough money", "\x04", "\x01");
  119. return Plugin_Handled;
  120. }
  121.  
  122. if(GetMoney(client) + iMoney <= 16000)
  123. {
  124. SetMoney(client, GetMoney(client) + iMoney);
  125. PrintToChat(client, "%t", "Withdraw successfully", iMoney, "\x04", "\x01");
  126. g_iBank[client] -= iMoney;
  127. }
  128. else
  129. {
  130. PrintToChat(client, "%t", "Withdraw max error", "\x04", "\x01");
  131. return Plugin_Handled;
  132. }
  133. }
  134.  
  135. return Plugin_Handled;
  136. }
  137.  
  138. public Action:BankStatus(client, args)
  139. {
  140. PrintToChat(client, "%t", "Bankstatus", g_iBank[client], "\x04", "\x01");
  141. return Plugin_Handled;
  142. }
  143.  
  144. public SetMoney(client, amount)
  145. {
  146. if(g_iAccount != -1)
  147. {
  148. SetEntData(client, g_iAccount, amount);
  149. }
  150. }
  151.  
  152. public GetMoney(client)
  153. {
  154. if(g_iAccount != -1)
  155. {
  156. return GetEntData(client, g_iAccount);
  157. }
  158.  
  159. return 0;
  160. }