Finished teleporter admin commands; zr_teleport, zr_tele_saveloc, zr_tele_loc, zr_tele_abort. Teleport admin menu made, but not coded.

This commit is contained in:
richard 2008-12-26 23:03:29 +01:00
parent 69799e1c0d
commit ef8a7e04b7
7 changed files with 263 additions and 20 deletions

View File

@ -1,3 +1,7 @@
2008.12.26 - 2.5.1.17
* Finished teleporter admin commands; zr_teleport, zr_tele_saveloc, zr_tele_loc, zr_tele_abort.
* Teleport admin menu made, but not coded.
2008.12.20 - 2.5.1.16 2008.12.20 - 2.5.1.16
* Improved the teleporter. Startup delay, cooldown, separate team delays and limits. Admin commands made, but not coded yet. * Improved the teleporter. Startup delay, cooldown, separate team delays and limits. Admin commands made, but not coded yet.

View File

@ -15,7 +15,7 @@
#undef REQUIRE_PLUGIN #undef REQUIRE_PLUGIN
#include <market> #include <market>
#define VERSION "2.5.1.16" #define VERSION "2.5.1.17"
#include "zr/zombiereloaded" #include "zr/zombiereloaded"
#include "zr/global" #include "zr/global"

View File

@ -10,9 +10,12 @@ CreateCommands()
{ {
RegAdminCmd("zr_infect", Command_Infect, ADMFLAG_GENERIC, "Infects the specified player"); RegAdminCmd("zr_infect", Command_Infect, ADMFLAG_GENERIC, "Infects the specified player");
RegAdminCmd("zr_spawn", Command_Respawn, ADMFLAG_GENERIC, "Respawns the specified player following auto-respawning rules"); RegAdminCmd("zr_spawn", Command_Respawn, ADMFLAG_GENERIC, "Respawns the specified player following auto-respawning rules");
RegAdminCmd("zr_teleport", Command_Teleport, ADMFLAG_GENERIC, "Teleports one or more players to spawn. Usage: zr_teleport <target>"); RegAdminCmd("zr_teleport", Command_Teleport, ADMFLAG_GENERIC, "Teleports one or more players to spawn. Usage: zr_teleport <target>");
RegAdminCmd("zr_tele_saveloc", Command_TeleSaveLocation, ADMFLAG_GENERIC, "Saves your or a players location to a buffer. Usage: zr_tele_saveloc [#userid|name]"); RegAdminCmd("zr_tele_saveloc", Command_TeleSaveLocation, ADMFLAG_GENERIC, "Saves your or a players location to a buffer. Usage: zr_tele_saveloc [#userid|name]");
RegAdminCmd("zr_tele_loc", Command_TeleportToLocation, ADMFLAG_GENERIC, "Teleports you or a player to the saved location. Usage: zr_tele_loc [#userid|name]"); RegAdminCmd("zr_tele_loc", Command_TeleportToLocation, ADMFLAG_GENERIC, "Teleports you or a player to the saved location. Usage: zr_tele_loc [#userid|name]");
RegAdminCmd("zr_tele_abort", Command_TeleportAbort, ADMFLAG_GENERIC, "Aborts a teleportation or cooldown on a client. Usage: zr_tele_abort <target>");
RegAdminCmd("zr_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon"); RegAdminCmd("zr_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon");
RegAdminCmd("zr_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon"); RegAdminCmd("zr_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon");
@ -21,6 +24,7 @@ CreateCommands()
RegAdminCmd("zr_admin", Command_AdminMenu, ADMFLAG_GENERIC, "Displays the admin menu for Zombie: Reloaded."); RegAdminCmd("zr_admin", Command_AdminMenu, ADMFLAG_GENERIC, "Displays the admin menu for Zombie: Reloaded.");
RegAdminCmd("zr_knockback_m", Command_KnockbackMMenu, ADMFLAG_GENERIC, "Displays the knockback multiplier menu."); RegAdminCmd("zr_knockback_m", Command_KnockbackMMenu, ADMFLAG_GENERIC, "Displays the knockback multiplier menu.");
RegAdminCmd("zr_teleadmin", Command_TeleMenu, ADMFLAG_GENERIC, "Displays the teleport admin menu for Zombie: Reloaded.");
} }
public Action:Command_Infect(client, argc) public Action:Command_Infect(client, argc)
@ -253,3 +257,17 @@ public Action:Command_KnockbackMMenu(client, argc)
} }
return Plugin_Handled; return Plugin_Handled;
} }
public Action:Command_TeleMenu(client, argc)
{
if (IsClientPlayer(client))
{
ZRTeleMenu(client);
}
else
{
PrintToServer("This menu cannot be used in the console. Client: %d", client);
if (client > 0) PrintToConsole(client, "You cannot use this menu. Client: %d", client);
}
return Plugin_Handled;
}

