PDA

View Full Version : How to execute a simple php script ?



ibasaw
4th January 2017, 15:09
Hi,

I am noob with libcod and game scripting, but i am a php developer.

My linux 1.3 cod2 is ready, libcod is installed, Rcon is ok, game is running.

How to use libcod and execute a php script ?

By exemple, want to write hello world on the dashboard, when user connect.

I need to understand how libcod communicate with a script in php.

Is there sample of code to read or downnload ?

Thanks for your advice.

++

Mitch
4th January 2017, 15:37
I need to understand how libcod communicate with a script in php.

Is there sample of code to read or downnload ?

Thanks for your advice.

++

You can use the function 'system (https://znation.nl/cod4script/system.htm)' to execute shell commands including php.

Example:

system("curl https://znation.nl/page.php");
system("php page.php");

For more libcod functions see: https://znation.nl/cod4script/

Note: the documentation is incomplete and might not work with all forks.
You can check the source code if a function or method is supported:
https://github.com/kungfooman/libcod/blob/master/gsc.cpp#L203
https://github.com/kungfooman/libcod/blob/master/gsc.cpp#L341

Whiskas
4th January 2017, 16:03
You can add "&" at the end of system() parameter to execute php script in background.

If the script has long execution time, it can lag the server.


system("/usr/bin/php script.php &");

IzNoGoD
4th January 2017, 16:23
You can add "&" at the end of system() parameter to execute php script in background.

If the script has long execution time, it can lag the server.


system("/usr/bin/php script.php &");

I like it :)

filthy_freak_
5th January 2017, 04:56
This is what he said to me before I sent him here;


hi,

I got a dedicated server and got cod2 linux server.

I don't know how to customize the server, add script, mod, ...

Ressources are rare because the game is pretty old, and this is difficult to find info on internet which are not closed or outdated.

I am a PHP developer, but i don' t know where to begin ?

So to begin, navigate to your main folder. There are mainly two files we'll be looking at, iw_07.iwd and iw_15.iwd (We're only looking at iw_15.iwd because you're using 1.2/1.3, if using 1.0 there will be no iw_15.iwd file).

Open those files using WinRAR. Navigate to maps\mp\gametypes. Here you will find the gametype files for CoD2 (ctf.gsc, sd.gsc, tdm.gsc etc). Look through them and try to understand how it works as those are the main files you should be using as a beginner. If using 1.2/1.3, look in the iw_15.iwd for the file you are editing and use that instead of the one in iw_07.iwd.

After making whatever changes you want to the gametype file, create a new .iwd file from scratch named zzz_yourmodnamehere.iwd. Now you need to make a few folders in that .iwd file, maps\mp\gametypes, because that is where CoD2 looks for the gametype files by default. Put your edited gametype.gsc file in there then it is ready to be uploaded to the server as a mod.

Put the mod in your main folder or fs_game folder if you have that setup.

I suggest setting developer 1 in the startup commands because it will show you a detailed error msg if there are any errors in your code.

IzNoGoD
5th January 2017, 12:57
Addendum to filty_freak's post: a .iwd file is just a renamed .zip file. Dont package it as .rar though, that fucks shit up.