Results 1 to 6 of 6

Thread: How to execute a simple php script ?

  1. #1
    ... connecting
    Join Date
    Jan 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to execute a simple php script ?

    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.

    ++

  2. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by ibasaw View Post
    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' to execute shell commands including php.

    Example:
    PHP Code:
    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...r/gsc.cpp#L203
    https://github.com/kungfooman/libcod...r/gsc.cpp#L341

  3. #3
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    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.

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

  4. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by Whiskas View Post
    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.

    PHP Code:
    system("/usr/bin/php script.php &"); 
    I like it
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  5. The Following User Says Thank You to IzNoGoD For This Useful Post:

    Whiskas (5th January 2017)

  6. #5
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    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.

  7. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •