Freeze player only, not camera -
CalvinC - 10.01.2015
Is there a function to freeze the player, but letting the camera be movable?
It's really annoying having to freeze both, instead of having it selectable.
Otherwise, how could you make it?
Re: Freeze player only, not camera -
CalvinC - 10.01.2015
Bump.
Re: Freeze player only, not camera -
bgedition - 10.01.2015
I think this is impossible.
Only if player is in vehicle with stopping engine
Re: Freeze player only, not camera -
danish007 - 10.01.2015
Quote:
Originally Posted by CalvinC
Bump.
|
Don't Bump..
i can give you suggesstion to make Under OnPlayerUpdate
On Top
pawn Код:
new Freezed[MAX_PLAYERS];
under OnPlayerUpdate
pawn Код:
if(Freezed[playerid] == 1)
{
new Float:Xpos, Float:Ypos, Float:Zpos;
GetPlayerPos(playerid, Xpos, Ypos, Zpos);
SetPlayerPos(playerid, Xpos, Ypos, Zpos);
}
Re: Freeze player only, not camera -
CalvinC - 10.01.2015
That'll just reset his position every 30 or so milliseconds.
It is possible, as there's a function that other servers have created.
Maybe you could set an animation that doesn't allow the player to move or remove the animation by going into vehicles or jumping?
Not sure how to do that if you can.
And also, it is allowed to bump.
Re: Freeze player only, not camera -
CalvinC - 11.01.2015
Bump.
Re: Freeze player only, not camera -
HeLiOn_PrImE - 11.01.2015
It is allowed to bump, but once every 24 hours. Read the rules carefully to avoid getting infraction points.
You can put them in the idle animation. And make sure that animation continues, no matter what buttons they press. I don't see another way.
Re: Freeze player only, not camera -
CalvinC - 11.01.2015
Quote:
Originally Posted by CalvinC
Maybe you could set an animation that doesn't allow the player to move or remove the animation by going into vehicles or jumping?
Not sure how to do that if you can.
|
How can you keep them in an animation nomatter what they press?
And sorry if im bumping a bit before 24 hours, my timezone is way different, so i don't understand the clock on this forum.
Re: Freeze player only, not camera -
Rudy_ - 11.01.2015
Attach an object to a player, There is an invisible object, use that. Attach player camera to the invisible object and toggle player control.
Re: Freeze player only, not camera -
HeLiOn_PrImE - 11.01.2015
or try this:
PHP код:
new bool:playerfreeze=false;
public OnPlayerUpdate(playerid);
{
if (playerfreeze==true)
{ClearAnimations(playerid);}
return 1;
}
PS: It doesn't matter what time is displayed on the forum (you can set it in your account preferences.
Make sure you bump after more than 24 hours.
Re: Freeze player only, not camera -
CalvinC - 12.01.2015
Quote:
Originally Posted by Rudy_
Attach an object to a player, There is an invisible object, use that. Attach player camera to the invisible object and toggle player control.
|
Even though the camera is attached to the object, wont toggleplayercontrol freeze the camera so you can't move it around?
Re: Freeze player only, not camera -
Rudy_ - 12.01.2015
No, the player will be frozen , But the camera attached to be object will be able to move.
Try it, I'm sure it'll work.
Re: Freeze player only, not camera -
CalvinC - 12.01.2015
Do you know an invisible object id?
Re: Freeze player only, not camera -
CalvinC - 13.01.2015
Bump. Does anybody have an invisible object id i could use for this purpose, or another function?
Re: Freeze player only, not camera -
Threshold - 14.01.2015
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