SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 29/04/2019, 06:33 PM   #1
aKnoxx
Big Clucker
 
aKnoxx's Avatar
 
Join Date: Dec 2018
Location: United States Discord: ABC#6701
Posts: 76
Reputation: 0
Default Why isn't SetPlayerPos working?

Code:
CMD:spec(playerid, params[])
{
	new targetid;

	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /spec id");
	
	GetPlayerPos(playerid, lastpos[playerid][0], lastpos[playerid][1], lastpos[playerid][2]);
	
	SpecTimer[playerid] = SetTimerEx("ShowPlayerInfo", 1000, 1, "ii", playerid, targetid);
	
	TogglePlayerSpectating(playerid, 1);
	PlayerSpectatePlayer(playerid, targetid);
	
	return 1;
}

CMD:specoff(playerid, params[])
{
	TogglePlayerSpectating(playerid, 0);
	
	SetPlayerPos(playerid, lastpos[playerid][0], lastpos[playerid][1], lastpos[playerid][2]);
	
	new string[128];
	format(string, sizeof(string), "X:%f | Y:%f | Z:%f", lastpos[playerid][0], lastpos[playerid][1], lastpos[playerid][2]);
	SendClientMessage(playerid, -1, string);
	
	KillTimer(SpecTimer[playerid]);
	
	return 1;
}
The SendClientMessage(playerid, -1, string); message is giving me these coords: (WHICH ARE THE CORRECT CORDS)
[14:35:14] X:1515.267333 | Y:-1666.724731 | Z:14.046875

But it's teleporting me to the OnPlayerSpawn position... Not to those X Y Z positions

Note: I tried switching them to Float:lastpos[playerid][0], ect that didn't help.
aKnoxx is offline   Reply With Quote
Old 29/04/2019, 06:41 PM   #2
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 122
Reputation: 6
Default Re: Why isn't SetPlayerPos working?

I'm not sure but I think the TogglePlayerSpectating(players, 0); will call the OnPlayerSpawn callback. Use a timer for the SetPlayerPos.
Koreadars is offline   Reply With Quote
Old 29/04/2019, 06:48 PM   #3
aKnoxx
Big Clucker
 
aKnoxx's Avatar
 
Join Date: Dec 2018
Location: United States Discord: ABC#6701
Posts: 76
Reputation: 0
Default Re: Why isn't SetPlayerPos working?

Tyvm, just removed my OnPlayerSpawn and it worked fine.

Repped ya<3
aKnoxx is offline   Reply With Quote
Old 29/04/2019, 07:09 PM   #4
m4karow
Huge Clucker
 
Join Date: Oct 2015
Posts: 287
Reputation: 37
Default Re: Why isn't SetPlayerPos working?

Quote:
Originally Posted by Koreadars View Post
I'm not sure but I think the TogglePlayerSpectating(players, 0); will call the OnPlayerSpawn callback. Use a timer for the SetPlayerPos.
Why not SetSpawnInfo?
m4karow is offline   Reply With Quote
Old 29/04/2019, 07:28 PM   #5
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 122
Reputation: 6
Default Re: Why isn't SetPlayerPos working?

Quote:
Originally Posted by m4karow View Post
Why not SetSpawnInfo?
(Y) Can be also
Koreadars 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
Need help with GetPlayerPos Kestro Scripting Help 4 14/04/2013 06:50 PM
Hmm Getplayerpos help Jimmeh! Help Archive 3 06/08/2011 06:50 AM
GetPlayerPos PhantomDot1 Help Archive 5 21/05/2011 07:12 PM
Help on GetPlayerPos Criss_Angel Help Archive 19 14/08/2010 01:19 PM
GetPlayerPos Help/Bug Tigerbeast11 Help Archive 3 11/10/2009 01:16 PM


All times are GMT. The time now is 06:53 AM.


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