SA-MP Forums Archive
Freeze Z coordinate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Freeze Z coordinate (/showthread.php?tid=296196)



Freeze Z coordinate - SA. - 10.11.2011

Hello, I'm trying to freeze Z (height) and I want peoples opinion on the best way to do it. Currently I am doing it like this:

Код:
forward OneHalfSecond();
public OneHalfSecond()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(gPlayer[i][Freeze_Z] == 1)
            {
                new Float:curX,
                    Float:curY,
                    Float:curZ;
                    
				GetPlayerPos(i, curX, curY, curZ);
                SetPlayerPos(i, curX, curY, gPlayer[i][Freeze_Z_Amount]);
			}
        }
    }
}
But obviously it's annoying having the screen jump every 1/2 second. Is there a way to prevent the player from falling at all or is this the only way?

Thanks.


Re: Freeze Z coordinate - SA. - 10.11.2011

up
.
.


Re: Freeze Z coordinate - KoczkaHUN - 10.11.2011

Try TogglePlayerControllable?


Re: Freeze Z coordinate - AndreT - 10.11.2011

Try a combination of freezing the player and changing their positions when keys are pressed (access GetPlayerKeys in OnPlayerUpdate). This doesn't allow them to change camera views but then again keeps the player from falling and annoying resets once a half-second.


Re: Freeze Z coordinate - SA. - 10.11.2011

Yeah this isn't exactly what I want, if anyone knows some hackey way to do this that will allow the camera to move through only scripting or a workaround, please post.

Thanks for suggestions.


Re: Freeze Z coordinate - RyDeR` - 10.11.2011

In a frequent timer:
pawn Код:
SetPlayerVelocity(playerid, 0.0, 0.0, 0.01);
Increase '0.01' if player is still sinking.


Re: Freeze Z coordinate - Ensconce - 10.11.2011

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
In a frequent timer:
pawn Код:
SetPlayerVelocity(playerid, 0.0, 0.0, 0.01);
Increase '0.01' if player is still sinking.
He wants the player to move about the x and y axis so wouldn't it be better to:

pawn Код:
new Float: fVel[3];

GetPlayerVelocity(playerid, fVel[0], fVel[1], fVel[2]);
#pragma unused fVel[2]
SetPlayerVelocity(playerid, fVel[0], fVel[1], 0.01);



Re: Freeze Z coordinate - SA. - 10.11.2011

Thanks for suggestions everyone.

Here's what I want to do. I've put together a script to change coordinates (simply with SetPlayerPos) when a certain key is held. It work's pretty well if the player is on the ground, assuming he can change facing angle. What would be nice is some math that will convert my camera facing angle to player facing angle. The solutions posted so far don't work for my purpose because the player can't change angles since he still falls very slowly.

Thanks.


Re: Freeze Z coordinate - RyDeR` - 10.11.2011

Quote:
Originally Posted by SA.
Посмотреть сообщение
Thanks for suggestions everyone.

Here's what I want to do. I've put together a script to change coordinates (simply with SetPlayerPos) when a certain key is held. It work's pretty well if the player is on the ground, assuming he can change facing angle. What would be nice is some math that will convert my camera facing angle to player facing angle. The solutions posted so far don't work for my purpose because the player can't change angles since he still falls very slowly.

Thanks.
pawn Код:
new
    Float: fCVX,
    Float: fCVY,
    Float: fAngle
;
GetPlayerCameraFrontVector(playerid, fCVX, fCVY, fAngle);
fAngle = atan2(fCVY, fCVX) - 90.0;

// SetPlayerFacingAngle(playerid, fAngle);



Re: Freeze Z coordinate - SA. - 10.11.2011

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
pawn Код:
new
    Float: fCVX,
    Float: fCVY,
    Float: fAngle
;
GetPlayerCameraFrontVector(playerid, fCVX, fCVY, fAngle);
fAngle = atan2(fCVY, fCVX) - 90.0;

// SetPlayerFacingAngle(playerid, fAngle);
This is exactly what I meant, thanks RyDeR and everyone else.