Fly function works only for ID 0, weird ...
#1

Hey guys, my Admin fly function works only for ID 0, that's very weird and honestly I have no clue why
PHP код:
CMD:fly(playerid)
{
    if(!
IsAllowed(playerid2)) return NoAuth(playerid);
    new 
Float:xFloat:yFloat:z;
    if(
Fly[playerid] == false)
    {
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+5);
           
SetPlayerArmour(playerid1000000000.0);
        
SetPlayerHealth(playerid1000000000.0);
        
SetTimerEx("AdminFly"1000"d"playerid);
        
Fly[playerid] = true;
        return 
1;
    }
    else
    {
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+0.5);
        
ClearAnimations(playerid);
        
SetPlayerArmour(playerid100.0);
        
SetPlayerHealth(playerid100.0);
        
Fly[playerid] = false;
        return 
1;
    }

PHP код:
// Admin Fly
forward AdminFly(playerid);
public 
AdminFly(playerid)
{
    if(!
IsPlayerConnected(playerid))
        return 
Fly[playerid] = false;
    if(
Fly[playerid])
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid,"SWIM","SWIM_crawl",6.1,1,1,1,1,0,1);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            
SetPlayerVelocity(playerid0.00.00.01);
        }
        
SetTimerEx("AdminFly"1000"d"playerid);
    }
    return 
0;

Anyone a clue ?
Reply
#2

Try setting Fly[playerid] = true;

before setting timer, in cmd:fly.
Reply
#3

Still doesn't work
Reply
#4

IsAllowed(playerid, 2) <--- give me definition fo this function
Reply
#5

Quote:
Originally Posted by Yaa
Посмотреть сообщение
IsAllowed(playerid, 2) <--- give me definition fo this function
If admin level above/equals to 2 ...

PHP код:
#define IsAllowed(%1,%2) (PlayerInfo[%1][pAdmin] >= %2) 
Reply
#6

Try this;

PHP код:
CMD:fly(playerid)
{
    if(!
IsAllowed(playerid2)) return NoAuth(playerid);
    new 
Float:xFloat:yFloat:z;
    if(
Fly[playerid] == false)
    {
        
Fly[playerid] = true;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+5);
        
SetPlayerArmour(playerid1000000000.0);
        
SetPlayerHealth(playerid1000000000.0);
        
AdminFly(playerid);
    }
    else
    {
        
Fly[playerid] = false;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+0.5);
        
ClearAnimations(playerid);
        
SetPlayerArmour(playerid100.0);
        
SetPlayerHealth(playerid100.0);
    }
    return 
1;
}  
forward AdminFly(playerid);
public 
AdminFly(playerid)
{
    if(
Fly[playerid] == true)
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid,"SWIM","SWIM_crawl",6.1,1,1,1,1,0,1);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            
SetPlayerVelocity(playerid0.00.00.01);
        }
        
AdminFly(playerid);
    }
    return 
0;

Reply
#7

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Try this;

PHP код:
CMD:fly(playerid)
{
    if(!
IsAllowed(playerid2)) return NoAuth(playerid);
    new 
Float:xFloat:yFloat:z;
    if(
Fly[playerid] == false)
    {
        
Fly[playerid] = true;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+5);
        
SetPlayerArmour(playerid1000000000.0);
        
SetPlayerHealth(playerid1000000000.0);
        
AdminFly(playerid);
    }
    else
    {
        
Fly[playerid] = false;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+0.5);
        
ClearAnimations(playerid);
        
SetPlayerArmour(playerid100.0);
        
SetPlayerHealth(playerid100.0);
    }
    return 
1;
}  
forward AdminFly(playerid);
public 
AdminFly(playerid)
{
    if(
Fly[playerid] == true)
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid,"SWIM","SWIM_crawl",6.1,1,1,1,1,0,1);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            
SetPlayerVelocity(playerid0.00.00.01);
        }
        
AdminFly(playerid);
    }
    return 
0;

Not gonna work, you cant move without the timers ..
Reply
#8

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Try this;

PHP код:
CMD:fly(playerid)
{
    if(!
IsAllowed(playerid2)) return NoAuth(playerid);
    new 
Float:xFloat:yFloat:z;
    if(
Fly[playerid] == false)
    {
        
Fly[playerid] = true;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+5);
        
SetPlayerArmour(playerid1000000000.0);
        
SetPlayerHealth(playerid1000000000.0);
        
AdminFly(playerid);
    }
    else
    {
        
Fly[playerid] = false;
        
GetPlayerPos(playeridxyz);
        
SetPlayerPos(playeridxyz+0.5);
        
ClearAnimations(playerid);
        
SetPlayerArmour(playerid100.0);
        
SetPlayerHealth(playerid100.0);
    }
    return 
