PDA

View Full Version : Metamod Plugin Programming Tutorial linux


SnakePr0luck0r
06-10-2004, 20:36
i am searching for a metamod plugins programming tutorial for linux.
i am skilled in c++ but not much i only would like to code a plugin for linux that changes the mp_timelimit to 30 or anything like this.

i hope someone is friendly and can paste me a source code for this and how to compile .
i understand a detail of the source from the examples from metamod.org ( stub/wdmisc_plugin ) but i don't know how to compile on linux.

bye snakepr0luck0r

Pierre-Marie Baty
06-10-2004, 22:18
There is not much difference between a Windows and a Linux metamod plugin, because metamod already abstracts all the OS-specific declarations. We have some very simple plugins here in the filebase, almost all of which come with source code. Just grab one and see for yourself :)

Note that you must have GCC 2.95 or 2.96 to compile a working plugin for Linux, because the GCC 3.x series are known not to work.

Whistler
07-10-2004, 06:15
well I don't think there is a "GCC 2.96"...
http://ftp.gnu.org/gnu/gcc/

sPlOrYgOn
07-10-2004, 06:19
yea there is..
it was never released because it was mostly a beta..
but RedHat released it with one of their versions and got MANY complaints about the compiler being "broken" but it actually wasn't.. it was just that it was compiled with strict regulations on what it compiles...

http://www.redhat.com/advice/speaks_gcc.html

SnakePr0luck0r
07-10-2004, 18:28
i downloaded hlsdk-2.3 and unziped it
my gcc version: "gcc version 2.95.4 20011002 (Debian prerelease)"
got one of the examples from the database called playerlog_mm.cpp .

i compile with:
g++ -o playerlog_mm.so playerlog_mm.cpp -I /root/pl/hlsdk-2.3/multiplayer/dlls -I /root/pl/hlsdk-2.3/multiplayer/common -I /root/pl/hlsdk-2.3/multiplayer/cl_dll -I /root/pl/hlsdk-2.3/multiplayer/dedicated -I /root/pl/hlsdk-2.3/multiplayer/dmc -I /root/pl/hlsdk-2.3/multiplayer/engine -I /root/pl/hlsdk-2.3/multiplayer/game_shared -I /root/pl/hlsdk-2.3/multiplayer/network -I /root/pl/hlsdk-2.3/multiplayer/pm_shared -I /root/pl/hlsdk-2.3/multiplayer/ricochet -I /root/pl/hlsdk-2.3/multiplayer/utils

don't know how to add the path to my searchpath i only know -I

but there are some compileing errors:

meta_api.h:40: dllapi.h: No such file or directory
meta_api.h:41: engine_api.h: No such file or directory
meta_api.h:42: plinfo.h: No such file or directory
meta_api.h:43: mutil.h: No such file or directory
meta_api.h:44: osdep.h: No such file or directory

can't find in hlsdk these files where can i download them?

thx snake

SnakePr0luck0r
07-10-2004, 19:41
ah forgott the source of metamod mhh but now this errors are there

In file included from /root/pl/hlsdk-2.3/multiplayer/dlls/meta_api.h:41,
from playerlog_mm.cpp:13:
/root/pl/metamod-1.17.2/metamod/engine_api.h:261: syntax error before `*'
/root/pl/metamod-1.17.2/metamod/engine_api.h:262: syntax error before `*'
/root/pl/metamod-1.17.2/metamod/engine_api.h:437: syntax error before `*'
/root/pl/metamod-1.17.2/metamod/engine_api.h:438: syntax error before `*'


strange!? i edite the file and make // before the line
then this error appears:

/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status


don't know what these errors are?!
i only want to compile an example from the filebase?!

SnakePr0luck0r
07-10-2004, 20:38
mhh now it works :)

i only have 2 questions
which functions i need for exec a command for example mp_timelimit 30
and how can i wirte something after connection of a client in the console
void ClientPutInServer (edict_t *pEntity)
{
LOG_CONSOLE (PLID, "%s: Client-Connected", Plugin_info.name);
}
won't work only the server see it .

thx snake

Pierre-Marie Baty
07-10-2004, 22:19
There is a macro to execute arbitrary server commands.

SERVER_COMMAND ("your_command_here\n");

it calls pfnServerCommand()

You can get a client's name by looking it up in the engine's string table using the STRING() macro.

STRING (pClientEdict->v.netname)

pClientEdict being an edict_t pointer.

I don't understand what you want exactly. WHEN do you want your mp_timelimit command to be executed ?

SnakePr0luck0r
09-10-2004, 14:54
thx for your help pierre marie :)