summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIronClawTrem <louie.nutman@gmail.com>2020-02-20 19:01:57 +0000
committerIronClawTrem <louie.nutman@gmail.com>2020-02-20 22:27:50 +0000
commit57938b6734c9551e3e7a8d213762391d1f370368 (patch)
treed6846da6cb01b60c55d05227b3e1d4024fd88443
parent331f738c7a0487a715792ffc3ab30042924e0c2f (diff)
add !switch command
-rw-r--r--src/game/g_admin.c68
-rw-r--r--src/game/g_admin.h1
2 files changed, 69 insertions, 0 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 0abba45..287c664 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -431,6 +431,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
{"print",G_admin_print2, "print",
"prints text",
"[text to print]"
+ },
+
+ {"switch", G_admin_switch, "switch",
+ "switch places with somenone",
+ "[^3name|slot#^7]"
}
};
@@ -8435,3 +8440,66 @@ qboolean G_admin_print2(gentity_t *ent, int skiparg )
AP( va( "print \"%s\n\"", text ));
return qtrue;
}
+
+qboolean G_admin_switch( gentity_t *ent, int skiparg )
+{
+ int pids[ MAX_CLIENTS ];
+ char name[ MAX_NAME_LENGTH ], err[ MAX_STRING_CHARS ];
+ int minargc;
+ gentity_t *vic;
+
+ if( !ent )
+ {
+ ADMP( "^3!switch: ^7console cannot use this command\n" );
+ return qfalse;
+ }
+
+ minargc = 2 + skiparg;
+
+ if( G_SayArgc() < minargc )
+ {
+ ADMP( "^3!switch: ^7usage: !switch [name|slot#]\n" );
+ return qfalse;
+ }
+
+ G_SayArgv( 1 + skiparg, name, sizeof( name ) );
+
+ if( G_ClientNumbersFromString( name, pids ) != 1 )
+ {
+ G_MatchOnePlayer( pids, err, sizeof( err ) );
+ ADMP( va( "^3!switch: ^7%s\n", err ) );
+ return qfalse;
+ }
+
+ vic = &g_entities[ pids[ 0 ] ];
+
+ //put them on noclip
+ vic->client->noclip = qtrue;
+ ent->client->noclip = qtrue;
+
+ //switch places
+ trap_UnlinkEntity( ent );
+ VectorCopy( vic->s.origin, ent->client->ps.origin );
+
+ //switch places
+ trap_UnlinkEntity( vic );
+ VectorCopy( ent->s.origin, vic->client->ps.origin );
+
+ //spectator fix
+ if( ent->client->sess.spectatorState == SPECTATOR_NOT )
+ trap_LinkEntity (ent);
+
+ if( vic->client->sess.spectatorState == SPECTATOR_NOT )
+ trap_LinkEntity (vic);
+
+
+ //take them off noclip
+ vic->client->noclip = qfalse;
+ ent->client->noclip = qfalse;
+
+ trap_SendServerCommand( vic-g_entities, va( "print \"^7%s^7 switched with you\n\"", ent->client->pers.netname ) );
+ trap_SendServerCommand( ent-g_entities, va( "print \"^7you switched with ^7%s^7\n\"", vic->client->pers.netname ) );
+
+ return qtrue;
+
+}
diff --git a/src/game/g_admin.h b/src/game/g_admin.h
index b85beec..218b403 100644
--- a/src/game/g_admin.h
+++ b/src/game/g_admin.h
@@ -306,6 +306,7 @@ qboolean G_admin_sm( gentity_t *ent, int skiparg );
void G_admin_schachtmeisterFrame( void );
qboolean G_admin_is_restricted(gentity_t *ent, qboolean sendMessage);
qboolean G_admin_print2( gentity_t *ent, int skiparg );
+qboolean G_admin_switch( gentity_t *ent, int skiparg );
void G_admin_print( gentity_t *ent, char *m );
void G_admin_buffer_print( gentity_t *ent, char *m );