Skip to content

Commit

Permalink
add mapper names to ck_maptier (#538)
Browse files Browse the repository at this point in the history
* add mapper names to ck_maptier

* use translation
  • Loading branch information
dPexxIAM authored Nov 14, 2022
1 parent 7bc45c1 commit dcc3080
Show file tree
Hide file tree
Showing 7 changed files with 1,523 additions and 3 deletions.
27 changes: 27 additions & 0 deletions addons/sourcemod/scripting/surftimer/admin.sp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,33 @@ public int TopMenuHandler2(Handle topmenu, TopMenuAction action, TopMenuObject o
return 0;
}

public Action Admin_insertMapperName(int client, int args)
{
if (!IsValidClient(client))
return Plugin_Handled;

if (!IsPlayerZoner(client))
{
CReplyToCommand(client, "%t", "AdminMapperName", g_szChatPrefix);
return Plugin_Handled;
}

if (args == 0)
{
CReplyToCommand(client, "%t", "MapperNameUsage", g_szChatPrefix);
return Plugin_Handled;
}
else
{
char arg1[64];
//char sMapperName[64];
GetCmdArgString(arg1, sizeof(arg1));

db_insertMapperName(client, arg1);
}
return Plugin_Handled;
}

public Action Admin_insertMapTier(int client, int args)
{
if (!IsValidClient(client))
Expand Down
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ void CreateCommands()
RegConsoleCmd("sm_hookzone", Command_HookZones, "[surftimer] [zoner] Opens up zone hook creation menu.");
RegConsoleCmd("sm_addmaptier", Admin_insertMapTier, "[surftimer] [zoner] Changes maps tier");
RegConsoleCmd("sm_amt", Admin_insertMapTier, "[surftimer] [zoner] Changes maps tier");
RegConsoleCmd("sm_amn", Admin_insertMapperName, "[surftimer] [zoner] Adds mapper name to DB.");
RegConsoleCmd("sm_addmappername", Admin_insertMapperName, "[surftimer] [zoner] Adds mapper name to DB.");
RegConsoleCmd("sm_addspawn", Admin_insertSpawnLocation, "[surftimer] [zoner] Changes the position !r takes players to");
RegConsoleCmd("sm_delspawn", Admin_deleteSpawnLocation, "[surftimer] [zoner] Removes custom !r position");
RegConsoleCmd("sm_mapsettings", Admin_MapSettings, "[surftimer] [zoner] Displays menu containing various options to change map settings");
Expand Down
3 changes: 2 additions & 1 deletion addons/sourcemod/scripting/surftimer/db/queries.sp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ char sql_selectLatestRecords[] = "SELECT name, runtime, map, date FROM ck_latest

// ck_maptier
char sql_createMapTier[] = "CREATE TABLE IF NOT EXISTS ck_maptier (mapname VARCHAR(54) NOT NULL, tier INT(12), maxvelocity FLOAT NOT NULL DEFAULT '3500.0', announcerecord INT(11) NOT NULL DEFAULT '0', gravityfix INT(11) NOT NULL DEFAULT '1', ranked INT(11) NOT NULL DEFAULT '1', PRIMARY KEY(mapname)) DEFAULT CHARSET=utf8mb4;";
char sql_selectMapTier[] = "SELECT tier, ranked FROM ck_maptier WHERE mapname = '%s'";
char sql_selectMapTier[] = "SELECT tier, ranked, mapper FROM ck_maptier WHERE mapname = '%s'";
char sql_insertmaptier[] = "INSERT INTO ck_maptier (mapname, tier) VALUES ('%s', '%i');";
char sql_updatemaptier[] = "UPDATE ck_maptier SET tier = %i WHERE mapname ='%s'";
char sql_updateMapperName[] = "UPDATE ck_maptier SET mapper = '%s' WHERE mapname = '%s'";

// ck_playeroptions2
char sql_createPlayerOptions[] = "CREATE TABLE IF NOT EXISTS `ck_playeroptions2` (`steamid` varchar(32) NOT NULL DEFAULT '', `timer` int(11) NOT NULL DEFAULT '1', `hide` int(11) NOT NULL DEFAULT '0', `sounds` int(11) NOT NULL DEFAULT '1', `chat` int(11) NOT NULL DEFAULT '0', `viewmodel` int(11) NOT NULL DEFAULT '1', `autobhop` int(11) NOT NULL DEFAULT '1', `checkpoints` int(11) NOT NULL DEFAULT '1', `gradient` int(11) NOT NULL DEFAULT '3', `speedmode` int(11) NOT NULL DEFAULT '0', `centrespeed` int(11) NOT NULL DEFAULT '0', `centrehud` int(11) NOT NULL DEFAULT '1', teleside int(11) NOT NULL DEFAULT '0', `module1c` int(11) NOT NULL DEFAULT '1', `module2c` int(11) NOT NULL DEFAULT '2', `module3c` int(11) NOT NULL DEFAULT '3', `module4c` int(11) NOT NULL DEFAULT '4', `module5c` int(11) NOT NULL DEFAULT '5', `module6c` int(11) NOT NULL DEFAULT '6', `sidehud` int(11) NOT NULL DEFAULT '1', `module1s` int(11) NOT NULL DEFAULT '5', `module2s` int(11) NOT NULL DEFAULT '0', `module3s` int(11) NOT NULL DEFAULT '0', `module4s` int(11) NOT NULL DEFAULT '0', `module5s` int(11) NOT NULL DEFAULT '0', prestrafe int(11) NOT NULL DEFAULT '0', cpmessages int(11) NOT NULL DEFAULT '1', wrcpmessages int(11) NOT NULL DEFAULT '1', hints int(11) NOT NULL DEFAULT '1', csd_update_rate int(11) NOT NULL DEFAULT '1' , csd_pos_x float(11) NOT NULL DEFAULT '0.5' , csd_pos_y float(11) NOT NULL DEFAULT '0.3' , csd_r int(11) NOT NULL DEFAULT '255', csd_g int(11) NOT NULL DEFAULT '255', csd_b int(11) NOT NULL DEFAULT '255', PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8mb4;";
Expand Down
6 changes: 6 additions & 0 deletions addons/sourcemod/scripting/surftimer/globals.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,12 @@ char g_szCountry[MAXPLAYERS + 1][100];
char g_szCountryCode[MAXPLAYERS + 1][3];
char g_szContinentCode[MAXPLAYERS + 1][3];

// mappers name
char g_szMapperName[32];

// mapper name null?
bool g_bMapperNameFound;

// Client's steamID
char g_szSteamID[MAXPLAYERS + 1][32];

Expand Down
58 changes: 56 additions & 2 deletions addons/sourcemod/scripting/surftimer/sql.sp
Original file line number Diff line number Diff line change
Expand Up @@ -4041,6 +4041,40 @@ public void db_UpdatePRinfo(int client, char szSteamID[32], int zGroup)
= MAPTIER =
===================================*/

public void db_insertMapperName(int client, char arg1[64])
{
char szQuery[256];

if (!g_bTierEntryFound)
{
CReplyToCommand(client, "%t", "NoTierEntry", g_szChatPrefix);
return;
}
if (g_bMapperNameFound)
{
CReplyToCommand(client, "%t", "UpdateMapperName", g_szChatPrefix, arg1);
Format(szQuery, sizeof(szQuery), sql_updateMapperName, arg1, g_szMapName);
SQL_TQuery(g_hDb, db_insertMapperNameCallback, szQuery, 1, DBPrio_Low);
}
else
{
CReplyToCommand(client, "%t", "InsertMapperName", g_szChatPrefix, arg1);
Format(szQuery, sizeof(szQuery), sql_updateMapperName, arg1, g_szMapName);
SQL_TQuery(g_hDb, db_insertMapperNameCallback, szQuery, 1, DBPrio_Low);
}
}

public void db_insertMapperNameCallback(Handle owner, Handle hndl, const char[] error, any data)
{
if (hndl == null)
{
LogError("[Surftimer] SQL Error (db_insertMapperNameCallback): %s", error);
return;
}

db_selectMapTier();
}

public void db_insertMapTier(int tier)
{
char szQuery[256];
Expand Down Expand Up @@ -4143,11 +4177,31 @@ public void SQL_selectMapTierCallback(Handle owner, Handle hndl, const char[] er
// Format tier string
tier = SQL_FetchInt(hndl, 0);
g_bRankedMap = view_as<bool>(SQL_FetchInt(hndl, 1));

if (SQL_IsFieldNull(hndl, 2))
{
g_szMapperName = "N/A";
g_bMapperNameFound = false;
}
else
{
SQL_FetchString(hndl, 2, g_szMapperName, sizeof(g_szMapperName));
g_bMapperNameFound = true;
}

if (0 < tier < 9)
{
g_bTierFound = true;
g_iMapTier = tier;
Format(g_sTierString, 512, "%c%s %c- ", BLUE, g_szMapName, WHITE);
if (g_bMapperNameFound)
{
Format(g_sTierString, 512, "%c%s \x01by \x03%s %c- ", BLUE, g_szMapName, g_szMapperName, WHITE);
}
else
{
Format(g_sTierString, 512, "%c%s %c- ", BLUE, g_szMapName, WHITE);
}

switch (tier)
{
case 1:Format(g_sTierString, 512, "%s%cTier %i %c- ", g_sTierString, GRAY, tier, WHITE);
Expand Down Expand Up @@ -9223,7 +9277,7 @@ public void db_selectMapImprovementCallback(Handle owner, Handle hndl, const cha
if (type == 0)
{
Menu mi = CreateMenu(MapImprovementMenuHandler);
SetMenuTitle(mi, "[Point Reward: %s]\n------------------------------\nTier: %i\n \n[Completion Points]\n \nMap Finish Points: %i\n \n[Map Improvement Groups]\n \n[Group 1] Ranks 11-%i ~ %i Pts\n[Group 2] Ranks %i-%i ~ %i Pts\n[Group 3] Ranks %i-%i ~ %i Pts\n[Group 4] Ranks %i-%i ~ %i Pts\n[Group 5] Ranks %i-%i ~ %i Pts\n \nSR Pts: %i\n \nTotal Completions: %i\n \n",szMapName, tier, mapcompletion, g1top, RoundFloat(g1points), g2bot, g2top, RoundFloat(g2points), g3bot, g3top, RoundFloat(g3points), g4bot, g4top, RoundFloat(g4points), g5bot, g5top, RoundFloat(g5points), iwrpoints, totalplayers);
SetMenuTitle(mi, "[Point Reward: %s]\n------------------------------\nTier: %i\n \nMapper: %s\n \n[Completion Points]\n \nMap Finish Points: %i\n \n[Map Improvement Groups]\n \n[Group 1] Ranks 11-%i ~ %i Pts\n[Group 2] Ranks %i-%i ~ %i Pts\n[Group 3] Ranks %i-%i ~ %i Pts\n[Group 4] Ranks %i-%i ~ %i Pts\n[Group 5] Ranks %i-%i ~ %i Pts\n \nSR Pts: %i\n \nTotal Completions: %i\n \n",szMapName, tier, mapcompletion, g1top, RoundFloat(g1points), g2bot, g2top, RoundFloat(g2points), g3bot, g3top, RoundFloat(g3points), g4bot, g4top, RoundFloat(g4points), g5bot, g5top, RoundFloat(g5points), iwrpoints, totalplayers);

This comment has been minimized.

Copy link
@tslashd

tslashd Dec 27, 2022

Member

just compiled dev

/mi > [SM] Exception reported: String formatted incorrectly - parameter 22 (total 21)

This comment has been minimized.

Copy link
@tslashd

tslashd Dec 27, 2022

Member

#547 fixes this

// AddMenuItem(mi, "", "", ITEMDRAW_SPACER);
AddMenuItem(mi, szMapName, "Top 10 Points");
SetMenuOptionFlags(mi, MENUFLAG_BUTTON_EXIT);
Expand Down
20 changes: 20 additions & 0 deletions addons/sourcemod/translations/surftimer.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,26 @@
"#format" "{1:s}"
"en" "{1} Usage: sm_addmaptier <Tier>"
}
"NoTierEntry"
{
"#format" "{1:s}"
"en" "{1} Tier entry not found. Use sm_addmaptier <Tier> to add a tier first."
}
"UpdateMapperName"
{
"#format" "{1:s},{2:s}"
"en" "{1} Mapper name already exists, updating to: {2}"
}
"InsertMapperName"
{
"#format" "{1:s},{2:s}"
"en" "{1} Setting mapper name to: {2}"
}
"MapperNameUsage"
{
"#format" "{1:s}"
"en" "{1} Usage: sm_addmappername <String>"
}
"Admin6"
{
"#format" "{1:s}"
Expand Down
Loading

0 comments on commit dcc3080

Please sign in to comment.