Hi!
I am running fun mvm server. And I wanted to make command sm_tpme (teleport me), so any player or, at least, reserved-slot players (my friends) could teleport themselves. I have modified source code of this plugin a little to add this function. But me is not programmer and I am afraid that I could miss something important and my modification could be dangerous for server security and stability.
If some one could check if my patch is good — that will be awesome…
Code is here:
https://bitbucket.org/avi9526/funcommandsx
Diff:
Code:
diff -r e6f29ac15a3d -r 036b17dc365a scripting/funcommandsX/teleport.sp
--- a/scripting/funcommandsX/teleport.sp Mon Jul 15 21:32:21 2013 +0300
+++ b/scripting/funcommandsX/teleport.sp Mon Jul 15 22:14:44 2013 +0300
@@ -8,6 +8,7 @@
*****************************************************************/
new Float:g_pos[3];
+new Handle:cvar_SelfTeleport;
/*****************************************************************
@@ -19,6 +20,8 @@
public SetupTeleport()
{
RegAdminCmd("sm_tele", Command_Tele, ADMFLAG_SLAY, "sm_tele <#userid|name> - Teleports player to where admin is looking");
+ RegConsoleCmd("sm_tpme", Command_TeleMe, "sm_tpme - teleport yourself");
+ cvar_SelfTeleport = CreateConVar("sm_selfteleport", "0", "Allow players to teleport themselves with sm_tpme");
}
/****************************************************************
@@ -82,6 +85,41 @@
return Plugin_Handled;
}
+public Action:Command_TeleMe(client, args)
+{
+ if( !GetConVarInt(cvar_SelfTeleport) )
+ {
+ ReplyToCommand(client, "[SM] Command disabled, to enable set sm_selfteleport to 1");
+ return Plugin_Handled;
+ }
+ //validate args
+ if (args >= 1)
+ {
+ ReplyToCommand(client, "[SM] Command does not require arguments");
+ }
+
+ if(!client)
+ {
+ ReplyToCommand(client, "[SM] Cannot teleport from rcon");
+ return Plugin_Handled;
+ }
+
+ if(!SetTeleportEndPoint(client))
+ {
+ return Plugin_Handled;
+ }
+
+ if(!IsPlayerAlive(client) || !IsClientInGame(client))
+ {
+ ReplyToCommand(client, "[SM] Can't teleport dead player");
+ return Plugin_Handled;
+ }
+
+ PerformTeleport(client, client, g_pos);
+
+ return Plugin_Handled;
+}
+
public bool:TraceEntityFilterPlayer(entity, contentsMask)
{
return entity > GetMaxClients() || !entity;
@@ -286,4 +324,4 @@
DisplayTeleMenu(param1);
}
}
-}
\ No newline at end of file
+}