The online racing simulator
Gapmon plugin - learn me
Hi!
I don't understand few parts of gapmon plugin code. Can you explain me it?
I'm talking about:

<?php 
$this
->race[$NPL->ReqI] = array(
?>

Shouldn't it be: $NPL->PLID?

<?php 
if(!($NPL->UCID 6))
?>

Lol, why?

<?php 
$BNF
->SubT(BFN_DEL_BTN)->Send();
?>

Maybe BFN_CLEAR?

<?php 
if($diff <= 0)
                        
$BTN->ClickID(101)->BStyle(20)->L($this->BtnX-20)->T($this->BtnY+5)->W(15)->H(5)->Text(number_format($diff 10002))->Send(); # Bottom Left
                    
else
                        
$BTN->ClickID(101)->BStyle(20)->L($this->BtnX-20)->T($this->BtnY+5)->W(15)->H(5)->Text('+'.number_format($diff 10002))->Send(); # Bottom Left
?>

Maybe we can do it like this?:

<?php 
$BTN
->ClickID(101)->BStyle(20)->L($this->BtnX-20)->T($this->BtnY+5)->W(15)->H(5)->Text((($diff <= 0) ? '' '+').number_format($diff 10002))->Send(); # Bottom Left
?>

Am I right? If I'm not, explaim me, where is my bad, please.
I think, few plugins need to be fixed. It's great, that PRISM work without any problem, but watch plugins added to public release.
1. yes it appears it should be plid, not ucid.

2. that & 6 part refers to
Quote : byte PType; // bit 0 : female / bit 1 : AI / bit 2 : remote

and is intended to check that the car is a local player (not ai or remote)
Quote from misiek08 :Hi!
I don't understand few parts of gapmon plugin code. Can you explain me it?

Yeah, I don't really know if the plugin works. I've not had it active in a while, and I wrote the plugin about 6 months ago. I think it was just a toy plugin that I was working to get an idea of how some people would write a plugin within PRISM.
  1. You are right that $NPL->ReqI should be $NPL->PLID, unless there was a reason that I did that on purpose, but I can't think of what that would be right now.
  2. The $NPL->UCID should be $NPL->PType & 6 to check if the player is an AI or remote client. As we really don't want to display buttons onto a AI player's screen as it might interfere with a normal client who is also a player on the server.
  3. Yeah it should be BFN_CLEAR. This function is called within the onRestart callback that I setup within the plugin. After this function, I request NPL packets from the server in order to rebuild the interface. Why I did this, I don't know. But I'm pretty sure it's in order to avoid a bug situation. However, remove the code and see what happens ... It could get interesting!
  4. The ($diff <= 0) ? '' : '+') vs an else statement is a matter of taste. I think I wrote the whole thing out to make it more explicit as to what I was doing for people reading over my code. It's quite easy to miss a ternary operator within a function call like that.
In my defense, I wrote this plugin like I wrote this post. At 4:30 in the morning while I was very tried. The only reason I'm awake right now is because I'm at work, and I'm sure that when I wrote that plugin I was not thinking straight. I'll fix the bugs later on today if I remember and push it in the next update (0.3.6?).
IMO BFN_CLEAR should never be used as it clears buttons of other plugins, too...
There should be an prism button wrapper which takes care of assigning ids etc. Also addons should be able to reserve space on the screen and the wrapper would print a warning if multiple as sons require the same space...


The fix for this plugin would be to set the clickids of the delete button packet
Quote from GeForz :There should be an prism button wrapper which takes care of assigning ids etc.

Easier said then done, trying to come up with a coherent solution to this problem is quite a bit more difficult then I had imagined, but if you want to come up with the syntax for these functions I'm all ears!
Quote from GeForz :Okay you are right!

I tried to put something together but the button concepts are killing me.
Stuff like adding a button for all connections and removing it for a single one... Oo

https://github.com/GeForz/PRIS ... gins/ButtonController.php
https://github.com/GeForz/PRIS ... rrent/plugins/welcome.php

Cool idea for the registerOnClick function. If you're willing to work on this, I'm willing to merge it into the main branch. Although you might want to have a look at my current as it has some updated values for the Powered By Button.

https://github.com/Dygear/PRIS ... rrent/plugins/welcome.php


<?php 
    
public function onClientConnect(IS_NCN $NCN)
    {
        
$BTN = new IS_BTN;
        
$BTN->ClickID(100)->UCID($NCN->UCID)->T(IS_Y_MAX IS_Y_MIN)->L(IS_X_MIN)->W(IS_X_MAX)->H(8);
        
$BTN->Text('Welcome to this ^3PRISM ^7Powered^8 Server.')->Send();
        
$BTN->ClickID(101)->T($BTN->$BTN->H);
        
$BTN->Text('PRISM Version ^7'.PHPInSimMod::VERSION.'^8.')->Send();
        
$this->createTimer('tmrClearWelcomeButtons'15Timer::CLOSE, array($NCN->UCID));
    }
?>

Just a couple of things, move ButtonController into the modules directory, as it's meant to be used by, many, many plugins. From there, I'll add the interface into the Plugins class (Much like timer is given some forwards within the Plugins class.) Great job!

There has also been some huge changes to the gapmon plugin, so I'm sure that misiek08 will want to take a look at that. Just keep in mind, it's not even close to being done yet.

https://github.com/Dygear/PRIS ... urrent/plugins/gapmon.php
Quote from GeForz :Okay you are right!

I tried to put something together but the button concepts are killing me.
Stuff like adding a button for all connections and removing it for a single one... Oo

https://github.com/GeForz/PRIS ... gins/ButtonController.php
https://github.com/GeForz/PRIS ... rrent/plugins/welcome.php

nice nice, I like... will defanitly help me with coding my Cruise insim

This button system + LFS Z35 is gonna be banging... I am certianly looking forward to being able to place objects VIA Insim... really can't wait
OFFTOP: If moving object via InSim will be allowed, we need later only track editor and permission for devs to use modified cars. The LFS can be best simulation game ever in less than 6 month if devs will change "policy action" (Google Translate).
If only, if only.
Quote from Dygear :Cool idea for the registerOnClick function. If you're willing to work on this, I'm willing to merge it into the main branch. Although you might want to have a look at my current as it has some updated values for the Powered By Button.

Jeah I'll try to improve it, but I'll make a new thread in a few days to discuss it and my brain-locks
@Dygear - one thing I have said it's propably done (moving objects). Allowing cars modifications will be only 1 topic from devs. Track editor? Maybe 2-3 months of work for Scawen, he's good programmer.
Quote from misiek08 :@Dygear - one thing I have said it's propably done (moving objects). Allowing cars modifications will be only 1 topic from devs. Track editor? Maybe 2-3 months of work for Scawen, he's good programmer.

He already has a track editor.
Yeah, but I think, they have personalized track editor, not good for public use, for everyone.
I think that if it's good enough for Eric, then it's good enough for us. Just look at the tracks he has made with it!
One more thing.

Gapmon plugin shows node gap. Is it possible to make a timegap plugin? I tried but it ended very quickly. Now I'm working on penalty system.
We would have to value each node with a time, and then add the time of each nodes between two cars. But this could be highly variable depending on if they are in different cars or not. Also, what would you account for, the lead cars time for each node or the tailing cars time? Do you avg both and add that up?
Saving time for each node will take a lot of memory in big events and it's not possible, because InSim don't report same nodes for each car. If you drive fast InSim report e.g. 104, 107,112,116 and for another car 104,108,111,115.

FGED GREDG RDFGDR GSFDG