Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. //////////////////////////////
  4. // DEFINITIONS //
  5. //////////////////////////////
  6.  
  7. #define PLUGIN_NAME "Store - Credits Multiplier"
  8. #define PLUGIN_AUTHOR "Zephyrus"
  9. #define PLUGIN_DESCRIPTION "A plugin that manages credits multiplying based on player number."
  10. #define PLUGIN_VERSION "1.0"
  11. #define PLUGIN_URL ""
  12.  
  13. //////////////////////////////
  14. // INCLUDES //
  15. //////////////////////////////
  16.  
  17. #include <sourcemod>
  18.  
  19. #undef REQUIRE_EXTENSIONS
  20. #include <zephstocks>
  21.  
  22. //////////////////////////////
  23. // ENUMS //
  24. //////////////////////////////
  25.  
  26. enum StoreMultiplier
  27. {
  28. unMaxPlayers,
  29. Float:flMultiplier,
  30. }
  31.  
  32. //////////////////////////////////
  33. // GLOBAL VARIABLES //
  34. //////////////////////////////////
  35.  
  36. new g_eMultipliers[MAXPLAYERS][StoreMultiplier];
  37. new g_iMultipliers = 0;
  38. new g_iDefaultCredits = 0;
  39. new g_cvarCredits = -1;
  40.  
  41. //////////////////////////////
  42. // MODULES //
  43. //////////////////////////////
  44.  
  45. //////////////////////////////////
  46. // PLUGIN DEFINITION //
  47. //////////////////////////////////
  48.  
  49. public Plugin:myinfo =
  50. {
  51. name = PLUGIN_NAME,
  52. author = PLUGIN_AUTHOR,
  53. description = PLUGIN_DESCRIPTION,
  54. version = PLUGIN_VERSION,
  55. url = PLUGIN_URL
  56. };
  57.  
  58. //////////////////////////////
  59. // PLUGIN FORWARDS //
  60. //////////////////////////////
  61.  
  62. public OnPluginStart()
  63. {
  64. IdentifyGame();
  65.  
  66. // Supress warnings about unused variables.....
  67. if(g_bL4D || g_bL4D2 || g_bND) {}
  68.  
  69. AutoExecConfig();
  70.  
  71. RegServerCmd("sm_store_multiplier_add", Command_AddMultiplier);
  72. }
  73.  
  74. public OnMapEnd()
  75. {
  76. SetConVarInt(g_eCvars[g_cvarCredits][hCvar], g_iDefaultCredits);
  77. }
  78.  
  79. public OnMapStart()
  80. {
  81. g_iDefaultCredits = g_eCvars[g_cvarCredits][aCache];
  82. g_iMultipliers=0;
  83. }
  84.  
  85. public OnAllPluginsLoaded()
  86. {
  87. g_cvarCredits = HookConVar("sm_store_credit_amount_active", TYPE_INT);
  88. }
  89.  
  90. public OnAutoConfigsBuffered()
  91. {
  92. CreateTimer(1.0, Timer_CalculateMultiplier, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
  93. }
  94.  
  95. //////////////////////////////
  96. // TIMERS //
  97. //////////////////////////////
  98.  
  99. public Action:Timer_CalculateMultiplier(Handle:timer, any:data)
  100. {
  101. new m_iPlayers = GetClientCount();
  102.  
  103. new m_iLastPlayers = MaxClients+1;
  104. new m_iCurrent = -1;
  105. for(new i=0;i<g_iMultipliers;++i)
  106. {
  107. if(g_eMultipliers[i][unMaxPlayers]>m_iPlayers && g_eMultipliers[i][unMaxPlayers]<m_iLastPlayers)
  108. {
  109. m_iCurrent = i;
  110. m_iLastPlayers = g_eMultipliers[i][unMaxPlayers];
  111. }
  112. }
  113.  
  114. if(m_iCurrent == -1)
  115. SetConVarInt(g_eCvars[g_cvarCredits][hCvar], g_iDefaultCredits);
  116. else
  117. SetConVarInt(g_eCvars[g_cvarCredits][hCvar], RoundFloat(g_iDefaultCredits*g_eMultipliers[m_iCurrent][flMultiplier]));
  118.  
  119. return Plugin_Handled;
  120. }
  121.  
  122. //////////////////////////////
  123. // COMMANDS //
  124. //////////////////////////////
  125.  
  126. public Action:Command_AddMultiplier(args)
  127. {
  128. // Bail out if the parameter count doesn't match
  129. if(args != 2)
  130. {
  131. PrintToServer("Usage: sm_store_multiplier_add <max players> <multiplier>");
  132. return Plugin_Handled;
  133. }
  134.  
  135. // Initialize variables
  136. new String:m_szPlayers[64];
  137. new String:m_szMultiplier[64];
  138.  
  139. // Get all parameters
  140. GetCmdArg(1, STRING(m_szPlayers));
  141. GetCmdArg(2, STRING(m_szMultiplier));
  142.  
  143. g_eMultipliers[g_iMultipliers][unMaxPlayers] = StringToInt(m_szPlayers);
  144. g_eMultipliers[g_iMultipliers][flMultiplier] = StringToFloat(m_szMultiplier);
  145.  
  146. ++g_iMultipliers;
  147.  
  148. return Plugin_Handled;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement