GetPlayerDistanceFromPoint
#1

pawn Код:
forward Float:GetDistanceBetweenPlayers(p1,p2);
pawn Код:
stock Float:GetDistanceBetweenPlayers(p1,p2){
    new Float:x1,Float:y1,Float:z1,Float:x3,Float:y3,Float:z3;
    if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x3,y3,z3);
    return floatsqroot(floatpower(floatabs(floatsub(x3,x1)),2)+floatpower(floatabs(floatsub(y3,y1)),2)+floatpower(floatabs(floatsub(z3,z1)),2));
}
pawn Код:
CMD:i( playerid, params[ ] )
{
    new ID, string[ 128 ], string2[ 128 ], name[ MAX_PLAYER_NAME ];
    new Float:Distance = GetDistanceBetweenPlayers(playerid,ID);
    if( sscanf( params, "u", ID ) ) return SendClientMessage( playerid, COLOR_WHITE, "USAGE: /i [id]" );
    if( IsPlayerConnected( ID ) == 0) return SendClientMessage( playerid, COLOR_RED, "Player is not connected!" );
    GetPlayerName( ID, name, MAX_PLAYER_NAME );

    new carid = GetPlayerVehicleID( ID );
    TextDrawShowForPlayer( playerid, info1 );
    TextDrawShowForPlayer( playerid, info0 );
    if( !IsPlayerInAnyVehicle( ID ) )
    {
        format( string, 128, "~y~Player Info: ~r~~h~%s[%d]~n~~n~~g~Location:~w~%s~n~~g~Distance:~w~%0.2f~n~~g~Vehicle:~w~On Foot", name, ID, ReturnPlayerZone( ID ), Distance );
    }
    else
    {
        format( string, 128, "~y~Player Info: ~r~~h~%s[%d]~n~~n~~g~Location:~w~%s~n~~g~Distance:~w~%0.2f~n~~g~Vehicle:~w~%s", name, ID, ReturnPlayerZone( ID ), Distance, VehicleNames[ GetVehicleModel( carid ) - 400 ] );
    }
    TextDrawSetString( info1, string );
    return 1;
}
Its only showing the distance between you and id 0 no matter what id you put in: http://i.imgur.com/qYr2Q.jpg
Reply


Messages In This Thread
GetDistanceBetweenPlayers +rep - by SnG.Scot_MisCuDI - 10.03.2012, 17:40
Re: GetPlayerDistanceFromPoint - by IstuntmanI - 10.03.2012, 17:55
Re: GetPlayerDistanceFromPoint - by Konstantinos - 10.03.2012, 18:02
Re: GetPlayerDistanceFromPoint - by SnG.Scot_MisCuDI - 10.03.2012, 19:40
Re: GetPlayerDistanceFromPoint - by SnG.Scot_MisCuDI - 10.03.2012, 21:58
Re: GetPlayerDistanceFromPoint - by [ABK]Antonio - 10.03.2012, 22:26
Re: GetPlayerDistanceFromPoint - by SnG.Scot_MisCuDI - 10.03.2012, 22:28
Re: GetPlayerDistanceFromPoint - by eesh - 11.03.2012, 03:50
Re: GetPlayerDistanceFromPoint - by SnG.Scot_MisCuDI - 11.03.2012, 06:48

Forum Jump:


Users browsing this thread: 2 Guest(s)