The online racing simulator
PHPInSimMod - PRISM 0.1.9 Discussion
You can download PHPInSimMod - PRISM 0.1.9 from that link. Please use this thread to talk about this release.

Thank you.

PHPInSimMod (PRISM) 0.1.9
  • Finished interactive startup.
  • Made sample config files.
  • Added very basic plugin interface to PRISM.
    • Plugins can now send packets, not just receive them. (Via $this->sendPacket());
    • Added a fullback constructor to the plugins class, should there not be one in the child plugin.
    • Fixed the three shutdown error messages and cleaned up the look of the packet module.
    • plugins::registerPacket function accepts a variable number of packets.
    • Added plugin list to the available console commands under 'P'.
    • Made sure plugins only get packets from their subscribed hosts.
  • Cleaned up some extra information being printed to the console and made it respect the debug level.
  • Added emergency defaults for the cvars array, made not having a cvar.ini file a non fatal error.
If you want to test the plugin interface, type "!thetime", "thetime", "!time" or "time". It will print the server time to your client.
I had a bit of a mess around and I had some comments. I know it's early in development and it's not finished, but here they are anyway.

- The packet initialization code is a little clunky. It would be nice if you could set packet properties in the constructor with optional parameters, so you could do something like this:

$this->sendPacket(new IS_MTC(Msg='Hello, world!', UCID=0));

- I cannot see any way to tell which host sent a specific packet or specify which host to send a packet to.

- The ISI prefix doesn't work, I had to change it to...

isi->Prefix = ord('!');

But aside from that it's looking good. As I say I know it's early in development, but thought I'd mention them anyway.

Good work so far though!
Hi,

Great work

I tested PRISM 0.1.9 and it worked good.
Win7 32 and PHP 5.3.3

The autoini wizzard works super. very good idea

I have some questions

1: Is it posible (in future) to start the wizzard again to make changes (to add or remove Plugins) or to add or remover a server?

2: Is it posible (in future) to start or stop PRISM to one or more servers?
example: type !stop [ID of host] to stop PRISM on that host or type !start [ID of host] to start PRISM on that host
1) the wizard creates ini files in your PRISM/config/ folder which you can edit manually to change any config setting at any time. The wizard is primarily there for people who never ran PRISM before and 'just run it' without first reading up on configuration. They then get the chance to manually set it up. But I'd recommend everyone to first have a look at the config folder and the sample ini files in there. They provide a bit more insight tbh.
You can of course just delete the ini files in your config folder and then prism will fire off the wizard again. But editing the ini files directly is easier.

2) I'm not sure if starting stopping prism _through an LFS host_ can be done, or should be done. The best option to connect / disconnect hosts to / from prism is on prism's console window. You canot even give commands via an LFS host if it's not connected to prism, so that can be a bit pointless
But he has a point, which is adding/removing prism from a server without restarting prism and thus interfering with prism running on other servers.
first thought would be 'can add console commands', but then I remember stupid windows doesn't cooperate there
But, I had the thought of making a www admin page, where the admin can add / remove connections, plugins, etc and view status. That could be a nice solution i think.
Quote from DarkTimes :I had a bit of a mess around and I had some comments. I know it's early in development and it's not finished, but here they are anyway.

Ok, as long as your gentle .

Quote from DarkTimes :- The packet initialization code is a little clunky. It would be nice if you could set packet properties in the constructor with optional parameters, so you could do something like this:


$this->sendPacket(new IS_MTC(Msg='Hello, world!', UCID=0));


Yeah, I agree on that point. But I can't do aliased or name arguments to give args out of order. The only thing I could do is hand the constructor a string and let it tokenized that (and to be frank, that's not great.) I've been thinking about this for quite some time. Still no closer to an answer.

Quote from DarkTimes :- I cannot see any way to tell which host sent a specific packet or specify which host to send a packet to.

Yeah, I wanted to keep it simple for the plugin programmers. The sendPacket function knows what host sent the last packet, so when you send a packet back it knows what host to send it too. If you wanted to talk to another host tho, it's not currently possible, but I could add an arg to the sendPacket function that would allow that. The idea being that the plugin programmer should not have to think to much, for them PRISM's code does all of the heavy lifting and they can concentrate on making a great plugin.

Quote from DarkTimes :- The ISI prefix doesn't work, I had to change it to...

isi->Prefix = ord('!');


- I'll fix that in the next release.

Quote from DarkTimes :But aside from that it's looking good. As I say I know it's early in development, but thought I'd mention them anyway.

Good work so far though!

Yeah, I'm pretty lucky to have a lot of help . Thanks for the input, and for being gentle.

Quote from Tim NL :1: Is it posible (in future) to start the wizzard again to make changes (to add or remove Plugins) or to add or remover a server?

Quote from Victor :You can of course just delete the ini files in your config folder and then prism will fire off the wizard again. But editing the ini files directly is easier.

Yeah, I really don't plan on making an editor for the config files. I think the current system works very well. And if you should load a new plugin there should be enough examples within the config files already to help you edit it. If that's not what you wanted, delete the file and prism will make another one for you, and ask you what you want this time.

Quote from Tim NL :2: Is it posible (in future) to start or stop PRISM to one or more servers?
example: type !stop [ID of host] to stop PRISM on that host or type !start [ID of host] to start PRISM on that host

Quote from Victor :2) I'm not sure if starting stopping prism _through an LFS host_ can be done, or should be done. The best option to connect / disconnect hosts to / from prism is on prism's console window. You canot even give commands via an LFS host if it's not connected to prism, so that can be a bit pointless

Quote from GeForz :But he has a point, which is adding/removing prism from a server without restarting prism and thus interfering with prism running on other servers.

It's a planned future feature from my stand point. Both connections and plugins can be stoped, started, and paused.

Connections:
!prism stop - Sends a good bye packet, and ends the connection.
!prism start - Sends a hello packet (ISP_ISI) to a new host. (Client must be using this command for the PRISM console, or be in a sever they have admin RCON level admin privilege on, and be an admin on the server they wish to start PRISM on, with RCON level admin privileges there too.)
!prism pause - Same as pausing all plugins, will still maintain it's own internal connection and player arrays, and respond to pings (ISP_TINYs), but no plugins will get any packets. Twice to toggle.

Plugins
!prism plugin start <plugin> - Plugin included, and is loaded to accept packets from the current hosts. If done from console, should be asked what hosts to attach too. If done from in server will start on that server only. (Or if the plugin is already loaded on another server, plugin will start getting packets from this server.)
!prism plugin stop <plugin> - Plugin unloads, __destruct is called on the plugin (if available).
!prism plugin pause <plugin> - Plugin no longer gets any packets. Twice to toggle.


Quote from Victor :first thought would be 'can add console commands', but then I remember stupid windows doesn't cooperate there
But, I had the thought of making a www admin page, where the admin can add / remove connections, plugins, etc and view status. That could be a nice solution i think.

A web interface, that would be sick!
I'd prefer "Style 3 - OOP, Arrays and it's own send method built in!" for sending messages
Quote from GeForz :I'd prefer "Style 3 - OOP, Arrays and it's own send method built in!" for sending messages

How about all of these above? 1, 2, 3 & 4! 4 being the style that DarkTimes suggested (Via a parsed, tokenized string?)
dygear, I think it's time you wrote that 'what is this' document and 'how it should work' because I think you are the only one who really knows atm

I get the feeling (and you said something to that extent on irc) that you want prism to be something that can be used by people who don't know a lot about programming. That's great of course, but through little hints here and there I get the feeling it's not going to be very interesting for the advanced programmers because while trying to keep it easy, you are also adding restrictions to what a plugin can do.
If I'd use prism because it has a decent core to build upon, I'd want full control over whatever I want to do with the hosts. I don't want to just send replies to hosts, but I want to be able to send anything I want to a host at any time!

So, that's why I'm asking for some docs on what prism should be and how it will work, schematically. Because then we can get a better picture of what's in your head and comment on it in order to improve on your ideas. Right now I'm not really sure what to say, apart from this post.
Quote from Dygear :Ok, as long as your gentle .

Yeah, I agree on that point. But I can't do aliased or name arguments to give args out of order. The only thing I could do is hand the constructor a string and let it tokenized that (and to be frank, that's not great.) I've been thinking about this for quite some time. Still no closer to an answer.

OK - I didn't realise PHP didn't support those sorts of optional parameters, the way that Python and C# 4.0 do. Seems rather strange to me that it doesn't.
The form you postet is rather uncommon afaik.
The closest thing to that in php is to call the constructor with an array with such mapping.
Quote from Victor :dygear, I think it's time you wrote that 'what is this' document and 'how it should work' because I think you are the only one who really knows atm

Yeah, I hope that's not pissing to many people off. I guess I'll start to flesh out my ideas in this post.

Quote from Victor :I get the feeling (and you said something to that extent on irc) that you want prism to be something that can be used by people who don't know a lot about programming. That's great of course, but through little hints here and there I get the feeling it's not going to be very interesting for the advanced programmers because while trying to keep it easy, you are also adding restrictions to what a plugin can do.
If I'd use prism because it has a decent core to build upon, I'd want full control over whatever I want to do with the hosts. I don't want to just send replies to hosts, but I want to be able to send anything I want to a host at any time!

I started off programming in 2004, and I can't believe that was almost 7 years ago, making simple plugins for AMX Mod that was at the time the de facto standard for administration and modification on Counter-Strike 1.5. AMX Mod came with a plugin interface via the SmallC programming language, SmallC is now known as PAWN by the way, providing a simple interface into the Counter-Strike engine provide by AMX Mod. So when a client would for example say something in the game, the plugin you wrote was notified by the callback mechanism within AMX Mod. AMX Mod would fire the SmallC function in your compiled code. AMX Mod also added an admin interface and admin commands into the mix. Along with the engine hooks this provided a very powerful interface into the Counter-Strike engine with little to no known of how the engine worked. It was event based programming at it's best. Something happens in the game, your code then get's called. Simple as that.

For the most part, that's all that mattered. You did not need to know about the underpinnings of the engine, you did not have to do pointer math, you did not even have to know what V-Tables where. All you had to do was find the callback for the event that you where looking for, and find the function that would get you the information you needed. These things combined make for a pretty easy way to program for AMX Mod, and for Counter-Strike.

With this in mind, I set out to make PRISM to AMX Mod of Live For Speed.
  • Prism will provide a admin interface in AMX Mod's footsteps, with some augmentation as PRISM can run on multiple servers at once.
  • It will provide a plugin interface that allows for hooking onto game based events.
  • It will do it's very best to keep it easy for the one programmer just starting out to program for just one server.
  • It will allow for advanced programmers to make whole systems within PRISM. Everything that the core has to leverage will be given to the programmer to so that they can expand on contract as they see for for their situation.
Quote from Victor :So, that's why I'm asking for some docs on what prism should be and how it will work, schematically. Because then we can get a better picture of what's in your head and comment on it in order to improve on your ideas. Right now I'm not really sure what to say, apart from this post.

Where should I start with this? "Passage of a packet through PRISM?" Because I think you would be a better author of that post at this point. I could do an "Anatomy of a Packet Callback," or anything else that you think would be appropriate.


Quote from DarkTimes :OK - I didn't realise PHP didn't support those sorts of optional parameters, the way that Python and C# 4.0 do. Seems rather strange to me that it doesn't.

Quote from GeForz :The form you postet is rather uncommon afaik.
The closest thing to that in php is to call the constructor with an array with such mapping.

We do what we can with what we have.
Quote from Dygear :Where should I start with this? "Passage of a packet through PRISM?" Because I think you would be a better author of that post at this point. I could do an "Anatomy of a Packet Callback," or anything else that you think would be appropriate.

hmm no i think the connection part should not really be mentioned in the docs. That's transparent for the plugin writer basically.

I was thinking more of how-to docs for them, the plugin writers.
-How to start writing a plugin (the basic skeleton - the extending onto the plugins class)
-Registering a packet handler
-how to write packets to one or more hosts
-what NOT to do (eg. create your own 'main' loops inside a plugin)

and eventually all the methods a plugin can use

Then the more complete that doc gets along with time, the better the picture will be of what we can and cannot do with plugins.
Oh and (am I providing enough work for you?) the admin system could be laid out as well. Ppl will need to understand how that works, because it's way more than the regular admin or no admin situation.
Quote from Victor :I was thinking more of how-to docs for them, the plugin writers.
-How to start writing a plugin (the basic skeleton - the extending onto the plugins class)
-Registering a packet handler
-how to write packets to one or more hosts
-what NOT to do (eg. create your own 'main' loops inside a plugin)

and eventually all the methods a plugin can use

Then the more complete that doc gets along with time, the better the picture will be of what we can and cannot do with plugins.

Agreed! I'll work on this just a little after I'm done with the admin system.
i was wondering why u use


<?php 
        
if ($M == '!thetime' OR $M == 'thetime' OR $M == '!time' OR $M == 'time')
        {
            
$MTC = new IS_MTC();
            
$MTC->PLID = ($p->PLID) ? $p->PLID NULL;
            
$MTC->UCID = ($p->UCID) ? $p->UCID NULL;
            
$MTC->Msg 'The time is: ' date('H:i:s') . ' server local time';
            
$this->sendPacket($MTC);
        }
?>


<?php 
switch ($M) {
    case 
'!thetime': case 'thetime': case '!time': case 'time':
            
$MTC = new IS_MTC();
            
$MTC->PLID = ($p->PLID) ? $p->PLID NULL;
            
$MTC->UCID = ($p->UCID) ? $p->UCID NULL;
            
$MTC->Msg 'The time is: ' date('H:i:s') . ' server local time';
            
$this->sendPacket($MTC);
        break;

}
?>

also is there a way to show buttons?
Quote from Fire_optikz001 :i was wondering why u use


<?php 
        
if ($M == '!thetime' OR $M == 'thetime' OR $M == '!time' OR $M == 'time')
?>


<?php 
switch ($M) {
    case 
'!thetime': case 'thetime': case '!time': case 'time':
?>


It was quicker .

Quote from Fire_optikz001 :also is there a way to show buttons?

Not at this very second, not without modifying the IS_BTN class. (Unless I fixed it and forgot.)
Quote from Dygear :It was quicker .



Not at this very second, not without modifying the IS_BTN class. (Unless I fixed it and forgot.)

also double checking ... i can use any php function in the script?

and how to make my own plugin
Quote from Fire_optikz001 :also double checking ... i can use any php function in the script?

and how to make my own plugin

Anything that your version of PHP can understand, yes.

However, don't make main loops in your code. You'll stall out the whole thing. Never put while(true) anywhere in a plugin. It's bad juju.
Quote from Dygear :Anything that your version of PHP can understand, yes.

However, don't make main loops in your code. You'll stall out the whole thing. Never put while(true) anywhere in a plugin. It's bad juju.

nvm
owkay, got a http server running in prism.
It's not ready yet to be pulled into current - i have to run through a couple of things first to optimise a bit and check security, but you can see it at work here : http://vic.lfs.net:1800/
It just presents you with a form and it will print out all the POST values after you submit the form. You can also write GET values into the url and it'll show those as well.

Or in other words, this http server can at the moment parse and validate http requests, including parsing your GET and POST variables. It does not yet support cookies. Will work on that later, but it's break time now File uploads will prolly not work either yet - haven't tested. (as in, it'll probably reject your request. Obviously i know if a file would be saved or not )
Damn thee oh javascript cross domain forbidance

(or something like that; I wrote a test_plugin which writes data into json file in my webserver dir; but perhaps that could be handled directly... ^^)
I've pushed the new branch http to my repo for if anyone feels like checking it.
Still not finished (needs some extra work in the safety department), but I'm kinda done for today.
Cookies work now.
1

FGED GREDG RDFGDR GSFDG