#1

Something is wrong in this function, because when I start my server I get message "file or function not found", but when I change GetVehicleDistanceToPoint to some random number, it works.

pawn Код:
static stock GetClosestVehicle( playerid, Float: radius )
{
    static
        Float: X,
        Float: Y,
        Float: Z;
    GetPlayerPos( playerid, X, Y, Z );
    for ( new vehicleid; vehicleid != MAX_VEHICLES; ++ vehicleid )
    {
        if ( GetVehicleDistanceFromPoint( vehicleid, X, Y, Z ) < radius ) return vehicleid;
    }
    return INVALID_VEHICLE_ID;
}

and for example, if I change line

if ( GetVehicleDistanceFromPoint( vehicleid, X, Y, Z ) < radius )

to

if ( 20 < radius ) (its just example)

I dont get error.
Reply
#2

Use this code:

pawn Код:
GetNearestcar(playerid, Float:radius)
{
    new
        Float:pX,
        Float:pY,
        Float:pZ,
        Float:CarX,
        Float:CarZ,
        Float:CarY;
       
    GetPlayerPos(playerid, pX, pY, pZ);
    for(new i = 1; i < MAX_VEHICLES; i++)
    {
        GetVehiclePos(i, CarX, CarY, CarZ);
        if((floatabs(pX-CarX)<radius)&&(floatabs(pY-CarY)<radius)&&(floatabs(pZ-CarZ)<radius))
        {
            return i;
        }
    }
    return false;
}
Credits goes to some German dude...
Reply
#3

Thx, works, now:

maybe someone knows not so hard way to do anti bunnyhop?
Reply
#4

OnPlayerKeyStateChange
pawn Код:
SetTimerEx("ResetBunny");
Variable += 1;
if(Variable >= 3)
{
ApplyAnim, kick, ban what ever.
ResetBunny.
}

ResetBunny
{
Variable = 0;
return true;
}
Reply
#5

GetClosestVehicle is faster using "GetVehicleDistanceFromPoint" then calculating the distance in PAWN:
pawn Код:
stock GetClosestVehicle(playerid, Float: fRadius)
{
    new
        Float: fX,
        Float: fY,
        Float: fZ,
        Float: fDist[2],
        iClosestID = INVALID_VEHICLE_ID
    ;
    fDist[1] = fRadius;
    GetPlayerPos(playerid, fX, fY, fZ);
   
    for(new i; i < MAX_VEHICLES; ++i)
    {
        if((fDist[0] = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fDist[1])
        {
            iClosestID = i;
            fDist[1] = fDist[0];
        }
    }
    return iClosestID;
}
Reply
#6

Ok, thanks RyDeR`.

For bunnyhop: I know, I just want to know which way is best to detect it, not to what and how to do something for player when player bunny hops.

And one more question: How can I convert color code (for example 0xFF0000AA) to HEX code (0xFF0000AA should be {FF0000})
Reply
#7

^^^^
Reply
#8

This is a quick example of how to turn the output of GetPlayerColor into a valid color code.
pawn Код:
format(string, sizeof(string), "{%06x}", (GetPlayerColor(playerid) >>> 8));
Reply
#9

I can answer the second question:

Код:
0xFF0000AA
0xFF0000AA
Reply
#10

Quote:
Originally Posted by AndreT
Посмотреть сообщение
This is a quick example of how to turn the output of GetPlayerColor into a valid color code.
pawn Код:
format(string, sizeof(string), "{%06x}", (GetPlayerColor(playerid) >>> 8));
OK, thanks, I will test it soon.

So, maybe someone knows how to detect bunnyhop good?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)