Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Added start side to spawn locations
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtko committed Mar 17, 2018
1 parent 83506d7 commit fa1d098
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 59 deletions.
11 changes: 7 additions & 4 deletions addons/sourcemod/scripting/SurfTimer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ int g_WrcpStage[MAXPLAYERS + 1];
bool g_bhasStages;

/*---------- Spawn Locations ----------*/
float g_fSpawnLocation[MAXZONEGROUPS][CPLIMIT][3];
float g_fSpawnAngle[MAXZONEGROUPS][CPLIMIT][3];
float g_fSpawnVelocity[MAXZONEGROUPS][CPLIMIT][3];
bool g_bGotSpawnLocation[MAXZONEGROUPS][CPLIMIT];
float g_fSpawnLocation[MAXZONEGROUPS][CPLIMIT][2][3];
float g_fSpawnAngle[MAXZONEGROUPS][CPLIMIT][2][3];
float g_fSpawnVelocity[MAXZONEGROUPS][CPLIMIT][2][3];
bool g_bGotSpawnLocation[MAXZONEGROUPS][CPLIMIT][2];

/*---------- Bonus Variables ----------*/

Expand Down Expand Up @@ -777,6 +777,9 @@ bool g_bSpecListOnly[MAXPLAYERS + 1];
bool g_bSideHud[MAXPLAYERS + 1];
int g_iSideHudModule[MAXPLAYERS + 1][5];

// Custom tele side
int g_iTeleSide[MAXPLAYERS + 1];

/*---------- Run Variables ----------*/

// Clients personal record in map
Expand Down
Binary file added addons/sourcemod/scripting/surftimer.smx
Binary file not shown.
66 changes: 58 additions & 8 deletions addons/sourcemod/scripting/surftimer/admin.sp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ public Action Admin_insertSpawnLocation(int client, int args)
if (!IsValidClient(client) || !IsPlayerZoner(client))
return Plugin_Handled;

Menu menu = CreateMenu(ChooseTeleSideHandler);
SetMenuTitle(menu, "Choose side for this spawn location");
AddMenuItem(menu, "", "Left");
AddMenuItem(menu, "", "Right");
SetMenuOptionFlags(menu, MENUFLAG_BUTTON_EXIT);
DisplayMenu(menu, client, MENU_TIME_FOREVER);

return Plugin_Handled;
}

public int ChooseTeleSideHandler(Handle menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
InsertSpawnLocation(param1, param2);
else if (action == MenuAction_End)
delete menu;
}

public void InsertSpawnLocation(int client, int teleside)
{
float SpawnLocation[3];
float SpawnAngle[3];
float Velocity[3];
Expand All @@ -95,38 +115,68 @@ public Action Admin_insertSpawnLocation(int client, int args)

SpawnLocation[2] += 3.0;

if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1])
if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1][teleside])
{
db_updateSpawnLocations(SpawnLocation, SpawnAngle, Velocity, g_iClientInZone[client][2]);
db_updateSpawnLocations(SpawnLocation, SpawnAngle, Velocity, g_iClientInZone[client][2], teleside);
CPrintToChat(client, "%t", "Admin7", g_szChatPrefix);
}
else
{
db_insertSpawnLocations(SpawnLocation, SpawnAngle, Velocity, g_iClientInZone[client][2]);
db_insertSpawnLocations(SpawnLocation, SpawnAngle, Velocity, g_iClientInZone[client][2], teleside);
CPrintToChat(client, "%t", "SpawnAdded", g_szChatPrefix);
}

CPrintToChat(client, "%f : %f : %f : %i", SpawnLocation, SpawnAngle, Velocity, g_iClientInZone[client][2]);

return Plugin_Handled;
}

public Action Admin_deleteSpawnLocation(int client, int args)
{
if (!IsValidClient(client) || !IsPlayerZoner(client))
return Plugin_Handled;

if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1])
if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1][0] || g_bGotSpawnLocation[g_iClientInZone[client][2]][1][1])
{
db_deleteSpawnLocations(g_iClientInZone[client][2]);
CPrintToChat(client, "%t", "Admin8", g_szChatPrefix);
Menu menu = CreateMenu(DelSpawnLocationHandler);
SetMenuTitle(menu, "Choose side of spawn location to delete");

if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1][0])
AddMenuItem(menu, "", "Left");
else
AddMenuItem(menu, "", "Left", ITEMDRAW_DISABLED);

if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1][1])
AddMenuItem(menu, "", "Right");
else
AddMenuItem(menu, "", "Right", ITEMDRAW_DISABLED);

SetMenuOptionFlags(menu, MENUFLAG_BUTTON_EXIT);
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
else
CPrintToChat(client, "%t", "Admin9", g_szChatPrefix);

return Plugin_Handled;
}

public int DelSpawnLocationHandler(Handle menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
DelSpawnLocation(param1, param2);
else if (action == MenuAction_End)
delete menu;
}

public void DelSpawnLocation(int client, int teleside)
{
if (g_bGotSpawnLocation[g_iClientInZone[client][2]][1][teleside])
{
db_deleteSpawnLocations(g_iClientInZone[client][2], teleside);
CPrintToChat(client, "%t", "Admin8", g_szChatPrefix);
}
else
CPrintToChat(client, "%t", "Admin9", g_szChatPrefix);
}

public Action Admin_ClearAssists(int client, int args)
{
if (IsPlayerTimerAdmin(client))
Expand Down
29 changes: 24 additions & 5 deletions addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,17 @@ void CenterSpeedDisplay(int client, bool menu = false)
MiscellaneousOptions(client);
}

void TeleSide(int client, bool menu = false)
{
if (g_iTeleSide[client] == 0)
g_iTeleSide[client]++;
else
g_iTeleSide[client] = 0;

if (menu)
MiscellaneousOptions(client);
}

public Action Client_Hide(int client, int args)
{
HideMethod(client);
Expand Down Expand Up @@ -3207,11 +3218,11 @@ public void MiscellaneousOptions(int client)
else
AddMenuItem(menu, "", "[OFF] Timer Sounds");

// Hide Weapon
if (g_bViewModel[client])
AddMenuItem(menu, "", "[OFF] Hide Weapon");
// Tele Side
if (g_iTeleSide[client] == 0)
AddMenuItem(menu, "", "[LEFT] Start Side");
else
AddMenuItem(menu, "", "[ON] Hide Weapon");
AddMenuItem(menu, "", "[RIGHT] Start Side");

// Speed Gradient
if (g_SpeedGradient[client] == 0)
Expand Down Expand Up @@ -3243,6 +3254,13 @@ public void MiscellaneousOptions(int client)
else
AddMenuItem(menu, "", "[OFF] Hide Chat");

// Hide Weapon
if (g_bViewModel[client])
AddMenuItem(menu, "", "[OFF] Hide Weapon");
else
AddMenuItem(menu, "", "[ON] Hide Weapon");


SetMenuExitBackButton(menu, true);
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
Expand All @@ -3255,11 +3273,12 @@ public int MiscellaneousOptionsHandler(Menu menu, MenuAction action, int param1,
{
case 0: HideMethod(param1, true);
case 1: QuakeSounds(param1, true);
case 2: HideViewModel(param1, true);
case 2: TeleSide(param1, true);
case 3: SpeedGradient(param1, true);
case 4: SpeedMode(param1, true);
case 5: CenterSpeedDisplay(param1, true);
case 6: HideChat(param1, true);
case 7: HideViewModel(param1, true);
}
}
else if (action == MenuAction_Cancel)
Expand Down
16 changes: 8 additions & 8 deletions addons/sourcemod/scripting/surftimer/db/queries.sp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ char sql_insertmaptier[] = "INSERT INTO ck_maptier (mapname, tier) VALUES ('%s',
char sql_updatemaptier[] = "UPDATE ck_maptier SET tier = %i WHERE mapname ='%s'";

// ck_playeroptions2
char sql_createPlayerOptions[] = "CREATE TABLE `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', `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', PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8mb4;";
char sql_createPlayerOptions[] = "CREATE TABLE `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', PRIMARY KEY (`steamid`)) DEFAULT CHARSET=utf8mb4;";
char sql_insertPlayerOptions[] = "INSERT INTO ck_playeroptions2 (steamid) VALUES ('%s');";
char sql_selectPlayerOptions[] = "SELECT timer, hide, sounds, chat, viewmodel, autobhop, checkpoints, gradient, speedmode, centrespeed, centrehud, module1c, module2c, module3c, module4c, module5c, module6c, sidehud, module1s, module2s, module3s, module4s, module5s FROM ck_playeroptions2 where steamid = '%s';";
char sql_updatePlayerOptions[] = "UPDATE ck_playeroptions2 SET timer = %i, hide = %i, sounds = %i, chat = %i, viewmodel = %i, autobhop = %i, checkpoints = %i, gradient = %i, speedmode = %i, centrespeed = %i, centrehud = %i, module1c = %i, module2c = %i, module3c = %i, module4c = %i, module5c = %i, module6c = %i, sidehud = %i, module1s = %i, module2s = %i, module3s = %i, module4s = %i, module5s = %i where steamid = '%s'";
char sql_selectPlayerOptions[] = "SELECT timer, hide, sounds, chat, viewmodel, autobhop, checkpoints, gradient, speedmode, centrespeed, centrehud, teleside, module1c, module2c, module3c, module4c, module5c, module6c, sidehud, module1s, module2s, module3s, module4s, module5s FROM ck_playeroptions2 where steamid = '%s';";
char sql_updatePlayerOptions[] = "UPDATE ck_playeroptions2 SET timer = %i, hide = %i, sounds = %i, chat = %i, viewmodel = %i, autobhop = %i, checkpoints = %i, gradient = %i, speedmode = %i, centrespeed = %i, centrehud = %i, teleside = %i, module1c = %i, module2c = %i, module3c = %i, module4c = %i, module5c = %i, module6c = %i, sidehud = %i, module1s = %i, module2s = %i, module3s = %i, module4s = %i, module5s = %i where steamid = '%s'";

// ck_playerrank
char sql_createPlayerRank[] = "CREATE TABLE IF NOT EXISTS `ck_playerrank` (`steamid` varchar(32) NOT NULL DEFAULT '', `steamid64` varchar(64) DEFAULT NULL, `name` varchar(32) DEFAULT NULL, `country` varchar(32) DEFAULT NULL, `points` int(12) DEFAULT '0', `wrpoints` int(12) NOT NULL DEFAULT '0', `wrbpoints` int(12) NOT NULL DEFAULT '0', `wrcppoints` int(11) NOT NULL DEFAULT '0', `top10points` int(12) NOT NULL DEFAULT '0', `groupspoints` int(12) NOT NULL DEFAULT '0', `mappoints` int(11) NOT NULL DEFAULT '0', `bonuspoints` int(12) NOT NULL DEFAULT '0', `finishedmaps` int(12) DEFAULT '0', `finishedmapspro` int(12) DEFAULT '0', `finishedbonuses` int(12) NOT NULL DEFAULT '0', `finishedstages` int(12) NOT NULL DEFAULT '0', `wrs` int(12) NOT NULL DEFAULT '0', `wrbs` int(12) NOT NULL DEFAULT '0', `wrcps` int(12) NOT NULL DEFAULT '0', `top10s` int(12) NOT NULL DEFAULT '0', `groups` int(12) NOT NULL DEFAULT '0', `lastseen` int(64) DEFAULT NULL, `joined` int(64) NOT NULL, `timealive` int(64) NOT NULL DEFAULT '0', `timespec` int(64) NOT NULL DEFAULT '0', `connections` int(64) NOT NULL DEFAULT '1', `readchangelog` int(11) NOT NULL DEFAULT '0', `style` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`steamid`, `style`)) DEFAULT CHARSET=utf8mb4;";
Expand Down Expand Up @@ -91,11 +91,11 @@ char sql_selectPlayerRankProTime[] = "SELECT name,mapname FROM ck_playertimes WH
char sql_selectAllMapTimesinMap[] = "SELECT runtimepro from ck_playertimes WHERE mapname = '%s';";

// ck_spawnlocations
char sql_createSpawnLocations[] = "CREATE TABLE IF NOT EXISTS ck_spawnlocations (mapname VARCHAR(54) NOT NULL, pos_x FLOAT NOT NULL, pos_y FLOAT NOT NULL, pos_z FLOAT NOT NULL, ang_x FLOAT NOT NULL, ang_y FLOAT NOT NULL, ang_z FLOAT NOT NULL, `vel_x` float NOT NULL DEFAULT '0', `vel_y` float NOT NULL DEFAULT '0', `vel_z` float NOT NULL DEFAULT '0', zonegroup INT(12) DEFAULT 0, stage INT(12) DEFAULT 0, PRIMARY KEY(mapname, zonegroup, stage))DEFAULT CHARSET=utf8mb4;";
char sql_insertSpawnLocations[] = "INSERT INTO ck_spawnlocations (mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup) VALUES ('%s', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', %i);";
char sql_updateSpawnLocations[] = "UPDATE ck_spawnlocations SET pos_x = '%f', pos_y = '%f', pos_z = '%f', ang_x = '%f', ang_y = '%f', ang_z = '%f', vel_x = '%f', vel_y = '%f', vel_z = '%f' WHERE mapname = '%s' AND zonegroup = %i";
char sql_selectSpawnLocations[] = "SELECT mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup, stage FROM ck_spawnlocations WHERE mapname ='%s';";
char sql_deleteSpawnLocations[] = "DELETE FROM ck_spawnlocations WHERE mapname = '%s' AND zonegroup = %i AND stage = 1;";
char sql_createSpawnLocations[] = "CREATE TABLE IF NOT EXISTS ck_spawnlocations (mapname VARCHAR(54) NOT NULL, pos_x FLOAT NOT NULL, pos_y FLOAT NOT NULL, pos_z FLOAT NOT NULL, ang_x FLOAT NOT NULL, ang_y FLOAT NOT NULL, ang_z FLOAT NOT NULL, `vel_x` float NOT NULL DEFAULT '0', `vel_y` float NOT NULL DEFAULT '0', `vel_z` float NOT NULL DEFAULT '0', zonegroup INT(12) DEFAULT 0, stage INT(12) DEFAULT 0, teleside INT(11) DEFAULT 0, PRIMARY KEY(mapname, zonegroup, stage, teleside)) DEFAULT CHARSET=utf8mb4;";
char sql_insertSpawnLocations[] = "INSERT INTO ck_spawnlocations (mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup, teleside) VALUES ('%s', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', %i, %i);";
char sql_updateSpawnLocations[] = "UPDATE ck_spawnlocations SET pos_x = '%f', pos_y = '%f', pos_z = '%f', ang_x = '%f', ang_y = '%f', ang_z = '%f', vel_x = '%f', vel_y = '%f', vel_z = '%f' WHERE mapname = '%s' AND zonegroup = %i AND teleside = %i;";
char sql_selectSpawnLocations[] = "SELECT mapname, pos_x, pos_y, pos_z, ang_x, ang_y, ang_z, vel_x, vel_y, vel_z, zonegroup, stage, teleside FROM ck_spawnlocations WHERE mapname ='%s';";
char sql_deleteSpawnLocations[] = "DELETE FROM ck_spawnlocations WHERE mapname = '%s' AND zonegroup = %i AND stage = 1 AND teleside = %i;";

// ck_vipadmins (should rename this table..)
char sql_createVipAdmins[] = "CREATE TABLE `ck_vipadmins` (`steamid` varchar(32) NOT NULL DEFAULT '', `title` varchar(128) DEFAULT '0', `namecolour` int(11) DEFAULT '0', `textcolour` int(11) NOT NULL DEFAULT '0', `joinmsg` varchar(255) DEFAULT 'none', `pbsound` varchar(256) NOT NULL DEFAULT 'none', `topsound` varchar(256) NOT NULL DEFAULT 'none', `wrsound` varchar(256) NOT NULL DEFAULT 'none', `inuse` int(11) DEFAULT '0', `vip` int(11) DEFAULT '0', `admin` int(11) NOT NULL DEFAULT '0', `zoner` int(11) NOT NULL DEFAULT '0', `active` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`steamid`), KEY `vip` (`steamid`,`vip`,`admin`,`zoner`)) DEFAULT CHARSET=utf8mb4;";
Expand Down
9 changes: 6 additions & 3 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime)
realZone = 0;
else
realZone = zone;

