SA-MP Forums Archive
Admin-fly error. - 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: Admin-fly error. (/showthread.php?tid=407410)



Admin-fly error. - Kaaajmak - 13.01.2013

On /adminfly it enables the admin to fly around without using ****** etc.
So, what the problem is, that only the space and crouch work, none other. What is causing this and how to fix it?

PHP код:
    if(Flying[playerid] == 1)
    {
        if(
HOLDING(KEY_LOOK_LEFT))
        {
            new 
Float:oldpos[3];
            
GetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]);
            
SetPlayerPos(playeridoldpos[0]+2oldpos[1], oldpos[2]);
        }
        else if(
HOLDING(KEY_LOOK_RIGHT))
        {
            new 
Float:oldpos[3];
            
GetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]);
            
SetPlayerPos(playeridoldpos[0]-2oldpos[1], oldpos[2]);
        }
        else if(
HOLDING(KEY_LEFT))
        {
            new 
Float:oldpos[3];
            
GetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]);
            
SetPlayerPos(playeridoldpos[0], oldpos[1]+2oldpos[2]);
        }
        else if(
HOLDING(KEY_RIGHT))
        {
            new 
Float:oldpos[3];
            
GetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]);
            
SetPlayerPos(playeridoldpos[0], oldpos[1]-2oldpos[2]);
        }
        else if(
HOLDING(KEY_SPRINT))
        {
            new 
Float:oldpos[3];
            
GetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]);
            
SetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]+2);
        }
        else if(
HOLDING(KEY_CROUCH))
        {
            new 
Float:oldpos[3];
            
GetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]);
            
SetPlayerPos(playeridoldpos[0], oldpos[1], oldpos[2]-2);
        } 
(Yes, i know I could've put the oldpos definition on top)


Re: Admin-fly error. - PRoleplay - 13.01.2013

im not a pro scripter but if you want a fly command for admins try this
https://sampforum.blast.hk/showthread.php?tid=309467
Credits to the Scripter hope it helps


Re: Admin-fly error. - Kaaajmak - 13.01.2013

Thanks, but I would still like to know why this won't work.


Re: Admin-fly error. - mineralo - 13.01.2013

its won't work because its depents of angle of player, to solve it you should use sin and cos of angle


Re: Admin-fly error. - Kaaajmak - 13.01.2013

The angle? There are no angles here, only positions...
Could you explain/give an example?

Note: On /adminfly I do:
Quote:

SetPlayerFacingAngle(playerid, 0);




Re: Admin-fly error. - mineralo - 13.01.2013

there are x,y and z coordonates, its depents how are your angle, in pic
http://i48.tinypic.com/1hbeaf.png
you should use sin and cos of angle if you want to do that


Re: Admin-fly error. - mineralo - 13.01.2013

pawn Код:
SetPlayerPos(playerid, (oldpos[0]+floatcos(Angle-94,degrees))+4.0, (oldpos[1]+floatsin(Angle-94,degrees))+4.0, oldpos[2]);// if press right
 SetPlayerPos(playerid, (oldpos[0]+floatcos(Angle-94,degrees))-4.0, (oldpos[1]+floatsin(Angle-94,degrees))-4.0, oldpos[2]);// if press left
this code its from my gm, I'd this problem when I was making one system, and I solve it, rest I think you'll get


Re: Admin-fly error. - Kaaajmak - 13.01.2013

Ah, I wasn't aware that the Co-ordinate system here is relative to the players angle.
Many thanks, I will attempt to adapt it to my code.