1;
}  
forward AdminFly(playerid);
public 
AdminFly(playerid)
{
    if(
Fly[playerid] == true)
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid,"SWIM","SWIM_crawl",6.1,1,1,1,1,0,1);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            
SetPlayerVelocity(playerid0.00.00.01);
        }
        
AdminFly(playerid);
    }
    return 
0;

Yo nigga, calling a function as much as possible every milli-second causes in crash xp.

@NeXoR your code has nothing wrong, I have used this system before it was working perfect however I've optimized its codes so try the new system:

PHP код:
#include a_samp
#include zcmd
/*******************************Superman System********************************/
#define DontUSEOnPlayerUpdate       false
new bool:flying[MAX_PLAYERS char];
#if DontUSEOnPlayerUpdate
new SuperManTimerID[MAX_PLAYERS];
forward public AdminFly(playerid);
#endif
/******************************************************************************/
Float:SetPlayerToFacePos(playeridFloat:XFloat:Y)
{
    new
        
Float:pX1,
        
Float:pY1,
        
Float:pZ1,
        
Float:ang;
    if(!
IsPlayerConnected(playerid)) return 0.0;
    
GetPlayerPos(playeridpX1pY1pZ1);
    if( 
pY1 ang = (-acos((pX1) / floatsqroot((pX1)*(pX1) + (pY1)*(pY1))) - 90.0);
    else if( 
pY1 && pX1 ang = (acos((pX1) / floatsqroot((pX1)*(pX1) + (pY1)*(pY1))) - 450.0);
    else if( 
pY1 ang = (acos((pX1) / floatsqroot((pX1)*(pX1) + (pY1)*(pY1))) - 90.0);
    if(
pX1ang = (floatabs(floatabs(ang) + 180.0));
    else 
ang = (floatabs(ang) - 180.0);
    
ang += 180.0;
    
SetPlayerFacingAngle(playeridang);
     return 
ang;
}
public 
OnPlayerUpdate(playerid)
{
    
#if !DontUSEOnPlayerUpdate
    
if(flying{playerid})
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid"SWIM""SWIM_crawl"4.101100);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            {
                
SetPlayerVelocity(playerid0.00.00.01);
            }
        }
    }
    
#endif
    
return 1;
}
public 
OnPlayerConnect(playerid)
{
    
flying{playerid} = false;
    
#if DontUSEOnPlayerUpdate
    
SuperManTimerID[playerid] = 0;
    
#endif
}
public 
OnPlayerDisconnect(playerid,reason)
{
    
#if DontUSEOnPlayerUpdate
    
if(SuperManTimerID[playerid])
    {
        
KillTimer(SuperManTimerID[playerid]);
        
SuperManTimerID[playerid] = 0;
    }
    
#endif
}
#if DontUSEOnPlayerUpdate
public AdminFly(playerid)
{
    if(!
IsPlayerConnected(playerid))
        return 
KillTimer(SuperManTimerID[playerid]);
    if(
flying{playerid})
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid"SWIM""SWIM_crawl"4.101100);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            
SetPlayerVelocity(playerid0.00.00.01);
        }
    }
    return 
1;
}
#endif
CMD:superman(playeridparams[])
{
    if(!
IsAllowed(playerid2))
    {
        new 
Float:xFloat:yFloat:z;
        if(!
flying{playerid})
        {
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+5);
            
SetPlayerArmour(playerid1000000000.0);
            
SetPlayerHealth(playerid1000000000.0);
            
#if DontUSEOnPlayerUpdate
            
SuperManTimerID[playerid] = SetTimerEx("AdminFly"100true"d"playerid);
            
#endif
            
flying{playerid} = true;
        }
        else
        {
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+0.5);
            
ClearAnimations(playerid);
            
SetPlayerArmour(playerid100.0);
            
SetPlayerHealth(playerid100.0);
            
flying{playerid} = false;
            
#if DontUSEOnPlayerUpdate
            
KillTimer(SuperManTimerID[playerid]);
            
SuperManTimerID[playerid] = 0;
            
#endif
            
return 1;
        }
    }
    else
    {
        
NoAuth(playerid);
    }
    return 
1;

Reply
#9

Quote:
Originally Posted by jlalt
Посмотреть сообщение
Yo nigga, calling a function as much as possible every milli-second causes in crash xp.

