The online racing simulator
#1 - PoVo
[Packet Handling Help] Packet Event not working?
Hey,

I'm having problems with my non-IS_MSO packets. I basically registered an IS_NCN packet, but it doesn't seem to be working.

Here's my code:


public function __construct()
{
$this->registerPacket(ISP_NCN, 'ConConnects');
}


public function ConConnects(IS_NCN $NCN)
{
$MTC = new IS_MTC();
$MTC->UCID($NCN->$UCID)->Msg(sprintf('%s ^7Welcome to %s', self::PreMsgStl, self::GameName))->Send();
return PLUGIN_CONTINUE;
}

The PreMsgStl and GameName are "const" defined along with the AUTHOR, NAME etc. And are working in the IS_MSO event.

Thanks,
Povo.
I don't really know PHP (as I'm sure everyone has worked out ), but I think your syntax is a bit mixed up. I think you have the registerPacket parameters the wrong way round. Also in PHP you don't need to specify the type of the param (maybe it's optional though, I dunno). Try this:

public function __construct()
{
$this->registerPacket('ConConnects', ISP_NCN);
}

public function ConConnects($NCN)
{
$MTC = new IS_MTC();
$MTC->UCID($NCN->$UCID)->Msg(sprintf('%s ^7Welcome to %s', self::PreMsgStl, self::GameName))->Send();
return PLUGIN_CONTINUE;
}

#3 - PoVo
The syntax isn't mixed up, since Dygear told me to use it that way, but I will test it in a sec

Edit: Never mind, Dygear gave me the registerPacket code the wrong way around, your way works! Thanks!
Quote from PoVo :The syntax isn't mixed up, since Dygear told me to use it that way, but I will test it in a sec

Edit: Never mind, Dygear gave me the registerPacket code the wrong way around, your way works! Thanks!

Oh, no, I confused my own syntax :redface:.
#5 - PoVo
Quote from Dygear :Oh, no, I confused my own syntax :redface:.

Don't worry, it happens
Quote from DarkTimes :Also in PHP you don't need to specify the type of the param (maybe it's optional though, I dunno).

You can, but it really has not effect on how the program runs. It will emit a notice but that's it. It's just Type Hinting so that IDE's and programmers know what the function expects. You can make it a fatal error, should the type hint fail, but you would have to do so programmatically yourself.

One last thing on the subject, you can't type hint a data type. String's, int's and float's can't be type hinted, only objects can.

FGED GREDG RDFGDR GSFDG