14.01.2015, 01:13
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;
}
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);
pawn Код:
ClearAnimations(playerid);
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]);
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