simple mod but i'm new


(buffgbob) #1

yeah…

i was wondering what i should start to program my mod with… all i really know how to do is C++, but if i program a C program… could i even compile that properly to run the thing i want to do… this is what i want to do…

I want a mod that creates a function… that can be bound to a key

basically an admin would hit whatever button it is bound to and a popup would come up which would ask him for a player’s name [playersname] and another popup for the reason [reason]… then it would put the person in spec
!putteam [playersname] s
and give them a popup telling them what they did [reason]
then it can execute a
!kick [playername] or something to that extent but i believe that is rather inconciquential

so… my question is could i program this in C++ … and if so… what would my compilation line look like to turn it into a .pk3?

yeah i know… i a n00b… flame me


(SCDS_reyalP) #2

first, look at the sticky threads on getting your mod running.

If you can write C++, you can write C. I would not suggest trying to link C++ into the ET game code. While it could be done, it would be much simpler just to stick to C.

As far as what you want to do, I would look at the referee code, and use that as a starting point. It already can be used to put people to spec, and has UI stuff too.


(buffgbob) #3

thanks a lot for the help
ok this may be a stupid question… but where would i find the referee code…
… and yeah… i can program in C… thanks again


(MuffinMan) #4

I would start searching in g_vote.c, didn’t have a look at it yet though


(buffgbob) #5

ok … i think i’m abandoning the idea of having a popup come up on the other person’s screen. I’m pretty sure i can do a menu for the person who is trying to kick etc.
with a popup showing on the other person’s screen, does anyone know how to run a string through the console?

like if i were to have

string thing;
thing = “/!putteam poopy s”;

how could i get it to run
/!putteam poopy s
inside the console

thanks again, you guys have been a lot of help so far…
the reason i want to run things in the console is because now that i’m not using a popup i’ll just have it send a private message… because i’m pretty sure a popup i’d have to alter some files that make it so one couldn’t play on other servers and this way there would only be a download and exec on the admin’s side


(MuffinMan) #6

have a look at G_ref_cmd() in g_referee.c, it calls G_refCommandCheck() which compares the entered string with existing predefined strings and so does all the referee stuff if you are logged in as one - just put in a new referee function - didn’t check that but I think it’s the way to go


(SCDS_reyalP) #7

buffgbob

You are going to have to poke around the code and learn it. Without a general idea of how things fit together, you won’t have much luck putting in your own features. Look for likely filenames (like g_vote.c and g_referee.c), pick a feature that is something like what you want, read through it until you have an idea of how it works, and then try to add what you want.

Along with the above mentioned files, you might want to look at g_cmds.c and g_cmds_ext.c

Some tool (like grep or sourcenav http://sourcenav.sourceforge.net ) that lets you search through the code will be a big help.

A few hints on how the code is organized:
cgame = client game.
game = server game.
ui = user interface
game/bg_ = both games.
game/q_shared = shared with the engine and/or stuff needed by all modules.
game/g_public.h = game <-> engine interfaces
game/g_local.h = used only by game.
cgame/cg_local.h = used only by cgame.
and so on.

beware of this issue http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=7413 if you are going to use G_refPrintf or cpm for your menu.

http://www.planetquake.com/code3arena/ is a good place to get more general information. Even though it is for q3, much of the information applies directly to ET. Just ignore the stuff about QVMs.


(buffgbob) #8

ok thanks a lot for the help… i was wondering… if i made these modifications, would anyone who downloads it still be able to play on other servers? also would the server owner have to somehow put it in his code… or is that what has to happen in the first place?

if he does do that… does everyone who logs onto the server need the mod… and if so… can they play on other servers once they’ve done this?


(SCDS_reyalP) #9

it depends how you do it. If you only change server game code (game/g_*.c compiled to qagame_mp_x86.dll) then it only needs to be on the server.

If you change cgame or ui, then clients will need to download those in order to use the changes.

You can add ref commands to the server only, but people will have to use /ref whatever instead of going through the menu.

On pure servers, clients must use the same .dll files as are in a .pk3 (usually mp_bin.pk3) on the server. If they don’t match, it will be downloaded an they will be extracted. So in order for people to use a client mod, it must also be on a .pk3 on the server.

If you are going to run a modified server, be sure to set fs_game to something unique.


(buffgbob) #10

the important thing is people will be able to play on different servers even if they download it… i think you imply this.

looks like i’ve got to get to work :smiley:


(SCDS_reyalP) #11

Yes. They won’t be able to use the features unless the server has the mod installed, but assuming things are set up correctly (namely the servers fs_game is set) then mods don’t interfere with each other at all.


(Schaffer) #12

Am I stupid or isn’t this sort of thing already in ET, or most games. As an admin (referee or recon) you can warn a player or kick them already. You can also put them into spectator mode or force them into a team. Are you trying to achieve this becasue you havn’t seen these feature implemeneted or are you just messing with the code so you get a grip on how it all ticks?


(MuffinMan) #13

yep the whole thing could be easily achieved with a little script but might be an easy way to get into the code as well…


(buffgbob) #14

well… what i’m trying to do is a sequence of these commands…
spec them
warn them (custom message)
kick them

all with one command

it shouldn’t be that tough… but i have to get used to the code and that is what i’m dealing with now… compiling will be a whole other story… it’ll be a mess


(SCDS_reyalP) #15

I don’t see how you can do this in a reasonable manner with one command. Learning the individual commands, and maybe making some binds for them would seem like a far better investment of time.

One thing you could do is make the concept of a selected player. So then your admins could do
/players
… find the pid or name of the player the want
/selplayer <player name|pid>
then
/followsel
would spectate the ‘selected’ player (same as /follow pid)
/warnsel “warning message”
would warn the selected player
/kicksel
would kick them.

You could then make a UI for this in client and ui. Ie, select the player from a popup, this puts you following them with warn and kick buttons available.

Still seems like a lot of work for something that is fairly easy to do manually.

edit:
you could of course modify the follow, warn and kick commands to accept a token that means ‘curretly selected player’