@NeXoR your code has nothing wrong, I have used this system before it was working perfect however I've optimized its codes so try the new system:

PHP код:
#include a_samp
#include zcmd
/*******************************Superman System********************************/
#define DontUSEOnPlayerUpdate       false
new bool:flying[MAX_PLAYERS char];
#if DontUSEOnPlayerUpdate
new SuperManTimerID[MAX_PLAYERS];
forward public AdminFly(playerid);
#endif
/******************************************************************************/
Float:SetPlayerToFacePos(playeridFloat:XFloat:Y)
{
    new
        
Float:pX1,
        
Float:pY1,
        
Float:pZ1,
        
Float:ang;
    if(!
IsPlayerConnected(playerid)) return 0.0;
    
GetPlayerPos(playeridpX1pY1pZ1);
    if( 
pY1 ang = (-acos((pX1) / floatsqroot((pX1)*(pX1) + (pY1)*(pY1))) - 90.0);
    else if( 
pY1 && pX1 ang = (acos((pX1) / floatsqroot((pX1)*(pX1) + (pY1)*(pY1))) - 450.0);
    else if( 
pY1 ang = (acos((pX1) / floatsqroot((pX1)*(pX1) + (pY1)*(pY1))) - 90.0);
    if(
pX1ang = (floatabs(floatabs(ang) + 180.0));
    else 
ang = (floatabs(ang) - 180.0);
    
ang += 180.0;
    
SetPlayerFacingAngle(playeridang);
     return 
ang;
}
public 
OnPlayerUpdate(playerid)
{
    
#if !DontUSEOnPlayerUpdate
    
if(flying{playerid})
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid"SWIM""SWIM_crawl"4.101100);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            {
                
SetPlayerVelocity(playerid0.00.00.01);
            }
        }
    }
    
#endif
    
return 1;
}
public 
OnPlayerConnect(playerid)
{
    
flying{playerid} = false;
    
#if DontUSEOnPlayerUpdate
    
SuperManTimerID[playerid] = 0;
    
#endif
}
public 
OnPlayerDisconnect(playerid,reason)
{
    
#if DontUSEOnPlayerUpdate
    
if(SuperManTimerID[playerid])
    {
        
KillTimer(SuperManTimerID[playerid]);
        
SuperManTimerID[playerid] = 0;
    }
    
#endif
}
#if DontUSEOnPlayerUpdate
public AdminFly(playerid)
{
    if(!
IsPlayerConnected(playerid))
        return 
KillTimer(SuperManTimerID[playerid]);
    if(
flying{playerid})
    {
        if(!
IsPlayerInAnyVehicle(playerid))
        {
            new
                
keys,
                
ud,
                
lr,
                
Float:x[2],
                
Float:y[2],
                
Float:z;
            
GetPlayerKeys(playeridkeysudlr);
            
GetPlayerVelocity(playeridx[0], y[0], z);
            if(
ud == KEY_UP)
            {
                
GetPlayerCameraPos(playeridx[0], y[0], z);
                
GetPlayerCameraFrontVector(playeridx[1], y[1], z);
                
ApplyAnimation(playerid"SWIM""SWIM_crawl"4.101100);
                
SetPlayerToFacePos(playeridx[0] + x[1], y[0] + y[1]);
                
SetPlayerVelocity(playeridx[1], y[1], z);
            }
            else
            
SetPlayerVelocity(playerid0.00.00.01);
        }
    }
    return 
1;
}
#endif
CMD:superman(playeridparams[])
{
    if(!
IsAllowed(playerid2))
    {
        new 
Float:xFloat:yFloat:z;
        if(!
flying{playerid})
        {
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+5);
            
SetPlayerArmour(playerid1000000000.0);
            
SetPlayerHealth(playerid1000000000.0);
            
#if DontUSEOnPlayerUpdate
            
SuperManTimerID[playerid] = SetTimerEx("AdminFly"100true"d"playerid);
            
#endif
            
flying{playerid} = true;
        }
        else
        {
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+0.5);
            
ClearAnimations(playerid);
            
SetPlayerArmour(playerid100.0);
            
SetPlayerHealth(playerid100.0);
            
flying{playerid} = false;
            
#if DontUSEOnPlayerUpdate
            
KillTimer(SuperManTimerID[playerid]);
            
SuperManTimerID[playerid] = 0;
            
#endif
            
return 1;
        }
    }
    else
    {
        
NoAuth(playerid);
    }
    return 
1;

Still not working for ID 1
Reply
#10

Anyone ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)