SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/06/2019, 02:04 PM   #1
KayleMC
Little Clucker
 
Join Date: Feb 2017
Posts: 8
Reputation: 0
Default spectate help - small issue

I used the spectating function to remove the spawn button, but the camera wont move to the place I told it to. Help please

Code:
public OnPlayerRequestClass(playerid, classid)
{

    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][1]);
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][2]);
	SetPlayerPos(playerid, 1239.6080, -1233.7601, 60.8744);
	TogglePlayerSpectating(playerid, true);
	InterpolateCameraPos(playerid, 1239.6080, -1233.7601, 60.8744, 1239.6080, -1233.7601, 60.8744, 0, CAMERA_MOVE);
 	InterpolateCameraLookAt(playerid, 1224.6945, -1267.5934, 61.6213, 1224.6945, -1267.5934, 61.6213, 0, CAMERA_MOVE);
	
	return 1;
}
KayleMC is offline   Reply With Quote
Old 26/06/2019, 02:06 PM   #2
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,064
Reputation: 50
Default Re: spectate help - small issue

use SetPlayerCameraPos and SetPlayerCameraLookAt before IterpolateCameraPos and Look (at starting coordinates)
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 26/06/2019, 06:28 PM   #3
KayleMC
Little Clucker
 
Join Date: Feb 2017
Posts: 8
Reputation: 0
Default Re: spectate help - small issue

Quote:
Originally Posted by Mugala View Post
use SetPlayerCameraPos and SetPlayerCameraLookAt before IterpolateCameraPos and Look (at starting coordinates)
Already tried that, it didnt help
KayleMC is offline   Reply With Quote
Old 26/06/2019, 10:07 PM   #4
KayleMC
Little Clucker
 
Join Date: Feb 2017
Posts: 8
Reputation: 0
Default Re: spectate help - small issue

Help
KayleMC is offline   Reply With Quote
Old 26/06/2019, 10:17 PM   #5
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 270
Reputation: 22
Default Re: spectate help - small issue

It does move to where you told it to.
From and to coordinates are the same.
//Edit:
if that is your intention, use SetPlayerCameraPos instead and change execution order so TooglePlayerSpectating is not directly before.
Or try setting time to something greater than 0 and/or change mode to CAMERA_CUT.
Plastikmensch is offline   Reply With Quote
Old 26/06/2019, 10:35 PM   #6
KayleMC
Little Clucker
 
Join Date: Feb 2017
Posts: 8
Reputation: 0
Default Re: spectate help - small issue

Quote:
Originally Posted by Plastikmensch View Post
It does move to where you told it to.
From and to coordinates are the same.
But it doesn't, it gets stuck at a certain bridge for no reason.
KayleMC is offline   Reply With Quote
Old 26/06/2019, 10:38 PM   #7
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 270
Reputation: 22
Default Re: spectate help - small issue

Quote:
Originally Posted by KayleMC View Post
But it doesn't, it gets stuck at a certain bridge for no reason.
Wrong coordinates? Please print the position of the camera after you set the camera to check.
//Edit:
What do you mean by "it gets stuck"?
Plastikmensch is offline   Reply With Quote
Old 26/06/2019, 11:07 PM   #8
BlackBank
Gangsta
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 524
Reputation: 437
Default Re: spectate help - small issue

Code:
forward RequestClassChangeCamera(playerid);
public RequestClassChangeCamera(playerid)
{
    SetPlayerPos(playerid, 1239.6080, -1233.7601, 60.8744);
    InterpolateCameraPos(playerid, 1239.6080, -1233.7601, 60.8744, 1239.6080, -1233.7601, 60.8744, 0, CAMERA_MOVE);
    InterpolateCameraLookAt(playerid, 1224.6945, -1267.5934, 61.6213, 1224.6945, -1267.5934, 61.6213, 0, CAMERA_MOVE);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][1]);
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][2]);
    TogglePlayerSpectating(playerid, true);
    SetTimerEx("RequestClassChangeCamera", 250, false, "d", playerid);
    return 1;
}
What if you do it like this? Since turning a player into spectating mode can take some time and during that time you can't really change the player position and camera. So just wait 250ms or so and then change their positions and camera.
BlackBank is offline   Reply With Quote
Old 27/06/2019, 02:38 AM   #9
KayleMC
Little Clucker
 
Join Date: Feb 2017
Posts: 8
Reputation: 0
Default Re: spectate help - small issue

Quote:
Originally Posted by BlackBank View Post
Code:
forward RequestClassChangeCamera(playerid);
public RequestClassChangeCamera(playerid)
{
    SetPlayerPos(playerid, 1239.6080, -1233.7601, 60.8744);
    InterpolateCameraPos(playerid, 1239.6080, -1233.7601, 60.8744, 1239.6080, -1233.7601, 60.8744, 0, CAMERA_MOVE);
    InterpolateCameraLookAt(playerid, 1224.6945, -1267.5934, 61.6213, 1224.6945, -1267.5934, 61.6213, 0, CAMERA_MOVE);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][1]);
    PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][2]);
    TogglePlayerSpectating(playerid, true);
    SetTimerEx("RequestClassChangeCamera", 250, false, "d", playerid);
    return 1;
}
What if you do it like this? Since turning a player into spectating mode can take some time and during that time you can't really change the player position and camera. So just wait 250ms or so and then change their positions and camera.
I just copied and pasted that, still not working.
KayleMC 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
Small Issue iFiras Scripting Help 8 24/01/2015 06:42 PM
Small Issue [rG]Cold Scripting Help 2 14/10/2012 04:02 PM
[Help]Small Issue ChrisCro Scripting Help 4 26/05/2012 03:31 AM
[help] I HAve An Very Small Issue [not Error] Issue HayZatic Help Archive 1 06/07/2011 04:33 AM
A Small Issue TKZ227 Help Archive 0 24/05/2010 02:43 PM


All times are GMT. The time now is 12:12 PM.


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