Author Topic: Script for new player joined  (Read 759 times)

What's the function for when a new player joined and when he joins how do I make a image appear on their screen?

Code: [Select]
package SpawnMessage
{   
    function GameConnection::OnClientEnterGame(%client)
    {
        %client.schedule(500, SendSpawnMessage);
    Parent::OnClientEnterGame(%client);
    }
   
    function SendSpawnMessage(%client)
    {
        CenterPrint(%Client,<IMAGE NAME HERE>,4);
    }
};
ActivatePackage(SpawnMessage);

Code: [Select]
package spawnMessage
{   
function GameConnection::onClientEnterGame(%client)
{
parent::onClientEnterGame(%client);
%client.schedule(500,centerPrint,"<bitmap:path/to/default/image/here>",4);
}
};
activatePackage(spawnMessage);

important note: You can't send a centerprint to people who haven't spawned yet.

Code: [Select]
package spawnMessage
{   
function GameConnection::onClientEnterGame(%client)
{
parent::onClientEnterGame(%client);
%client.schedule(500,centerPrint,"<bitmap:path/to/default/image/here>",4);
}
};
activatePackage(spawnMessage);
Instead, is their a onSpawn function?

Instead, is their a onSpawn function?
Pretty sure it's GameConnection::spawnPlayer(%client).

Okay so Greek2me and swollows's code do the same thing but Lugnut says that the code is wrong because you can't show a message on a players screen until they spawn.  Like wordy said, is there a OnSpawn function?

Okay so Greek2me and swollows's code do the same thing but Lugnut says that the code is wrong because you can't show a message on a players screen until they spawn.  Like wordy said, is there a OnSpawn function?
You don't have a grasp of the series of events.

1. GameConnection::onConnectRequest -- Before client joins. If %client is deleted immediately after this function, their connection is rejected.
2. GameConnection::autoAdminCheck -- After client connects to the server. Called after "Name has connected."
3. GameConnection::onClientEnterGame -- After client has finished downloading and has spawned for the first time.
4. GameConnection::spawnPlayer -- Any time the player spawns or respawns, for the first time or otherwise.

If you want to send a center print the first time a client spawns, package onClientEnterGame, call the parent, and then do a center print. That should work.

When packaging, ensure that all arguments are being considered at all times.

Thanks  :cookieMonster: I got it working now!

Okay so Greek2me and swollows's code do the same thing but Lugnut says that the code is wrong because you can't show a message on a players screen until they spawn.  Like wordy said, is there a OnSpawn function?
OnClientEnterGame is called when they spawn. (for the first time)

There's nothing wrong with using it.