SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 15/05/2018, 05:17 PM   #1
JR_Junior
Huge Clucker
 
Join Date: Nov 2011
Location: Brazil
Posts: 228
Reputation: 54
Default GetActorPos is not working or updating!

Hello.
It seems that you can move actors and their original position does not change or update:



When I try to check for changes in position, nothing happens:
PHP Code:
#define Loop(%0,%1,%2) for(new %0 = %2; %0 < %1; %0++)
new ActorPos[MAX_ACTORS][4];

stock new_CreateActor(skin,Float:x,Float:y,Float:z,Float:a)
{
    new 
aid CreateActor(skin,x,y,z,a);
    
ActorPos[aid][0] = x,ActorPos[aid][1] = y,ActorPos[aid][2] = z,ActorPos[aid][3] = a;
    
SetActorVirtualWorld(aid0);
    
SetActorInvulnerable(aid1);
    return 
aid;
}

stock CheckActorPos()
{
    new 
Float:Pos[3];
    
Loop(i,GetActorPoolSize()+1,0)
    {
        if(
IsValidActor(i))
        {
            if(
GetActorVirtualWorld(i) == 0)
            {
                
GetActorPos(iPos[0], Pos[1], Pos[2]);
                if(
Pos[0] != ActorPos[i][0] || Pos[1] != ActorPos[i][1] || Pos[2] != ActorPos[i][2])
                {
                    
SetActorPos(iActorPos[i][0],ActorPos[i][1],ActorPos[i][2]);
                    
SetActorFacingAngle(iActorPos[i][3]);
                }
            }
        }
    }
    return 
1;

JR_Junior is offline   Reply With Quote
Old 15/05/2018, 10:48 PM   #2
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,412
Reputation: 1240
Default Re: GetActorPos is not working or updating!

You shouldn't use != or == operators with floats use >=, <=, <, > for comparisons. Anyways you are not even clear at all about your problem with no explanation of anything of what you are doing.
Pottus is offline   Reply With Quote
Old 16/05/2018, 04:29 AM   #3
JR_Junior
Huge Clucker
 
Join Date: Nov 2011
Location: Brazil
Posts: 228
Reputation: 54
Default Re: GetActorPos is not working or updating!

Quote:
Originally Posted by Pottus View Post
You shouldn't use != or == operators with floats use >=, <=, <, > for comparisons. Anyways you are not even clear at all about your problem with no explanation of anything of what you are doing.
I'm trying to say that I have a function that checks if the actor is not in the original position it was created (CheckActorPos ()), and if it is not, I try to put it back. According to my images, I move the actors but their current position is not updated, so for the server it is still in the original position.

And regarding comparison of values in float, I also use another function (GetDistanceBetweenPoints) and even so it seems that the position of the actor does not change:
PHP Code:
forward Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2);
stock Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2)
{
    return 
floatadd(floatadd(floatsqroot(floatpower(floatsub(rx1,rx2),2)),floatsqroot(floatpower(floatsub(ry1,ry2),2))),floatsqroot(floatpower(floatsub(rz1,rz2),2)));
}

stock CheckActorPos()
{
    new 
Float:Pos[3];
    
Loop(i,GetActorPoolSize()+1,0)
    {
        if(
IsValidActor(i))
        {
            if(
GetActorVirtualWorld(i) == 0)
            {
                
GetActorPos(iPos[0], Pos[1], Pos[2]);
                new 
Float:dist GetDistanceBetweenPoints(Pos[0], Pos[1], Pos[2],ActorPos[i][0],ActorPos[i][1],ActorPos[i][2]);
                if(
dist 0.0)
                {
                    
SetActorPos(iActorPos[i][0],ActorPos[i][1],ActorPos[i][2]);
                    
SetActorFacingAngle(iActorPos[i][3]);
                }
            }
        }
    }
    return 
1;


Last edited by JR_Junior; 16/05/2018 at 06:34 PM.
JR_Junior is offline   Reply With Quote
Old 16/05/2018, 04:53 PM   #4
Spmn
Gangsta
 
Join Date: Jun 2015
Location: Romania
Posts: 543
Reputation: 131
Default Re: GetActorPos is not working or updating!

The real bug is that actors aren't properly frozen on clients' screens and therefore they can be pushed away from their original position until they are restreamed or SetActorPos is used.
Spmn is offline   Reply With Quote
Old 16/05/2018, 11:04 PM   #5
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,553
Reputation: 457
Default Re: GetActorPos is not working or updating!

The actor positions are synced only from the server to the client. If they are pushed away client-side or fall through the ground or similar it is not synced, therefore the server still holds the original position. This is not a bug as they were never meant to be synced from clients.
NaS is online now   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
Updating 0.3z to 0.3.7 isn't working out! Magnezia Server Support 3 20/12/2015 08:07 PM
Textdraw not working after updating into 0.3.7 r2 ALoX12 Scripting Help 1 22/07/2015 09:32 PM
Gamemode stopped working after updating includes Prostilov Scripting Help 2 24/11/2013 09:25 AM
Small MYSQL updating not working? Nuke547 Scripting Help 7 17/04/2012 09:38 PM


All times are GMT. The time now is 02:46 PM.


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