Admin-fly error.
#1

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)
Reply
#2

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
Reply
#3

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

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

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

Note: On /adminfly I do:
Quote:

SetPlayerFacingAngle(playerid, 0);

Reply
#6

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
Reply
#7

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
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)