Getting Client
by Nathan Kent · in Technical Issues · 10/21/2007 (3:23 pm) · 2 replies
I've been working on a function to send the player to a new level:
As you can see, I've got the %client variable. So when I use that, how would I get the handle of the client who entered the trigger?
function travelTrigger::onEnterTrigger(%this, %client) {
Parent::onEnterTrigger(%this,%trigger,%obj);
%goTo = %this.goWhere;
%transform = %this.setDown;
%this.getScenegraph().schedule(100,"loadLevel","game/data/missions/" @ %goTo);
%client.player.setTransform(%transform);
}As you can see, I've got the %client variable. So when I use that, how would I get the handle of the client who entered the trigger?
About the author
#2
11/21/2007 (9:54 am)
Someone a while back posted a "switchMissionTrigger" resource. It works really well. Just wish I had caught the name and written it down so that when I use it, I can give him credit. But.. Here is his code:datablock TriggerData (TriggerSwapMission)
{
tickPeriodMS = 100;
};
function TriggerSwapMission::onEnterTrigger(%this,%trigger,%obj)
{
%client = %obj.client;
if(!%client)
{
// return if not a client
// we do not want any npc or other players walking into our trigger and seting off the swap mission
return;
}
%ZoneName = %trigger.ZoneName; // mission name
%SpawnPoint = %trigger.SpawnPoint; // Spawn Point in mission
echo("Zone client:" SPC %client SPC "to" SPC %ZoneName SPC "at" SPC %SpawnPoint);
schedule( 0, 0, loadMission, "starter.fps/data/missions/" @ %ZoneName,false,%SpawnPoint);
}
You can ether specify there values statically in the trigger code
%ZoneName = %trigger.ZoneName;
%SpawnPoint = %trigger.SpawnPoint;
eg
%ZoneName = "newMission.mis";
%SpawnPoint = "2";
Or you can set dynamic values on each trigger, F11 > Would Editor Inspector, click on the trigger you want to change and add two dynamic value "ZoneName" and "SpawnPoint"It works really well for single player games, but in multiplayer it drags all players with you.
Associate Ross Pawley