swim system

Started by MEGAMIND, Oct 02, 2018, 03:08 AM

Previous topic - Next topic

MEGAMIND

A bit updated and better swim system then previous version

function onScriptLoad()
{
swimming <- array(100,false)
I <- BindKey(true, 0x49,0,0); // forward
J <- BindKey(true, 0x4A,0,0); // left
K <- BindKey(true, 0x4B,0,0); // back
L <- BindKey(true, 0x4C,0,0); //right
O <- BindKey(true, 0x4F,0,0); //jump
}

function onPlayerHealthChange( player, lastHP, newHP )
{
if ( (player.Pos.z <= GetWaterLevel()) && (swimming[player.ID] == false))
{
MessagePlayer( "[#ff00ff]=======(Jump in Water)=======", player );
MessagePlayer( "[#ffffff]USE I, J, K, L, O for movement in water", player );
swimming[player.ID] = true
return true;
}
player.Health = 100;
player.SetAnim(0,149);
local vector1 = Vector ( player.Pos.x+10, player.Pos.y, player.Pos.z+5 ), vector2 = Vector ( player.Pos.x, player.Pos.y, player.Pos.z );
player.SetCameraPos( vector1, vector2 );
}

function onKeyDown( player, key )
{
if( key == I )
{
if ( player.Pos.z <= GetWaterLevel() ) {
 player.Pos.x++;
       }
}
if( key == J )
{
if ( player.Pos.z <= GetWaterLevel() ) {
     player.Pos.y++;
       }
}
if( key == K )
{
if ( player.Pos.z <= GetWaterLevel() ) {
player.Pos.x--;
 }
}
if( key == L )
{
if ( player.Pos.z <= GetWaterLevel() ) {
 player.Pos.y--;
       }
}

//==jump out of water and change directions==============
if( key == O )
{
if ( player.Pos.z <= GetWaterLevel() ) {
 player.Pos.z++;
player.RestoreCamera();
}
}
}
Features:
1.Everything is same (swimstyle , movement keys).
2.While swimming Screen camera moves like as if ur being spectated.
3.Players Glitching into falls and other stuff is fixed.

Credits: @UrbanY
QuoteTo avoid the abuse of players like evade among other things (Glitching everywhere..)

Sebastian

Dude. Keep every "swimming" system in one thread. No need to open 9999 topics about it.
UPDATE the topic, like everybody else in this world...

I will let you clean everything, and stick to one and only.