// Check clients tele side
int teleside = g_iTeleSide[client];

if (g_bStartposUsed[client][zonegroup])
{
Expand Down Expand Up @@ -222,7 +225,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime)
return;
}
}
else if (g_bGotSpawnLocation[zonegroup][realZone])
else if (g_bGotSpawnLocation[zonegroup][realZone][teleside])
{
// Check if teleporting to bonus
if (zonegroup > 0)
Expand All @@ -242,7 +245,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime)
if (stopTime)
Client_Stop(client, 0);

Array_Copy(g_fSpawnLocation[zonegroup][realZone], g_fTeleLocation[client], 3);
Array_Copy(g_fSpawnLocation[zonegroup][realZone][teleside], g_fTeleLocation[client], 3);

g_specToStage[client] = true;
g_bRespawnPosition[client] = false;
Expand All @@ -265,7 +268,7 @@ public void teleportClient(int client, int zonegroup, int zone, bool stopTime)
g_bInStageZone[client] = false;
}

teleportEntitySafe(client, g_fSpawnLocation[zonegroup][realZone], g_fSpawnAngle[zonegroup][realZone], g_fSpawnVelocity[zonegroup][realZone], stopTime);
teleportEntitySafe(client, g_fSpawnLocation[zonegroup][realZone][teleside], g_fSpawnAngle[zonegroup][realZone][teleside], g_fSpawnVelocity[zonegroup][realZone][teleside], stopTime);

return;
}
Expand Down
Loading

0 comments on commit fa1d098

Please sign in to comment.