View File

@ -2,7 +2,7 @@
* ==================== * ====================
* Zombie:Reloaded * Zombie:Reloaded
* File: teleport.inc * File: teleport.inc
* Authors: Richard Helgeby / Cpt.Moore * Authors: Richard Helgeby, Cpt.Moore
* ==================== * ====================
*/ */
@ -138,31 +138,175 @@ public Action:Event_TeleportCooldown(Handle:Timer, any:client)
public Action:Command_Teleport(client, argc) public Action:Command_Teleport(client, argc)
{ {
// Check (on all specified clients) if a teleport/cooldown is in progress. new String:arg1[MAX_TARGET_LENGTH];
// If so, kill those timers. new String:target_name[MAX_TARGET_LENGTH];
new bool:tn_is_ml;
if (argc >= 1)
{
GetCmdArg(1, arg1, sizeof(arg1));
new target_list[MAXPLAYERS];
new target_count;
if ((target_count = ProcessTargetString(
arg1,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
AbortTeleport(target_list[i]);
TeleportClient(target_list[i], true, true);
LogAction(client, target_list[i], "\"%L\" teleported \"%L\" to spawn", client, target_list[i]);
}
}
else
{
AbortTeleport(client);
TeleportClient(client, true, true);
GetClientName(client, target_name, sizeof(target_name));
LogAction(client, client, "[ZR] Player %s teleported %s to spawn.", target_name, target_name);
}
if (tn_is_ml)
{
ShowActivity2(client, "[ZR] ", "%t teleported to spawn.", target_name);
}
else
{
ShowActivity2(client, "[ZR] ", "%s teleported to spawn.", target_name);
}
// No cooldown when using this command.
return Plugin_Handled; return Plugin_Handled;
} }
public Action:Command_TeleSaveLocation(client, argc) public Action:Command_TeleSaveLocation(client, argc)
{ {
new String:target_name[MAX_TARGET_LENGTH];
new String:target_client;
if (argc >= 1)
{
GetCmdArg(1, target_name, sizeof(target_name));
target_client = FindTarget(client, target_name);
}
else
{
target_client = client;
}
if (target_client > 0 && target_client <= MAXPLAYERS)
{
GetClientAbsOrigin(target_client, bufferLoc);
bufferLocSaved = true;
GetClientName(target_client, target_name, sizeof(target_name));
ReplyToCommand(client, "Saved location to %s (%d, %d, %d).", target_name, bufferLoc[0], bufferLoc[1], bufferLoc[2]);
}
else
{
ReplyToCommand(client, "Unable to target %s", target_name);
}
return Plugin_Handled; return Plugin_Handled;
} }
public Action:Command_TeleportToLocation(client, argc) public Action:Command_TeleportToLocation(client, argc)
{ {
new String:target_name[MAX_TARGET_LENGTH];
new target_client;
new Float:empty_vector[3] = {0.0, 0.0, 0.0};
// Don't teleport if a location isn't saved yet. // Don't teleport if a location isn't saved yet.
// To do: Find or make a function to check if a vector array is a null vector. if (bufferLocSaved)
/*if (bufferLoc[] != NULL_VECTOR)
{ {
return Plugin_Handled; if (argc >= 1)
{
GetCmdArg(1, target_name, sizeof(target_name));
target_client = FindTarget(client, target_name);
}
else
{
target_client = client;
}
if (target_client > 0 && target_client <= MAXPLAYERS)
{
AbortTeleport(target_client);
TeleportEntity(target_client, bufferLoc, NULL_VECTOR, empty_vector);
ZR_PrintToChat(client, "!ztele successful");
if (target_client != client) ZR_PrintToChat(target_client, "!ztele successful");
}
else
{
ReplyToCommand(client, "Unable to target %s", target_name);
}
} }
else else
{ {
ZR_PrintToChat(client, "!ztele location not set"); ReplyToCommand(client, "Location not set.");
return Plugin_Handled; }
}*/
return Plugin_Handled;
}
public Action:Command_TeleportAbort(client, argc)
{
new String:arg1[MAX_TARGET_LENGTH];
new String:target_name[MAX_TARGET_LENGTH];
new bool:tn_is_ml;
if (argc >= 1)
{
GetCmdArg(1, arg1, sizeof(arg1));
new target_list[MAXPLAYERS];
new target_count;
if ((target_count = ProcessTargetString(
arg1,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
AbortTeleport(target_list[i]);
LogAction(client, target_list[i], "\"%L\" aborted teleport on \"%L\".", client, target_list[i]);
}
}
else
{
AbortTeleport(client);
GetClientName(client, target_name, sizeof(target_name));
LogAction(client, client, "[ZR] Player %s teleported %s to spawn.", target_name);
}
if (tn_is_ml)
{
ShowActivity2(client, "[ZR] ", "Aborted teleport and cooldown on %t.", target_name);
}
else
{
ShowActivity2(client, "[ZR] ", "Aborted teleport and cooldown on %s.", target_name);
}
return Plugin_Handled;
} }
ZTeleClientCheck(client) ZTeleClientCheck(client)
@ -174,6 +318,13 @@ ZTeleClientCheck(client)
return; return;
} }
new team = GetClientTeam(client);
if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
ZR_PrintToChat(client, "Must be alive");
return;
}
if (!ztele_online) if (!ztele_online)
{ {
ZR_PrintToChat(client, "!ztele offline"); ZR_PrintToChat(client, "!ztele offline");
@ -249,10 +400,14 @@ ZTeleClientCheck(client)
TeleportClient(client); TeleportClient(client);
} }
TeleportClient(client, bool:no_delay = false) /*
* Note: free_tele only works if no_delay is true.
*/
TeleportClient(client, bool:no_delay = false, bool:free_tele = false)
{ {
new teleports_left; new teleports_left;
new bool:teleports_unlimited = false; new bool:teleports_unlimited = false;
new Float:empty_vector[3] = {0.0, 0.0, 0.0};
if (IsPlayerHuman(client)) if (IsPlayerHuman(client))
{ {
@ -302,10 +457,12 @@ TeleportClient(client, bool:no_delay = false)
if (no_delay) if (no_delay)
{ {
ztele_countdown[client] = -1; ztele_countdown[client] = -1;
ztele_count[client]++; if (!free_tele) ztele_count[client]++;
TeleportEntity(client, spawnLoc[client], NULL_VECTOR, NULL_VECTOR);
TeleportEntity(client, spawnLoc[client], NULL_VECTOR, empty_vector);
ZR_PrintToChat(client, "!ztele successful"); ZR_PrintToChat(client, "!ztele successful");
if (!teleports_unlimited) if (!teleports_unlimited && !free_tele)
{ {
ZR_PrintToChat(client, "!ztele amount", teleports_left); ZR_PrintToChat(client, "!ztele amount", teleports_left);
} }

View File

@ -54,6 +54,7 @@ new protCount[MAXPLAYERS+1];
new Float:spawnLoc[MAXPLAYERS + 1][3]; new Float:spawnLoc[MAXPLAYERS + 1][3];
new Float:bufferLoc[3]; new Float:bufferLoc[3];
new bool:ztele_spawned[MAXPLAYERS + 1] = {false, ...}; new bool:ztele_spawned[MAXPLAYERS + 1] = {false, ...};
new bool:bufferLocSaved = false;
new ztele_countdown[MAXPLAYERS + 1] = {-1, ...}; new ztele_countdown[MAXPLAYERS + 1] = {-1, ...};
new ztele_count[MAXPLAYERS + 1]; new ztele_count[MAXPLAYERS + 1];
new bool:ztele_online = false; new bool:ztele_online = false;

View File

@ -20,15 +20,16 @@ ZRAdminMenu(client)
decl String:znvgs[] = "Change night vision settings"; decl String:znvgs[] = "Change night vision settings";
decl String:zinfect[] = "Infect a player"; decl String:zinfect[] = "Infect a player";
decl String:zspawn[] = "Spawn all players"; decl String:zspawn[] = "Spawn all players";
decl String:ztele[] = "Teleporter commands";
decl String:zrestrict[] = "Restrict a weapon"; decl String:zrestrict[] = "Restrict a weapon";
decl String:zunrestrict[] = "Unrestrict a weapon"; decl String:zunrestrict[] = "Unrestrict a weapon";
AddMenuItem(zr_admin_menu, "zknockbackm", zknockbackm); AddMenuItem(zr_admin_menu, "zknockbackm", zknockbackm);
AddMenuItem(zr_admin_menu, "zknockback", zknockback); AddMenuItem(zr_admin_menu, "zknockback", zknockback);
AddMenuItem(zr_admin_menu, "znvgs", znvgs); AddMenuItem(zr_admin_menu, "znvgs", znvgs);
AddMenuItem(zr_admin_menu, "zinfect", zinfect); AddMenuItem(zr_admin_menu, "zinfect", zinfect);
AddMenuItem(zr_admin_menu, "zspawn", zspawn); AddMenuItem(zr_admin_menu, "zspawn", zspawn);
AddMenuItem(zr_admin_menu, "ztele", ztele);
AddMenuItem(zr_admin_menu, "zrestrict", zrestrict, ITEMDRAW_DISABLED); AddMenuItem(zr_admin_menu, "zrestrict", zrestrict, ITEMDRAW_DISABLED);
AddMenuItem(zr_admin_menu, "zunrestrict", zunrestrict, ITEMDRAW_DISABLED); AddMenuItem(zr_admin_menu, "zunrestrict", zunrestrict, ITEMDRAW_DISABLED);
@ -63,9 +64,13 @@ public ZRAdminMenuHandle(Handle:zr_admin_menu, MenuAction:action, client, slot)
} }
case 5: case 5:
{ {
// restrict ZRTeleMenu(client);
} }
case 6: case 6:
{
// restrict
}
case 7:
{ {
// unrestrict // unrestrict
} }
@ -363,6 +368,62 @@ ZRSpawnAll(client)
ZRAdminMenu(client); ZRAdminMenu(client);
} }
ZRTeleMenu(client)
{
new Handle:zr_tele_menu = CreateMenu(ZRTeleHandle);
decl String:ztele_player[] = "Teleport players";
decl String:ztele_abort[] = "Abort teleport on players";
decl String:ztele_save[] = "Save player location";
decl String:ztele_teleloc[] = "Teleport player to saved location";
SetMenuTitle(zr_tele_menu, "Teleport menu");
AddMenuItem(zr_tele_menu, "ztele_player", ztele_player);
AddMenuItem(zr_tele_menu, "ztele_abort", ztele_abort);
AddMenuItem(zr_tele_menu, "ztele_save", ztele_save);
AddMenuItem(zr_tele_menu, "ztele_teleloc", ztele_teleloc);
SetMenuExitBackButton(zr_tele_menu, true);
DisplayMenu(zr_tele_menu, client, MENU_TIME_FOREVER);
}
public ZRTeleHandle(Handle:zr_tele_menu , MenuAction:action, client, slot)
{
if (action == MenuAction_Select)
{
switch(slot)
{
case 0:
{
// Teleport player.
}
case 1:
{
// Abort teleport.
}
case 2:
{
// Save location.
}
case 3:
{
// Teleport to location.
}
}
}
if (action == MenuAction_Cancel)
{
if (slot == MenuCancel_ExitBack)
{
ZRAdminMenu(client);
}
}
if (action == MenuAction_End)
{
CloseHandle(zr_tele_menu);
}
}
AddToKnockbackMultiplier(Float:value) AddToKnockbackMultiplier(Float:value)
{ {
new Float:current_val = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]); new Float:current_val = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]);

View File

@ -10,6 +10,8 @@ Section content is listed in order of importance. Some of these can be ideas too
class name to read the value: class name to read the value:
zr_class_enabled <classname>[ <0/1>] zr_class_enabled <classname>[ <0/1>]
* Zombies that dies from anything else than a human attack (+ grenades) will respawn as zombies.
* Make a admin command to read and write settings to a spesific class, * Make a admin command to read and write settings to a spesific class,
using key/value. Integrate it with the zr_admin menu. using key/value. Integrate it with the zr_admin menu.