pawn Код:
new cameraobject[MAX_PLAYERS] = -1;
CMD:freeze(playerid, params[])
{
new Float:x, Float:y, Float:z;
GetPlayerCameraPos(playerid, x, y, z);
cameraobject[playerid] = CreateObject(19475, x, y, z, 0.0, 0.0, 0.0); //19475 is an invisible object with no collision
AttachCameraToObject(playerid, cameraobject[playerid]);
ApplyAnimation(playerid, "ped", "IDLE_stance", 4.1, 1, 0, 0, 0, 0, 1);
return 1;
}
CMD:unfreeze(playerid, params[])
{
ClearAnimations(playerid);
SetCameraBehindPlayer(playerid);
DestroyObject(cameraobject[playerid]);
cameraobject[playerid] = -1;
return 1;
}
Rather than using TogglePlayerControllable, you can simply apply the idle animation to the player which simulates the same effect that TogglePlayerControllable has. They cannot move and they cannot move their camera, but the camera itself isn't actually frozen..
The two commands above just represent how you would freeze and unfreeze with the functions such as ApplyAnimation and AttachCameraToObject. The cameraobject[playerid] idea is optional, but I recommend it to save yourself from having hundreds of invisible objects scattered across the server without you knowing it, thus freeing up some space for additional objects.
To 'freeze' the player:
pawn Код:
ApplyAnimation(playerid, "ped", "IDLE_stance", 4.1, 1, 0, 0, 0, 0, 1);
To unfreeze the player:
pawn Код:
ClearAnimations(playerid);
To enable camera movement: (This is really only if you want the camera to not be focused on the player)
pawn Код:
cameraobject[playerid] = CreateObject(19475, x, y, z, 0.0, 0.0, 0.0); //19475 is an invisible object with no collision
AttachCameraToObject(playerid, cameraobject[playerid]);
To reset camera movement:
pawn Код:
SetCameraBehindPlayer(playerid);
--
References:
https://sampwiki.blast.hk/wiki/SetCameraBehindPlayer
https://sampwiki.blast.hk/wiki/AttachCameraToObject
https://sampwiki.blast.hk/wiki/ApplyAnimation
https://sampwiki.blast.hk/wiki/ClearAnimations
https://sampwiki.blast.hk/wiki/GetPlayerCameraPos