Author Topic: Switch command  (Read 8083 times)

googles

  • Posts: 219
  • Turrets: +30/-19
Switch command
« on: November 06, 2007, 02:44:48 am »
hey...im new to modding the QVM and im not totally sure on how to make a patch...but i made a switch command today which lets you switch places with someone, and no i didnt *steal* this from arcade mod, i had no idea that arcade mod had this i just thought it up and recently found arcade mod had it so i guess you can call this the command for it..

g_admin.c

Code: [Select]

    {"switch", G_admin_switch, "I",
      "switch places with somenone",
      "[^3name|slot#^7]"
    }



Code: [Select]

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;


  minargc = 3 + skiparg;
  if( G_admin_permission( ent, ADMF_UNACCOUNTABLE ) )
    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.sessionTeam != TEAM_SPECTATOR )
    trap_LinkEntity (ent);

  if( vic->client->sess.sessionTeam != TEAM_SPECTATOR )
    trap_LinkEntity (vic);


//take them off noclip
vic->client->noclip = qfalse;
ent->client->noclip = qfalse;


AP( va( "print \"^7%s^7 switched places with %s^7\n\"", ent->client->pers.netname, vic->client->pers.netname ) );

  return qtrue;

}



g_admin.h

Code: [Select]

qboolean G_admin_switch( gentity_t *ent, int skiparg );


please dont yell at me if my code is noobish and wrong :( i just did what i had to to make it work im not sure if its any good

Caveman

  • Guest
Switch command
« Reply #1 on: November 06, 2007, 08:41:20 am »
Nicely done :)

Steely Ann

  • Posts: 752
  • Turrets: +106/-88
Switch command
« Reply #2 on: November 06, 2007, 08:57:22 am »
Lessee:
Crimson, ash-laden sky.  Check
Fire & brimstone.  Check
Caveman saying nice things.  Check
The apocalypse is here, folks!
</obligatory obnoxious omg cavemn !!!!11elven2!!!!!11 comment>

And yes, that code is the hawtness, assuming I didn't miss a typo or some other little detail (damned nitpicky programming languages!).
That said, what would be the purpose of a switcharoo in positions besides mind-screwing people?  Sorry, it's four in the morning and all, I guess.

Caveman

  • Guest
Switch command
« Reply #3 on: November 06, 2007, 11:16:47 am »
*giggles*

together with that other "patch"-idea, you remember the Ninja-suggestion, it would be awfully cute.

googles

  • Posts: 219
  • Turrets: +30/-19
Switch command
« Reply #4 on: November 06, 2007, 04:35:02 pm »
well there isnt much use for it other then to have mass fun with people, if you want to see it in action come to my server, its called *google's server*, i also have alot more commands but im not sure they are as good as switch lol

and btw THANK YOU SO MUCH! for the nice comments i was expecting everyone to call me a noob and stuff :(

benmachine

  • Posts: 915
  • Turrets: +99/-76
    • ben's machinery
Re: Switch command
« Reply #5 on: November 06, 2007, 06:22:30 pm »
Code: [Select]
 minargc = 3 + skiparg;
  if( G_admin_permission( ent, ADMF_UNACCOUNTABLE ) )
    minargc = 2 + skiparg;

I don't understand this bit - why do some people need 3 args? It's not as if you use the third one.
Also, if it were me, I'd probably not make this an admin command. Doesn't seem like something you'd use to keep order and fight griefers. That's really just a matter of style though.
Nice work overall.
benmachine

googles

  • Posts: 219
  • Turrets: +30/-19
Switch command
« Reply #6 on: November 06, 2007, 08:12:03 pm »
lol i forgot to remove that and yeah i can see that this has about no use in real games but! i run a cheat server(you could call it) with all glitch stuff enabled an its fun to switch players around, and thank you for your nice comment :) that means alot from a good modder like you :)

googles

  • Posts: 219
  • Turrets: +30/-19
Switch command
« Reply #7 on: November 06, 2007, 08:12:24 pm »
please remove this post

benmachine

  • Posts: 915
  • Turrets: +99/-76
    • ben's machinery
Switch command
« Reply #8 on: November 06, 2007, 09:00:08 pm »
Quote from: "googles"
i can see that this has about no use in real games but! i run a cheat server(you could call it) with all glitch stuff enabled an its fun to switch players around, and thank you for your nice comment :) that means alot from a good modder like you :)

I didn't mean to imply that this was useless, just that it wasn't an administrative function. You could instead move it to g_cmds.c to make a /command rather than a !command, but it doesn't really matter.
benmachine

googles

  • Posts: 219
  • Turrets: +30/-19
Switch command
« Reply #9 on: November 07, 2007, 04:01:26 am »
well im new to the C programming language(i feel that needed to be stated), and i use !commands because so far all my commands are for my level of admin(so just a few friends have it) the reason for that is to give them a very good test run. but i had never had the idea to send them to /commands, please drop by my server and maybe we can talk about the QVM and commands and stuff im very intrested in modding the QVM and tremulous itself(even though im like a 1 month user, and tremulous is my first quake mod i have ever used)