Skip to content

Commit

Permalink
Add cvar for guns menu on first connect. Resolves issue 19.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Jul 19, 2014
1 parent 09a840e commit f49dc40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions csgo/addons/sourcemod/scripting/multi1v1.sp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ new Handle:g_hStatsWebsite = INVALID_HANDLE;
new Handle:g_hAutoUpdate = INVALID_HANDLE;
new Handle:g_hRecordTimes = INVALID_HANDLE;
new Handle:g_hVersion = INVALID_HANDLE;
new Handle:g_hGunsMenuOnFirstConnct = INVALID_HANDLE;

/** Saved data for database interaction - be careful when using these, they may not
* be fetched, check multi1v1/stats.sp for a function that checks that instead of
Expand All @@ -57,6 +58,7 @@ new bool:g_PluginTeamSwitch[MAXPLAYERS+1] = false; // Flags the teamswitches as
new bool:g_AllowAWP[MAXPLAYERS+1];
new bool:g_AllowPistol[MAXPLAYERS+1];
new bool:g_GiveFlash[MAXPLAYERS+1];
new bool:g_GunsSelected[MAXPLAYERS+1];
new RoundType:g_Preference[MAXPLAYERS+1];
new String:g_PrimaryWeapon[MAXPLAYERS+1][WEAPON_LENGTH];
new String:g_SecondaryWeapon[MAXPLAYERS+1][WEAPON_LENGTH];
Expand Down Expand Up @@ -137,6 +139,7 @@ public OnPluginStart() {
g_hRecordTimes = CreateConVar("sm_multi1v1_record_times", "0", "Should the lastTime field store when players connect?");
g_hStatsWebsite = CreateConVar("sm_multi1v1_stats_url", "", "URL to send player stats to. For example: http://csgo1v1.splewis.net/redirect_stats/. The accountID is appened to this url for each player.");
g_hAutoUpdate = CreateConVar("sm_multi1v1_autoupdate", "0", "Should the plugin attempt to use the auto-update plugin?");
g_hGunsMenuOnFirstConnct = CreateConVar("sm_multi1v1_guns_menu_first_connect", "0", "Should players see the guns menu automatically on their first connect?");

/** Config file **/
AutoExecConfig(true, "multi1v1", "sourcemod/multi1v1");
Expand Down Expand Up @@ -761,12 +764,17 @@ public AddPlayer(client) {
if (valid && space && !alreadyin) {
Queue_Enqueue(g_RankingQueue, client);
}

if (GetConVarInt(g_hGunsMenuOnFirstConnct) != 0 && valid && !g_GunsSelected[client]) {
GiveWeaponMenu(client);
}
}

/**
* Resets all client variables to their default.
*/
public ResetClientVariables(client) {
g_GunsSelected[client] = false;
g_roundsPlayed[client] = 0;
g_roundsLeader[client] = 0;
g_ratings[client] = 0.0;
Expand Down
11 changes: 8 additions & 3 deletions csgo/addons/sourcemod/scripting/multi1v1/weaponmenu.sp
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ public MenuHandler_Pistol(Handle:menu, MenuAction:action, param1, param2) {
public PreferenceMenu(client) {
new Handle:menu = CreateMenu(MenuHandler_Preference);
SetMenuTitle(menu, "Choose your preference:");
AddMenuInt(menu, RoundType_NoPreference, "No Preference");
AddMenuInt(menu, RoundType_Rifle, "Rifle Rounds");
if (g_AllowAWP[client])
AddMenuInt(menu, RoundType_Awp, "AWP Rounds");
if (g_AllowPistol[client])
AddMenuInt(menu, RoundType_Pistol, "Pistol Rounds");
AddMenuInt(menu, RoundType_NoPreference, "No Preference");

DisplayMenu(menu, client, MENU_TIME_LENGTH);
}

Expand Down Expand Up @@ -247,19 +246,25 @@ public MenuHandler_FlashChoice(Handle:menu, MenuAction:action, param1, param2) {
new bool:choice = GetMenuBool(menu, param2);
g_GiveFlash[client] = choice;
SetCookieBool(client, g_hFlashCookie, choice);
SetCookieBool(client, g_hSetCookies, true);
FinishGunsMenu(client);
} else if (action == MenuAction_End) {
CloseHandle(menu);
}
}

public FinishGunsMenu(client) {
SetCookieBool(client, g_hSetCookies, true);
g_GunsSelected[client] = true;
}

/**
* Sets all the weapon choices based on the client's cookies.
*/
public UpdatePreferencesOnCookies(client) {
if (!GetCookieBool(client, g_hSetCookies))
return;

g_GunsSelected[client] = true;
g_AllowAWP[client] = GetCookieBool(client, g_hAllowAWPCookie);
g_AllowPistol[client] = GetCookieBool(client, g_hAllowPistolCookie);
g_Preference[client] = RoundType:GetCookieInt(client, g_hPreferenceCookie);
Expand Down

0 comments on commit f49dc40

Please sign in to comment.