Back to the Vavoom Forum Archives


Forum

Sending command from client side to server side

Wed, 04 Jul 2007 12:24:14

Crimson Wizard

This question comes periodically - what's the better way to call some particular function at server side (Player's, GameInfo's etc)? For example, I needed to make an in-game menu option to remove a bot. Thus, it had to make a call of DisconnectBot from corresponding Player object somehow. The only method I was able to find was following: I got a first met player's ReplicationInfo with bIsBot flag set, then passed an impulse command with number = (custom constant + RepInfo.PlayerNum), and then made PlayerImpulse parse this command and call DisconnectBot for corresponding player. Frankly, using 'Impulse' looks like sort of pervertion. <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: --> Is there a better way to do such things?
Thu, 05 Jul 2007 17:40:02

Janis Legzdinsh

You can have a separate method in Player class for this, that will be executed on server side. Something like this:
void ServerDropBot(byte Index)
{
    Level.Game.Players[Index].DisconnectBot();
}

replication
{
    reliable if (bIsClinet)
        ServerDropBot;
}
Fri, 06 Jul 2007 12:36:30

Crimson Wizard

Hmm, this works and is very convenient. I think I finally got the idea of new client-server cooperation method. Thanks.

Back to the Vavoom Forum Archives