Coordinates of the sight
#1

Help me please calculate the coordinates of the sight using camerapos + camerafrontvector to get the same data as in GetPlayerLastShotVectors (origin position)
Reply
#2

Tried to, already close, but would still not accurately

PHP код:
    new
        
Float:fPXFloat:fPYFloat:fPZ,
        
Float:fVXFloat:fVYFloat:fVZ,
        
Float:object_z,Float:zzz;
    const
        
Float:disttt 2.75;
    
GetPlayerCameraPos(playeridfPXfPYfPZ);
    
GetPlayerCameraFrontVector(playeridfVXfVYfVZ);
    
GetPlayerFacingAngle(playerid,zzz);
    
object_z fPZ floatmul(fVZdisttt);
    
CreateObject(2707fPX+disttt*-floatsin(zzz,degrees), fPY+disttt*floatcos(zzz,degrees), object_z+0.140.0000000,0.0000000,0.0000000100); // my origin
    
CreateObject(2707unoccupiedData[PR_origin][0],unoccupiedData[PR_origin][1],unoccupiedData[PR_origin][2], 0.0000000,0.0000000,0.0000000100); // origin 
Reply
#3

Almost ready, there is little left, please help
Watch the video, you will understand

https://www.youtube.com/watch?v=DWdZYdq-E0A

PHP код:
    new
        
Float:fPXFloat:fPYFloat:fPZ,
        
Float:fVXFloat:fVYFloat:fVZ,
        
Float:object_xFloat:object_yFloat:object_z
        Float
:zzz;
    const 
Float:fScale 2.75// 2.76;
    
GetPlayerCameraPos(playeridfPXfPYfPZ);
    
GetPlayerCameraFrontVector(playeridfVXfVYfVZ);
    
GetPlayerFacingAngle(playerid,zzz);
    
fVX += floatsin(-zzz+1.5degrees);
    
fVY += floatcos(-zzz+1.5degrees);
    
object_x unoccupiedData[PR_origin][0] + (fVX fScale);
    
object_y unoccupiedData[PR_origin][1] + (fVY fScale);
    
object_z unoccupiedData[PR_origin][2] + (fVZ fScale);
    
CreateObject(2707object_xobject_yobject_z0.0000000,0.0000000,0.0000000100); 
Reply
#4

Shots do not come from the center of the screen they are offset. So how do you expect this work? I am sure there is a way to do it but not the way you are trying.
Reply
#5

Then how ?
Reply
#6

Help please
Reply
#7

Why do you even need this ?
Reply
#8

Anti-cheat on all types of "Aim"
Reply
#9

I ready even to pay
Reply
#10

will help who?
Reply
#11

Try this.
Fire A weapon
Get the origin / hitpoint of the shot
Use https://sampwiki.blast.hk/wiki/VectorSize
Subtract the result this from camera front vector GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ)

That should give you a constant vector you can add to GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ); to figure out where the shot came from. Once you have your constant then test it you might have to compensate for facing angle? Not sure test it out.
Reply
#12

Quote:
Originally Posted by Pottus
View Post
Try this.
Fire A weapon
Get the origin / hitpoint of the shot
Use https://sampwiki.blast.hk/wiki/VectorSize
Subtract the result this from camera front vector GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ)

That should give you a constant vector you can add to GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ); to figure out where the shot came from. Once you have your constant then test it you might have to compensate for facing angle? Not sure test it out.
Thats basically what I did for GetPlayerCameraWeaponVector but it was inacurrate because I only tested it for targets infront / same height of the player
After the GetPlayerLastShotVectors update it was clear that the offset differ if you aim up or down, so I adjusted it but that version isn't available anymore because I deleted it from github without reuploading it because I thought this wasn't needed anymore

Anyways you need to get multiple offsets for different z position and approximate or interpolate it
Here the graphic from my thread for three different weapon types with bad / manual approximation


That version should be on one of my old drives but a reapproximation wouldn't hurt

The older versions can be found in some old scripts but these are inaccurate because they are based on same height targets, so they should be accurate from around -0.4 to 0.4 z front vector
First version with static offsets can be found here, second version with circular offset can be found here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)