GetPlayerFacingAngle after SetPlayerFacingAngle -
MP2 - 06.06.2012
GetPlayerFacingAngle returns the OLD angle if used straight after SetPlayerFacingAngle. It doesn't seem to be correct until after the next OnPlayerUpdate call. I have written a fix for this which I will be asking ****** to add to fixes.inc, but of course it's a SA:MP/GTA bug so I'm also reporting it.
It may not be the case every time, I forgot, AFAIK it is.
I used this code to fix it:
http://pastebin.com/L3v6YYyk
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
Basssiiie - 09.06.2012
I remember the same problem occurs with GetPlayerPos after SetPlayerPos, but I can't say that for sure.
Re: GetPlayerFacingAngle after SetPlayerFacingAngle - [MM]IKKE - 09.06.2012
Doesn't this seem quite logical?
OnPlayerUpdate
-> SetPlayerPos: ok, you set a new pos
-> GetPlayerPos: where did you get a new update? You're still using the same information you got, nothing else updated
next OnPlayerUpdate
-> GetPlayerPos: aha, new position information.
I don't know, it seems logical to me...
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
Basssiiie - 09.06.2012
I don't remember how I did it exactly, but is was for a deathmatch map. It was something similar as this:
Код:
new Float: DeathmatchSpawns[][] = {
{100.0, 100.0, 100.0, 100.0},
{more deathmatch spawns}
};
stock SpawnPlayers()
{
for (new p; p != MAX_PLAYERS; p++)
{
new Float: pos[3];
for (new p; p != MAX_PLAYERS; p++)
{
new spawn = random(sizeof(DeathmatchSpawns)), bool: goodspawn;
while (goodspawn == false)
{
new bool: someonenearby, Float: p2Pos[3];
for (new p2; p2 != MAX_PLAYERS; p2++)
{
GetPlayerPos(playerid, p2Pos[0], p2Pos[1], p2Pos[2]);
if (InRangeOf(25.0, DeathmatchSpawns[spawn][0], DeathmatchSpawns[spawn][1], DeathmatchSpawns[spawn][2], p2Pos[0], p2Pos[1], p2Pos[2])
{
someonenearby = true;
}
}
if (someonenearby == false) {goodspawn = true;}
else {spawn = random(sizeof(DeathmatchSpawns));}
}
SetPlayerPos(p, DeathmatchSpawns[s][0], DeathmatchSpawns[s][1], DeathmatchSpawns[s][2]);
SetPlayerFacingAngle(p, DeathmatchSpawns[s][3]);
SetCameraBehindPlayer(p);
}
}
return 1;
}
The goal of the script is to spawn all the players in the deathmatch, without them spawning too close to each other.
Of course, IsPlayerInRangeOfPoint could be used too, but who's says that one gets updated? But still, I'm not sure if this was actually the case. Although, I have changed the original script for this reason, I think. (The script I use nowadays isn't the same as this anymore.)
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
Patrik356b - 09.06.2012
Quote:
Originally Posted by [MM]IKKE
Doesn't this seem quite logical?
OnPlayerUpdate
-> SetPlayerPos: ok, you set a new pos
-> GetPlayerPos: where did you get a new update? You're still using the same information you got, nothing else updated
next OnPlayerUpdate
-> GetPlayerPos: aha, new position information.
I don't know, it seems logical to me...
|
You make a good point but depending on the implementation of functions this would also work within logics:
-> SetPlayerPos: Set new position and store the new position
-> GetPlayerPos: Gets the new position
-> OnPlayerUpdate: Store updated position
Re: GetPlayerFacingAngle after SetPlayerFacingAngle - [MM]IKKE - 09.06.2012
Quote:
Originally Posted by Patrik356b
You make a good point but depending on the implementation of functions this would also work within logics:
-> SetPlayerPos: Set new position and store the new position
-> GetPlayerPos: Gets the new position
-> OnPlayerUpdate: Store updated position
|
Idk if it's true (I'm not a scripter), but
Quote:
Originally Posted by Basssiiie
I remember the same problem occurs with GetPlayerPos after SetPlayerPos, but I can't say that for sure.
|
Same "bug" for that then
OnPlayerUpdate -> Get x1, y1, z1, other stuff, all player info
SetPlayerPos -> sets the position to x2,y2,z2
GetPlayerPos -> still uses the original data: x1,y1,z1
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
leong124 - 09.06.2012
Theoretically the player's facing angle is unchanged at the moment you send the SetPlayerFacingAngle command to do so, until he received it. To ensure that they have already received, the player need to tell the server the facing angle was changed. Thus the data can only be updated in the next player update, so I doubt it is a bug.
Also, I don't understand why you need to use GetPlayerFacingAngle right after using SetPlayerFacingAngle. If you assume GetPlayerFacingAngle returns what you have just set, why don't you just use that angle constant/variable?
For example:
pawn Код:
SetPlayerFacingAngle(playerid,10.0);
facingangle[playerid] = 10.0;//Instead of GetPlayerFacingAngle(facingangle[playerid]);
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
MP2 - 10.06.2012
Because it calls a different function. Even though you CAN do that, it still IS a bug.
I set their angle to 90.
Their angle is set to 90.
I use GetPlayerFacingAngle and it says it's not 90.
That is not correct.
I understand WHY it happens, but it should be fixed. I hope ****** will add this in fixes.inc.
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
cessil - 10.06.2012
You use SetPlayerFacingAngle, it sends a command to the client to change their facing angle it does not definitely set it, just tells the client to please set it.
Re: GetPlayerFacingAngle after SetPlayerFacingAngle -
MP2 - 10.06.2012
There's two ways that GetPlayerFacingAngle could work:
1. It sends a request to the client.
2. It returns the data stored from the last sync (OnPlayerUpdate)
Clearly it's #2 - but it would be better to be #1.