Class help
#1

PHP код:
        SetPlayerTeamFromClass(playerid,classid);
        
SetPlayerPos(playerid,1558.1510,-1370.1229,330.0528);
        new 
Float:X,Float:Y,Float:Z,Float:A,Float:R=4;
        
GetPlayerPos(playerid,X,Y,Z);
        
GetPlayerFacingAngle(playerid,A);
        new 
Float:CX,Float:CY,Float:CZ;
        
CX=X+(R*floatsin(-A,degrees));
        
CY=Y+(R*floatcos(-A,degrees));
        
CZ=Z+1;
        
SetPlayerCameraPos(playerid,CX,CY,CZ);
        
SetPlayerCameraLookAt(playerid,1558.1510,-1370.1229,330.0528); 
These are the onplayerrequestclass code. Well the problem is that the camerpos coords are wrong. But if i execute the onplayerrequestclass again then the coords are right. Basically this function get's late to be executed. Any thing wrong?
Reply
#2

Change this,
PHP код:
CX=X+(R*floatsin(-A,degrees));
CY=Y+(R*floatcos(-A,degrees)); 
To this,
PHP код:
+= (Rfloatsin(-Adegrees));
+= (floatcos(-Adegrees));
SetPlayerCameraPos(playeridXYZ+1.0); 
An remove those few unnecessary float values eg: CX, CY, CZ
Reply
#3

Same problem. Occurs on login too
Reply
#4

Thats very strange isn't it,

Try fixing the float R value up which is currently set to an integer value '4', but it should be a float value '4.0'.

Maybe try using SetPlayerFacingAngle before GetPlayerFacingAngle?
Reply
#5

The problem is that. The position at which the camera is or the player is it sets the coords at the same place instead of to positions i want
Reply
#6

Here man, I made this just for you!

PHP код:
}
stock SetPlayerToLookAtSelf(playeridFloat:range)
{
    new 
Float:XFloat:YFloat:ZFloat:A;
    
GetPlayerPos(playeridXYZ);
    
GetPlayerFacingAngle(playeridA);
    
SetPlayerCameraLookAt(playeridXYZ);
    
+= (range floatsin(-Adegrees));
    
+= (range floatcos(-Adegrees));
    
SetPlayerCameraPos(playeridXYZ);
    return 
1;

Simply set your position wherever you like and use it

Example,
PHP код:
SetPlayerTeamFromClass(playerid,classid);
SetPlayerPos(playerid,1558.1510,-1370.1229,330.0528);
SetPlayerToLookAtSelf(playerid4.0); 
Reply
#7

Why are you using GetPlayerPos when you already have the coordinates that the player is going to be put on? SetPlayerPos probably hasn't been fully executed by the time you use GetPlayerPos, so the coordinates are a somewhat delayed version.

PHP код:
        SetPlayerTeamFromClass(playerid,classid); 
        
SetPlayerPos(playerid1558.1510, -1370.1229330.0528);
        
// SetPlayerFacingAngle(playerid, ...); ?
        
new Float:A// Remove if using SetPlayerFacingAngle
        
GetPlayerFacingAngle(playeridA); // If you're going to use SetPlayerFacingAngle, use the angle from that instead.
        
SetPlayerCameraPos(playerid1558.1510 + (floatsin(-A,degrees)), -1370.1229 + (floatcos(-A,degrees), 330.0528 1.0); 
        
SetPlayerCameraLookAt(playerid1558.1510, -1370.1229330.0528); 
Though there is a lazy but clean way of doing this, which could be helpful if you decide that you want to change these coordinates in the future.

PHP код:
    new 
        
Float:pX 1558.1510,
        
Float:pY = -1370.1229,
        
Float:pZ 330.0528,
        
Float:pA 0.0
    
;
    
SetPlayerTeamFromClass(playerid,classid); 
    
SetPlayerPos(playeridpXpYpZ);
    
SetPlayerFacingAngle(playeridpA);
    
SetPlayerCameraPos(playeridpX + (4.0 floatsin(-pAdegrees)), pY + (4.0 floatcos(-pAdegrees)), pZ 1.0); 
    
SetPlayerCameraLookAt(playeridpXpYpZ); 
Reply
#8

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Why are you using GetPlayerPos when you already have the coordinates that the player is going to be put on? SetPlayerPos probably hasn't been fully executed by the time you use GetPlayerPos, so the coordinates are a somewhat delayed version.

PHP код:
        SetPlayerTeamFromClass(playerid,classid); 
        
SetPlayerPos(playerid1558.1510, -1370.1229330.0528);
        
// SetPlayerFacingAngle(playerid, ...); ?
        
new Float:A// Remove if using SetPlayerFacingAngle
        
GetPlayerFacingAngle(playeridA); // If you're going to use SetPlayerFacingAngle, use the angle from that instead.
        
SetPlayerCameraPos(playerid1558.1510 + (floatsin(-A,degrees)), -1370.1229 + (floatcos(-A,degrees), 330.0528 1.0); 
        
SetPlayerCameraLookAt(playerid1558.1510, -1370.1229330.0528); 
Though there is a lazy but clean way of doing this, which could be helpful if you decide that you want to change these coordinates in the future.

PHP код:
    new 
        
Float:pX 1558.1510,
        
Float:pY = -1370.1229,
        
Float:pZ 330.0528,
        
Float:pA 0.0
    
;
    
SetPlayerTeamFromClass(playerid,classid); 
    
SetPlayerPos(playeridpXpYpZ);
    
SetPlayerFacingAngle(playeridpA);
    
SetPlayerCameraPos(playeridpX + (4.0 floatsin(-pAdegrees)), pY + (4.0 floatcos(-pAdegrees)), pZ 1.0); 
    
SetPlayerCameraLookAt(playeridpXpYpZ); 
What is R in here?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)