diff --git a/README.md b/README.md index 148e3d48..5c4128e8 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,8 @@ Chat **(NEW!)** Zones -- +- [x] Add teleport zones (multiple). - [ ] Use string explosion in ZoneAdjuster_Handler and ZoneEdge_Handler for code efficiency. -- [ ] Migrate zone settings to use Dynamic. - [ ] Make zones be trigger-based for high-performance. Also remove InsideZone() and use booleans instead (OnStartTouch/OnEndTouch). +- [ ] Migrate zone settings to use Dynamic. +- [ ] Handle teleport zones once everything is done. (teleport to a value from gV_Teleport) diff --git a/scripting/include/shavit.inc b/scripting/include/shavit.inc index f62891da..e53f47c2 100644 --- a/scripting/include/shavit.inc +++ b/scripting/include/shavit.inc @@ -30,7 +30,7 @@ #define PREFIX "\x04[Timer]\x01" #define MAX_STYLES 6 -#define MAX_ZONES 7 +#define MAX_ZONES 8 // game types enum ServerGame(+=1) @@ -214,7 +214,8 @@ enum MapZones(+=1) Zone_Stop, Zone_Slay, Zone_Freestyle, - Zone_NoVelLimit + Zone_NoVelLimit, + Zone_Teleport }; // let's not throw errors k? diff --git a/scripting/shavit-zones.sp b/scripting/shavit-zones.sp index e6e4c82a..89f45d13 100644 --- a/scripting/shavit-zones.sp +++ b/scripting/shavit-zones.sp @@ -46,7 +46,8 @@ char gS_ZoneNames[MAX_ZONES][] = "Glitch Zone (Stop Timer)", // stops the player's timer "Slay Player", // slays (kills) players which come to this zone "Freestyle Zone", // ignores style physics when at this zone. e.g. WASD when SWing - "No Speed Limit" // ignores velocity limit in that zone + "No Speed Limit", // ignores velocity limit in that zone + "Teleport Zone" // teleports to a defined point }; MapZones gMZ_Type[MAXPLAYERS+1]; @@ -62,6 +63,7 @@ float gF_Modifier[MAXPLAYERS+1]; // I suck float gV_Point1[MAXPLAYERS+1][3]; float gV_Point2[MAXPLAYERS+1][3]; +float gV_Teleport[MAXPLAYERS+1][3]; bool gB_Button[MAXPLAYERS+1]; @@ -147,6 +149,7 @@ public void OnAllPluginsLoaded() public void OnPluginStart() { RegAdminCmd("sm_modifier", Command_Modifier, ADMFLAG_RCON, "Changes the axis modifier for the zone editor. Usage: sm_modifier "); + RegAdminCmd("sm_tpzone", Command_TPZone, ADMFLAG_RCON, "Defines the teleport zone so it teleports to the location you are in."); // menu RegAdminCmd("sm_zones", Command_Zones, ADMFLAG_RCON, "Opens the mapzones menu"); @@ -277,7 +280,7 @@ public int Native_InsideZone(Handle handler, int numParams) int client = GetNativeCell(1); MapZones type = GetNativeCell(2); - if(type == Zone_Freestyle || type == Zone_NoVelLimit) + if(type >= Zone_Freestyle) { for(int i = 0; i < MULTIPLEZONES_LIMIT; i++) { @@ -310,6 +313,7 @@ public void SetupColors() gI_Colors[Zone_Respawn] = {255, 200, 0, 255}; gI_Colors[Zone_Stop] = {255, 200, 0, 255}; gI_Colors[Zone_Slay] = {255, 200, 0, 255}; + gI_Colors[Zone_Teleport] = {255, 200, 0, 255}; // freestyle zones - blue gI_Colors[Zone_Freestyle] = {25, 25, 255, 195}; @@ -370,7 +374,7 @@ public void UnloadZones(int zone) return; } - if(zone != view_as(Zone_Freestyle) || zone != view_as(Zone_NoVelLimit)) + if(zone < view_as(Zone_Freestyle)) { for(int i = 0; i < 3; i++) { @@ -423,7 +427,7 @@ public void SQL_RefreshZones_Callback(Database db, DBResultSet results, const ch { MapZones type = view_as(results.FetchInt(0)); - if(type == Zone_Freestyle || type == Zone_NoVelLimit) + if(type >= Zone_Freestyle) { gV_FreestyleZones[iFreestyleRow][0][0] = results.FetchFloat(1); gV_FreestyleZones[iFreestyleRow][0][1] = results.FetchFloat(2); @@ -523,6 +527,27 @@ public Action Command_Modifier(int client, int args) return Plugin_Handled; } +public Action Command_TPZone(int client, int args) +{ + if(!IsValidClient(client)) + { + return Plugin_Handled; + } + + if(!IsPlayerAlive(client)) + { + Shavit_PrintToChat(client, "You have to be alive in order to use this command."); + + return Plugin_Handled; + } + + GetClientAbsOrigin(client, gV_Teleport[client]); + + Shavit_PrintToChat(client, "Teleport zone destination updated."); + + return Plugin_Handled; +} + public Action Command_Zones(int client, int args) { if(!IsValidClient(client)) @@ -569,7 +594,7 @@ public Action Command_DeleteZone(int client, int args) for(int i = 0; i < MAX_ZONES; i++) { - if(i == view_as(Zone_Freestyle) || i == view_as(Zone_NoVelLimit)) + if(i >= view_as(Zone_Freestyle)) { if(!EmptyZone(gV_FreestyleZones[0][0]) && !EmptyZone(gV_FreestyleZones[0][1])) { @@ -770,6 +795,7 @@ public void Reset(int client) { gV_Point1[client][i] = 0.0; gV_Point2[client][i] = 0.0; + gV_Teleport[client][i] = 0.0; } } @@ -1297,7 +1323,7 @@ public void InsertZone(int client) MapZones type = gMZ_Type[client]; - if((EmptyZone(gV_MapZones[type][0]) && EmptyZone(gV_MapZones[type][1])) || type == Zone_Freestyle || type == Zone_NoVelLimit) // insert + if((EmptyZone(gV_MapZones[type][0]) && EmptyZone(gV_MapZones[type][1])) || type >= Zone_Freestyle) // insert { FormatEx(sQuery, 512, "INSERT INTO %smapzones (map, type, corner1_x, corner1_y, corner1_z, corner2_x, corner2_y, corner2_z, rot_ang, fix1_x, fix1_y, fix2_x, fix2_y) VALUES ('%s', '%d', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f', '%.03f');", gS_MySQLPrefix, gS_Map, type, gV_Point1[client][0], gV_Point1[client][1], gV_Point1[client][2], gV_Point2[client][0], gV_Point2[client][1], gV_Point2[client][2], gF_RotateAngle[client], gV_Fix1[client][0], gV_Fix1[client][1], gV_Fix2[client][0], gV_Fix2[client][1]); } @@ -1321,9 +1347,7 @@ public void SQL_InsertZone_Callback(Database db, DBResultSet results, const char return; } - bool bFreestyle = (data == Zone_Freestyle || data == Zone_NoVelLimit); - - UnloadZones(bFreestyle? 0:data); + UnloadZones((data >= Zone_Freestyle)? 0:data); RefreshZones(); } @@ -1333,7 +1357,7 @@ public Action Timer_DrawEverything(Handle Timer, any data) { float vPoints[8][3]; - if(i == view_as(Zone_Freestyle) || i == view_as(Zone_NoVelLimit)) + if(i >= view_as(Zone_Freestyle)) { for(int j = 0; j < MULTIPLEZONES_LIMIT; j++) {