Freeze player only, not camera
#1

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?
Reply
#2

Bump.
Reply
#3

I think this is impossible.
Only if player is in vehicle with stopping engine
Reply
#4

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);
}
Reply
#5

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.
Reply
#6

Bump.
Reply
#7

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.
Reply
#8

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.
Reply
#9

Attach an object to a player, There is an invisible object, use that. Attach player camera to the invisible object and toggle player control.
Reply
#10

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.
Reply
#11

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?
Reply
#12

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.
Reply
#13

Do you know an invisible object id?
Reply
#14

Bump. Does anybody have an invisible object id i could use for this purpose, or another function?
Reply
#15

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)