? -
Gh0sT_ - 22.08.2011
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.
Re: ? -
iMonk3y - 22.08.2011
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...
Re: ? -
Gh0sT_ - 22.08.2011
Thx, works, now:
maybe someone knows not so hard way to do anti bunnyhop?
Re: ? -
Riddick94 - 22.08.2011
OnPlayerKeyStateChange
pawn Код:
SetTimerEx("ResetBunny");
Variable += 1;
if(Variable >= 3)
{
ApplyAnim, kick, ban what ever.
ResetBunny.
}
ResetBunny
{
Variable = 0;
return true;
}
Re: ? -
RyDeR` - 22.08.2011
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;
}
Re: ? -
Gh0sT_ - 22.08.2011
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})
Re: ? -
Gh0sT_ - 24.08.2011
^^^^
Re: ? -
AndreT - 24.08.2011
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));
Re: ? -
iMonk3y - 24.08.2011
I can answer the second question:
Код:
0xFF0000AA
0xFF0000AA
Re: ? -
Gh0sT_ - 24.08.2011
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?