Which Mod Looks The Best?

Caliber
Urban Terror
Survival 9mm
Weapons Factory
None of the above


News

- Current
- Archived
- Send News
Tutorials
- Coding
- Mapping
Interviews
- Caliber Mod
Mods
- Previews
:::Q3Fortress
- Reviews
Download
- Best Maps
- Best Models
- Tools
Community
- Forums
- Dev Screens
- Chat

Mod Database
- Sign-Up
- Add Mod
- Delete Mod
- View Mods
Hosted Sites
Mods

- Alien Culture
- Alive

- Anarchy
- Armed Service
- Battle Arena
- Caliber
- Chaotic Designs
- Classic Q3A
- Countdown to Dest.
- Critical Mass
- Crusade
- Darkgift
- DarkStar
- Decimal
- Defend The Flags
- Full Metal Jacket
- Front Lines
- Fury
- GatheringDarkness
- Guerilla Warfare
- Hunter
- Insanity
- Insanity Prod.
- Jagged Q3
- Nightrunner
- Occupation
- Oblivion Demise
- Omega
- QForces
- Railfest
- Resound
- Run Bob Run
- ShadowRun
- ShadowStar Conflict
- SiR
- Snipers
- Team Phatass
- Terrorism
- Toons of Evil
- Tritium
- Urban Terror
- Zoners

Editing
- Coded
- Rungy's Metropolis
- MD3Centre
- PikaMaps!
- Q3Empire
- RealGunz
- RocIDE
- Team Interact

 
 

Exploding Machine Gun Bullets - By Ad0


In this tutorial I will explain to you how command line arguments work in the Quake 3: Arena console. The meaning of this is that you can choose more functions from ONE single command using parameters. And that can save some time, thinking of bindings to the keyboard and so on.

Well! Let's start with some easy coding for making this tutorial E A S Y :)

--

Open g_cmds.c and scroll down around line 57, AFTER the function DeathmatchScoreboardMessage.
Ok, I guess you're there now, so I guess you're ready to do some coding!

Ok, the first thing to do is to create a "comment mark" to easily find back to your code, so just snag a comment area and paste it around line 57 UNDER DeathmatchScoreboardMessage function. Call the function whateveryou want, but don't use space between words!:

/*
=================
Cmd_MyFunc_f
=================
*/

void Cmd_MyFunc_f( gentity_t *ent ) {

char *msg; // message to player
char arg1[MAX_STRING_TOKENS]; //argument string var.

trap_Argv( 1, arg1, sizeof( arg1 ) ); //catch the parameter text
       if ( !Q_stricmp( arg1, "arg1" ) ) { //check for parameter "arg1"
          msg = "Argument 1 typed in!\n";
       } else if ( !Q_stricmp( arg1, "arg2" ) ) {
          msg = "Argument 2 typed in!\n";
       } else {
       msg = "no parameters or wrong parameter!!!\n"; //if none of above
    }
trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
//prints the message var --> msg to the local console!
} //The very end of Cmd_MyFunc_f

After you've done this paste/writeoff, you must make this function aviable in the console, by adding it to the commands code at the end of g_cmds.c.
I recommend you to write off instead of paste. maybe try to add a third argument, and figure more things out! It's healthy for your brain!

Ok, enough talking, lets get back to coding!
Scroll down to the very end, and after that, crawl your way up the source until you hit:
else if (Q_stricmp (cmd, "god") == 0)
     Cmd_God_f (ent);

Copy this, paste it right under and modify to:

if (Qstricmp (cmd, "MyFunc" ==0) //command name in console
     Cmd_MyFunc_f (ent); //the function name must be like the function!

And there you go! Command Line arguments!

Compile and launch Quake 3 (you must know how to compile and stuff before getting into any Quake 3 C coding)

When you're entering q3arena and writing "/MyFunc arg1", the console responds: "Argument 1 typed in!". figure the rest out of yourself...

Try to develop this, and learn from it.
This is my first Quake 3: Arena coding tutor, so don't get angry by errors... just mail the bugs to me. The mail address is locatedon the top.

Cheers!