SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/01/2015, 05:39 PM   #11
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,831
Reputation: 114
Default Re: Freeze player only, not camera

Quote:
Originally Posted by Rudy_ View Post
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?
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 12/01/2015, 05:41 PM   #12
Rudy_
High-roller
 
Rudy_'s Avatar
 
Join Date: Nov 2011
Location: Pakistan
Posts: 1,355
Reputation: 230
Default Re: Freeze player only, not camera

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.
__________________
And now my Watch has Ended.


[Tutorial]
[TuT]How to create a car shooting Neon

[Filterscript]
Neon Vehicle Laser


__________________________________________________
Rudy_ is offline   Reply With Quote
Old 12/01/2015, 06:13 PM   #13
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,831
Reputation: 114
Default Re: Freeze player only, not camera

Do you know an invisible object id?
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 13/01/2015, 06:43 PM   #14
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,831
Reputation: 114
Default Re: Freeze player only, not camera

Bump. Does anybody have an invisible object id i could use for this purpose, or another function?
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 14/01/2015, 01:13 AM   #15
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,126
Reputation: 527
Default Re: Freeze player only, not camera

pawn Code:
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 Code:
ApplyAnimation(playerid, "ped", "IDLE_stance", 4.1, 1, 0, 0, 0, 0, 1);

To unfreeze the player:
pawn Code:
ClearAnimations(playerid);

To enable camera movement: (This is really only if you want the camera to not be focused on the player)
pawn Code:
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 Code:
SetCameraBehindPlayer(playerid);

--

References:
http://wiki.sa-mp.com/wiki/SetCameraBehindPlayer
http://wiki.sa-mp.com/wiki/AttachCameraToObject
http://wiki.sa-mp.com/wiki/ApplyAnimation
http://wiki.sa-mp.com/wiki/ClearAnimations
http://wiki.sa-mp.com/wiki/GetPlayerCameraPos
__________________

Kar's Cops and Robbers 2019
Threshold is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Freeze a player Compton Help Archive 2 16/08/2011 02:39 PM
Moving Camera On Login The Camera On Player Spawn Does Not Go Back. Robert_Crawford Help Archive 5 20/06/2011 12:56 AM
Freeze player but let him move camera. xXDaniiXx Help Archive 0 01/06/2011 03:12 PM
freeze player shoru93 Help Archive 2 15/05/2010 10:48 AM
Camera freeze after alt tabbing TedTheNugent Client Support 2 27/04/2010 06:32 PM


All times are GMT. The time now is 10:29 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.