Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <morecolors>
- #include <clientprefs>
- #pragma semicolon 1
- new Handle:guardCookie;
- new Handle:cvarTimeRequired;
- new bool:canUseGuard[MAXPLAYERS + 1];
- public Plugin:myinfo =
- {
- name = "Guard Timer",
- author = "Bleed",
- description = "Forces people to play for 1 hour before using the guard queue",
- version = "0.1",
- url = "www.xenogamers.org"
- };
- public OnPluginStart()
- {
- AddCommandListener(Command_Guard, "sm_guard");
- guardCookie = RegClientCookie("clientPlayTime", "Holds the amount of time a client has played", CookieAccess_Private);
- CreateTimer(60.0, Timer_MinutePassed, _, TIMER_REPEAT);
- cvarTimeRequired = CreateConVar("sm_guardqueue_timerequired", "60", "Time in minutes required for people to play as CT");
- }
- public OnClientCookiesCached(client)
- {
- decl String:cookie[32];
- GetClientCookie(client, guardCookie, cookie, sizeof(cookie));
- if(cookie[0] == '\0')
- {
- SetClientCookie(client, guardCookie, "0");
- Format(cookie, sizeof(cookie), "0");
- }
- canUseGuard[client] = StringToInt(cookie) >= GetConVarInt(cvarTimeRequired);
- }
- public Action:Command_Guard(client, const String:command[], args)
- {
- if(canUseGuard[client])
- return Plugin_Continue;
- decl String:cookie[32];
- GetClientCookie(client, guardCookie, cookie, sizeof(cookie) );
- new timeRemaining = GetConVarInt(cvarTimeRequired) - StringToInt(cookie);
- CReplyToCommand(client, "{GREEN}[xG] {BLUE}you must have played for %i minutes before you can join the guard queue!\n{GREEN}[xG] {BLUE}You have %i minutes remaining.",GetConVarInt(cvarTimeRequired), timeRemaining);
- return Plugin_Handled;
- }
- public Action:Timer_MinutePassed(Handle:timer)
- {
- decl String:cookie[32];
- new timeRequired = GetConVarInt(cvarTimeRequired);
- for(new i = 1; i < MaxClients;i++)
- {
- if(IsClientInGame(i) && !IsFakeClient(i))
- {
- GetClientCookie(i, guardCookie, cookie, sizeof(cookie));
- if(StringToInt(cookie) == timeRequired)
- {
- CPrintToChat(i, "{GREEN}[xG] {BLUE}You can now use the guard queue. Type !guard to join the queue.");
- canUseGuard[i] = true;
- }
- Format(cookie, sizeof(cookie), "%i", StringToInt(cookie) + 1);
- SetClientCookie(i, guardCookie, cookie);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment