Author Topic: How do you make a on spawned event work correctly.  (Read 1672 times)

OnConnected with delay dosn't work.
How do have a function that turns on when a player spawns?


OnClientEnterGame


Code: [Select]
function GameConnection::onClientEnterGame(%this)
{
%this.mtki = "m";
}


Freezes up the game.

Tom

You need to call the parent. And onClientEnterGame is only when they spawn for the first time.

You need to call the parent. And onClientEnterGame is only when they spawn for the first time.


I said onClientEnterGame wasn't what I wanted.
But for this It's okay. Now how do I do the "Calling of the parent." that you speak of?


Also: How do you map a key for one person olny?
« Last Edit: July 08, 2009, 08:53:46 PM by Azjherben »

Also: How do you map a key for one person olny?
Can only be done client sided.

Parent thing (READ THIS): http://forum.blockland.us/index.php?topic=21811.0
Use gameConnection::spawnPlayer.
« Last Edit: July 11, 2009, 11:13:16 PM by Amade »

Code: [Select]
$dscale = "0.5";
$spawnyes = 1;


function setscaleofguy(%client)
{
echo("Okay.");
%client.player.setplayerscale($dscale);
}

package kat {

function GameConnection::onClientEnterGame(%this)
{

if($spawnyes == 1){
$ST = schedule(500,0, setscaleofguy,%this);
}
}

};



activatepackage(kat);


...Didn't work either.

Code: [Select]
$dscale = "0.5 0.5 0.5";
$spawnyes = 1;


function setscaleofguy(%client)
{
    echo("Okay.");
    %client.player.setScale($dscale);
}

package kat
{
    function GameConnection::onClientEnterGame(%this)
      {
             if($spawnyes == 1)
             {
                  schedule(500,0, setscaleofguy,%this);
             }
      }
      Parent::onClientEnterGame(%this)
};
activatepackage(kat);


...Didn't work either.

First of all its setScale(%vector); not setplayerscale($vector);. %vector should be 3 sets of numbers so I will fix up what I see wrong. Also, organize your codes more, this is a mess. My code SHOULD work, but no guarantees. You make your code so much more complicated than it should be, also, this will only work the first time they spawn, not every time.
« Last Edit: July 09, 2009, 03:42:27 PM by lilboarder32 »

Both scripts are missing Parent::onClientEnterGame(%this);

Both scripts are missing Parent::onClientEnterGame(%this);

I noticed, let me look at default minigame script.
And setscale could be one thing I thought.

Tom

First of all its setScale(%vector); not setplayerscale($vector);. %vector should be 3 sets of numbers so I will fix up what I see wrong. Also, organize your codes more, this is a mess. My code SHOULD work, but no guarantees. You make your code so much more complicated than it should be, also, this will only work the first time they spawn, not every time.
setPlayerScale should work. And setPlayerScale doesn't need a vector.

Ok, SetPlayerScale works then, my bad. And I forgot to parent, woops. Added Parent to my script.
« Last Edit: July 09, 2009, 03:45:10 PM by lilboarder32 »

Ok, SetPlayerScale works then, my bad. And I forgot to parent, woops. Added Parent to my script.


So how do I get it to be onSpawn each time the person Spawns?
Oh, and your parent is broke.
« Last Edit: July 10, 2009, 09:30:22 AM by Azjherben »

You have the parent function outside of any actual function and instead in the package, which will cause syntax errors.

Using GameConnection::onConnected will not work as it's a protected function and cannot be packaged or replaced. Use GameConnection::autoAdminCheck instead.