SA-MP Forums Archive
funtion question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: funtion question (/showthread.php?tid=586216)



funtion question - zeth98 - 20.08.2015

Hello, how can I made a function to know X and Y coordonate around object pos with diameter off 5 units.
I know my pos I know object pos but how can I SetPlayerPos(Getplayerpos (x,y+1,z)
And the new player pos be an long circle?

P.S if I made that pos for many times the player need to rotate in round of object position (around of circle) with diameter 5 units


Re: funtion question - Mariciuc223 - 20.08.2015

i think that it's what you need:

Quote:

new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(playerid, Pos[0], Pos[1]+1, Pos[2]);




Re: funtion question - zeth98 - 20.08.2015

Yes but this Position SetPlayerPos(playerid, Pos[0], Pos[1]+1, Pos[2]); need to be on the circle with diameter off 5 unit


AW: funtion question - Nero_3D - 20.08.2015

An example not sure what you exactly wanted
PHP код:
TeleportPlayerAroundObject(objectidFloatradius) {
    new
        
FloatX,
        
FloatY,
        
FloatZ
    
;
    if(
GetObjectPos(objectidXYZ)) {
        new
            
i,
            
count,
            
players[MAX_PLAYERS]
        ;
        for(
GetPlayerPoolSize(); >= 0; --i) {
            if(
IsPlayerConnected(i)) {
                
players[count++] = i;
            }
        }
        new
            
Floatstep 360.0 count
        
;
        for(
0count; (Floati) += step) {
            
SetPlayerPos(players[--count],
                
floatcos(Floatidegrees) * radius,
                
floatsin(Floatidegrees) * radius,
                
Z
            
);
        }
    }




Re: funtion question - zeth98 - 20.08.2015

Yout function teleport me if I am in coord C teleport in D, if I am in A teleport me in D
I want if I am in A Teleport me in B
I want to teleport me to closet coord of circle




AW: funtion question - Nero_3D - 20.08.2015

Ah okay here you go
pawn Код:
TeleportPlayerToObject(playerid, objectid, Float: distance) {
    new
        Float: pX,
        Float: pY,
        Float: pZ
    ;
    if(GetPlayerPos(playerid, pX, pY, pZ)) {
        new
            Float: oX,
            Float: oY,
            Float: oZ
        ;
        if(GetObjectPos(objectid, oX, oY, oZ)) {
            pX -= oX;
            pY -= oY;
            pZ -= oZ;

            distance /= VectorSize(pX, pY, pZ);

            return SetPlayerPos(playerid,
                oX + pX * distance,
                oY + pY * distance,
                oZ
            );
        }
    }
    return false;
}



Re: funtion question - zeth98 - 20.08.2015

THANK YOU VERY MUCH, IT WORKS


Re: funtion question - zeth98 - 20.08.2015

I modiffied at the return SetPlyaerPos( "that operation " +1
But don't work. How can I make to TeleportPlayerToObject and auto rotating in round of object.
I want the player to rotate in round of object with this position and i put the value move.


AW: Re: funtion question - Nero_3D - 21.08.2015

Quote:
Originally Posted by zeth98
Посмотреть сообщение
I modiffied at the return SetPlyaerPos( "that operation " +1
But don't work. How can I make to TeleportPlayerToObject and auto rotating in round of object.
I want the player to rotate in round of object with this position and i put the value move.
Could you rephrase that

1. Player gets teleported to the new position
2. Now he should rotate around the object ?

Than you need to use an timer which will rotate him by the given speed? Is this some kind of merry-go-round / carousel


Re: funtion question - zeth98 - 21.08.2015

The function work god, and I put SetPlayerCameraPosLookAt "objectCoord" at a timer 20 miliseconds. And now I want to teleport me around object with 2meters