Forum

stuffcmd tutorial

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

stuffcmd tutorial

Postby ceriux » Wed Dec 23, 2009 8:44 am

i wrote this and put it on my homepage i figured it might have a little use here too so ...


In this basic tutorial ill show you how to stuffcmd something. there's a lot of uses when using this so i think its a good tutorial.

ok to start off we need to have something to stuffcmd.

so lets make a function to print your name. just for something to use.

so i always like to make a new .qc file to put most of my custom stuff in and another for custom definitions so my way of doing things might be a little weird to some. but it helps me keep organized.

so first things first lets make a new .qc files called custom. in this file add your function to print your name like so:

Code: Select all
void() nameprint =
{
if (self.impulse == 15) // if self.impulse equals 15 .
centerprint(self,self.netname);  // print my name in the center of the screen.
};

next thing to do is go to weapons.qc and go down to "impulse commands." IN this function you want to add:



Code: Select all
if (self.impulse == 15) // sets self.impulse to 15
nameprint(); // and if its 15 calls our function.





next save and open up client.qc go down to "clientconnect" and in this function paste this:


Code: Select all
 stuffcmd(self,"alias myname \"impulse 15\"\n");
stuffcmd(self,"bind m myname \n");


next, make one more .qc file and name it moddefs.qc in this paste your new definitions. when modding i like to have all of my custom definitions within my own def qc file. helps me keep track of what im doing.what you have should look like this:
Code: Select all
void() nameprint ;



last step, open up progs.src and make it look like this:


Code: Select all
../progs.dat
 
defs.qc
         moddefs.qc  // added this
subs.qc
fight.qc
ai.qc
combat.qc
items.qc
weapons.qc
world.qc
client.qc
player.qc
monsters.qc
doors.qc
buttons.qc
triggers.qc
plats.qc
misc.qc
         custom.qc  // added this
 
ogre.qc
demon.qc
shambler.qc
knight.qc
soldier.qc
wizard.qc
dog.qc
zombie.qc
boss.qc
 
tarbaby.qc    // registered
hknight.qc    // registered
fish.qc    // registered
shalrath.qc    // registered
enforcer.qc    // registered
oldone.qc    // registered


the only issue with adding the bind stuffcmd is that every time the player connects IF he has a custom bind set to your alias it will reset their to the default you set. but like i said stuffcmding can be used for a lot of things this is just a tutorial to familiarize you with using it.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest