Vice City: Multiplayer

Server Development => Scripting and Server Management => Script Showroom => Topic started by: Mohamed Boubekri on Jul 14, 2023, 09:10 PM

Title: Walking System (now tommy can walk like a civilian)
Post by: Mohamed Boubekri on Jul 14, 2023, 09:10 PM
Hey everyone, i have made this simple script for roleplay servers especially, have fun!

How to use: if you want to walk keep pressing alt, and stop pressing it if you want to stop.
Preview: https://www.youtube.com/shorts/TpJf7rXvkXo
Server-side:
enum StreamType
{
    a1 = 0x01
    a2 = 0x02
}

function onClientScriptData( player )
{
    local stream = Stream.ReadByte();
    switch ( stream )
    {
        case StreamType.a1:
        {
        if (player.Vehicle) return;
        player.SetAnim(0,0);       
        }
        break;   
        case StreamType.a2:
        {
        if (player.Vehicle) return;
        player.SetAnim(0,2);       
        }
        break;               
    }
}
Client-side:
enum StreamType
{
    a1 = 0x01
    a2 = 0x02
}
alt <- KeyBind( 0x12 );
local walking=false;

function Script::ScriptProcess()
{
if (walking == true) {
SendDataToServer(StreamType.a1);
}
}
function KeyBind::OnDown(key)
{
if (key == alt )
{
walking = true;
}
}
function KeyBind::OnUp(key)
{
if (key == alt )
{
walking = false;
SendDataToServer(StreamType.a2);
}
}
function SendDataToServer( ... )
{
    if( vargv[0] )
    {
        local   byte = vargv[0],
                len = vargv.len();
               
        if( 1 > len ) Console.Print( "ToClent <" + byte + "> No params specified." );
        else
        {
            local pftStream = Stream();
            pftStream.WriteByte( byte );

            for( local i = 1; i < len; i++ )
            {
                switch( typeof( vargv[i] ) )
                {
                    case "integer": pftStream.WriteInt( vargv[i] ); break;
                    case "string": pftStream.WriteString( vargv[i] ); break;
                    case "float": pftStream.WriteFloat( vargv[i] ); break;
                }
            }
           
            Server.SendData( pftStream );
        }
    }
    else Console.Print( "ToClient: Not even the byte was specified..." );
}
The system now is clean without any lag.
Title: Re: Simple Walking System
Post by: habi on Jul 15, 2023, 12:51 AM
Nice
Title: Re: Simple Walking System
Post by: H.a.S.a.N on Aug 09, 2023, 04:36 PM
Wow bro cool system
 :)   ;)
Title: Re: Simple Walking System
Post by: Mohamed Boubekri on Aug 09, 2023, 11:29 PM
Thank you friends, but I think that NewTimer Func cause lag in the server especially if the server fraught of players, so we all need to make effort to make the player capable to walk with a simple repeatedly function.
Title: Re: Walking System (now tommy can walk like a civilian)
Post by: Mohamed Boubekri on Nov 01, 2023, 11:18 AM
Note: The system has been updated you can see that above.
We are using now client-function which is ScriptProcess(), because NewTimer func cause lag in the server.
Don't delete this one "player.SetAnim(0,2)" because it's necessary to stop the walking animation.
Title: Re: Walking System (now tommy can walk like a civilian)
Post by: PSL on Nov 03, 2023, 07:04 AM
Nice feature. Well done, brother