View Full Version : Message to just one person
Mikjen
16th April 2008, 08:10
$this->MsgToAll($msg);
We have insim on our server and would like to change this code.
Does anyone know to make this code, so it sends to 1 person only, IE the person who asks the request...
Thank you
Mick
the_angry_angel
16th April 2008, 08:33
What framework are you using? Something created yourself, or something by filur, Dygear or someone else?
The reason I ask is that's very specific to whatever you're using, and isn't applicable to general insim programming.
shaun463
16th April 2008, 09:10
It's easy with LFS External if you were using C#. MSN me and I'll try and give advice :).
EDIT: IIRC In C# it would be InSim_MTC_MessageToConnection
EDIT 2: I think he is using PHP :(
DarkTimes
16th April 2008, 09:55
What framework are you using? Something created yourself, or something by filur, Dygear or someone else?
I think he is using PHPLFS (http://www.lfsforum.net/showthread.php?t=41397).
So really you would need to change it to something like this...
private function MsgToConnection($ucid, $message, $plid=0)
{
$this->server->sendp(new IS_MTC($ucid, "/msg $message", $plid));
}
If you wanted to be sent only to the person who asked the request, just make sure you put in their unique connection ID (ucid) to send the message to. But it is hard to be sure without more info.
dougie-lampkin
16th April 2008, 11:11
What is the function of the PLID in a MTC? It functions perfectly with it set to 0...
the_angry_angel
16th April 2008, 11:14
You can either use PLID or UCID. If you populate the UCID it will ignore the PLID.
DarkTimes
16th April 2008, 11:46
I think it's the other way round, if you populate the PLID it will ignore the UCID. I might well be wrong though.
Just out of interest, does PHP let you use named parameters? Like this...
private function MsgToConnection($message, $ucid=0, $plid=0)
{
$this->server->sendp(new IS_MTC($ucid, "/msg $message", $plid));
}
$this->MsgToConnection("Hello, world!", $plid=12)
the_angry_angel
16th April 2008, 11:59
I think it's the other way round, if you populate the PLID it will ignore the UCID. I might well be wrong though.It's one way around or the other :shrug: If you consider that they should be mutally exclusive then there's no real reason to get in a flap about which way around they should be used, I guess :)
Just out of interest, does PHP let you use named parameters? Like this...Yes it does.
NabZ245
16th April 2008, 17:58
Seem to be getting this error:
Fatal error: Class 'IS_MSC' not found in C:\LFS\PHP\programs\Stunt\Stunt.inc on
line 239
windstyle
16th April 2008, 18:07
Seem to be getting this error:
Fatal error: Class 'IS_MSC' not found in C:\LFS\PHP\programs\Stunt\Stunt.inc on
line 239
Should be MTC, not MSC. Maybe a typo by DarkTimes.
DarkTimes
16th April 2008, 18:11
Yes, sorry, I made a typo. It should be IS_MTC.
shaun463
16th April 2008, 18:43
LOL Another typo by DarkTimes :). It is MTC not MST lol.
DarkTimes
16th April 2008, 19:03
Whoops sorry. You'll see I actually updated my code posts to the correct thing, I just got brain fade when posting my reply.
dougie-lampkin
16th April 2008, 19:34
That would be a good explaination, I should have realised that :shy:
NabZ245
17th April 2008, 00:59
Worked perfect. Thanks a lot guys :)
Dygear
17th April 2008, 20:16
Just out of interest, does PHP let you use named parameters? Like this...
private function MsgToConnection($message, $ucid=0, $plid=0) {
$this->server->sendp(new IS_MTC($ucid, "/msg $message", $plid));
}
$this->MsgToConnection("Hello, world!", $plid=12)
Yes it does.
And how did I not know this, this changes EVERYTHING! Oh god, I need to revisit my PHPInSim code, as this could make such a HUGE impact on it.
For those of you who did not notice named parameters, in this case it is $plid, if you did not name the parameter the value of 12 would of been passed to the $ucid variable and not the $plid variable. The first happens simply due to order of succession. However, you must know the name of the variable that you want to pass, and you have to give it a value in that same function call.
filur
17th April 2008, 21:31
named variables do not have to follow that order, they can be accepted in any order!
Unfortunately this isn't the case.
<?php
function MsgToConnection($message, $ucid=0, $plid=0)
{
var_dump($ucid, $plid);
}
MsgToConnection('Hello, World!', $plid=12);
function test($var1, $var2, $var3)
{
echo $var1, $var2, $var3, PHP_EOL;
}
test($var3='baz', $var2='bar', $var1='foo');
var_dump($var='value');
?>
Dygear
17th April 2008, 22:20
Unfortunately this isn't the case.
I was all giddy, I thought they did it the right way.
DarkTimes
18th April 2008, 01:27
So PHP doesn't support those sorts of named parameters? I used to program PHP up until a few years ago and I didn't remember ever seeing them before, which is why I asked. I was a very bad PHP programmer though, so it wouldn't have surprised me if I missed something like that.
the_angry_angel
18th April 2008, 01:36
Bugger, sorry guys - I've caused some serious confusion here.
I skimmed the code in DarkTimes' post earlier today, and I clearly didn't read it properly :( I guess I assumed you were asking about predefining parameters (some how). I do apologise :(
Dygear
18th April 2008, 18:18
Bugger, sorry guys - I've caused some serious confusion here.
I skimmed the code in DarkTimes' post earlier today, and I clearly didn't read it properly :( I guess I assumed you were asking about predefining parameters (some how). I do apologise :(
You so got my hopes up! But I forgive you.
the_angry_angel
18th April 2008, 18:34
You so got my hopes up! But I forgive you.Sorry :( I really need to stop partially reading posts :o I'm sure you realise this, but you can fake it, but it mings massively.
Or you can do it "the c way" and pass parameters into functions as arrays, and then array_merge them into some defaults.
Dygear
18th April 2008, 23:13
but you can fake it
Yeah I could do it that way, but god, why would I want to.
And no one fakes it while I'm around. - Sorry, could not help it.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.