Author Topic: GameConnection::spawnPlayer - Stuck on Loading Objects  (Read 1211 times)

Pretty simple, this line below gets me stuck on Loading Objects.  I can mess with F8/F7 and see the world but I won't have a character and would just be an invisible person, just watching.
Code: [Select]
function GameConnection::spawnPlayer(%client)
{
talk("A summoner has reconnected!");
}

You didn't package it. Also, if you only want to do this when they finish loading, use ::onClientEnterGame instead.

(If this is server sided)Don't forget to parent it.

Here you go, packaged and parented.
Code: [Select]
package somepackage
{
function GameConnection::spawnPlayer(%Client)
{
parent::spawnPlayer(%Client);
//Do Stuff Here
}
};
activatepackage(somepackage);

No. spawnPlayer returns the created player object. Do not use that code, you will break other add-ons.

Code: [Select]
package somepackage
{
function GameConnection::spawnPlayer(%client)
{
// Stuff that happens before the player spawns.

%result = parent::spawnPlayer(%client);

// Stuff that happens after the player spawns.

return %result;
}
};
activatepackage(somepackage);

Always, always, always check to see if the parent returns a value when packaging a function or you will break core functionality.

P.S. It violates coding semantics to start a variable with a capital letter.
« Last Edit: January 30, 2012, 11:03:58 AM by CityRPG »

No. spawnPlayer returns the created player object. Do not use that code, you will break other add-ons.

Code: [Select]

Always, always, always check to see if the parent returns a value when packaging a function or you will break core functionality.

P.S. It violates coding semantics to start a variable with a capital letter.

Last time I used it, ::spawnPlayer returned the client. ::createPlayer returns the new player.

Oof, you're right.

Still, it is returning a value and if it is you need to return it in your code. The only time I do not return the result is when setting a variable to parent:: issues a warning in the console.