Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- //////////////////////////////
- // DEFINITIONS //
- //////////////////////////////
- #define PLUGIN_NAME "Store - Credits Multiplier"
- #define PLUGIN_AUTHOR "Zephyrus"
- #define PLUGIN_DESCRIPTION "A plugin that manages credits multiplying based on player number."
- #define PLUGIN_VERSION "1.0"
- #define PLUGIN_URL ""
- //////////////////////////////
- // INCLUDES //
- //////////////////////////////
- #include <sourcemod>
- #undef REQUIRE_EXTENSIONS
- #include <zephstocks>
- //////////////////////////////
- // ENUMS //
- //////////////////////////////
- enum StoreMultiplier
- {
- unMaxPlayers,
- Float:flMultiplier,
- }
- //////////////////////////////////
- // GLOBAL VARIABLES //
- //////////////////////////////////
- new g_eMultipliers[MAXPLAYERS][StoreMultiplier];
- new g_iMultipliers = 0;
- new g_iDefaultCredits = 0;
- new g_cvarCredits = -1;
- //////////////////////////////
- // MODULES //
- //////////////////////////////
- //////////////////////////////////
- // PLUGIN DEFINITION //
- //////////////////////////////////
- public Plugin:myinfo =
- {
- name = PLUGIN_NAME,
- author = PLUGIN_AUTHOR,
- description = PLUGIN_DESCRIPTION,
- version = PLUGIN_VERSION,
- url = PLUGIN_URL
- };
- //////////////////////////////
- // PLUGIN FORWARDS //
- //////////////////////////////
- public OnPluginStart()
- {
- IdentifyGame();
- // Supress warnings about unused variables.....
- if(g_bL4D || g_bL4D2 || g_bND) {}
- AutoExecConfig();
- RegServerCmd("sm_store_multiplier_add", Command_AddMultiplier);
- }
- public OnMapEnd()
- {
- SetConVarInt(g_eCvars[g_cvarCredits][hCvar], g_iDefaultCredits);
- }
- public OnMapStart()
- {
- g_iDefaultCredits = g_eCvars[g_cvarCredits][aCache];
- g_iMultipliers=0;
- }
- public OnAllPluginsLoaded()
- {
- g_cvarCredits = HookConVar("sm_store_credit_amount_active", TYPE_INT);
- }
- public OnAutoConfigsBuffered()
- {
- CreateTimer(1.0, Timer_CalculateMultiplier, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
- }
- //////////////////////////////
- // TIMERS //
- //////////////////////////////
- public Action:Timer_CalculateMultiplier(Handle:timer, any:data)
- {
- new m_iPlayers = GetClientCount();
- new m_iLastPlayers = MaxClients+1;
- new m_iCurrent = -1;
- for(new i=0;i<g_iMultipliers;++i)
- {
- if(g_eMultipliers[i][unMaxPlayers]>m_iPlayers && g_eMultipliers[i][unMaxPlayers]<m_iLastPlayers)
- {
- m_iCurrent = i;
- m_iLastPlayers = g_eMultipliers[i][unMaxPlayers];
- }
- }
- if(m_iCurrent == -1)
- SetConVarInt(g_eCvars[g_cvarCredits][hCvar], g_iDefaultCredits);
- else
- SetConVarInt(g_eCvars[g_cvarCredits][hCvar], RoundFloat(g_iDefaultCredits*g_eMultipliers[m_iCurrent][flMultiplier]));
- return Plugin_Handled;
- }
- //////////////////////////////
- // COMMANDS //
- //////////////////////////////
- public Action:Command_AddMultiplier(args)
- {
- // Bail out if the parameter count doesn't match
- if(args != 2)
- {
- PrintToServer("Usage: sm_store_multiplier_add <max players> <multiplier>");
- return Plugin_Handled;
- }
- // Initialize variables
- new String:m_szPlayers[64];
- new String:m_szMultiplier[64];
- // Get all parameters
- GetCmdArg(1, STRING(m_szPlayers));
- GetCmdArg(2, STRING(m_szMultiplier));
- g_eMultipliers[g_iMultipliers][unMaxPlayers] = StringToInt(m_szPlayers);
- g_eMultipliers[g_iMultipliers][flMultiplier] = StringToFloat(m_szMultiplier);
- ++g_iMultipliers;
- return Plugin_Handled;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement