[help] distance between object and player
#1

Why this code does not work properly?

pawn Код:
if(DistanceBetweenObjectAndPlayer(playerid) < 3.5){
//this close to the object
}else{
//not close to the object
}
pawn Код:
stock DistanceBetweenObjectAndPlayer(playerid){
    new Float:pos1[3],Float:pos2[3],Float:distance;
    for(new slots=1,idx=MAX_SLOTS;slots!=idx;slots++){
        GetObjectPos(VarObject[slots], pos1[0], pos1[1], pos1[2]);
        GetPlayerPos(playerid, pos2[0], pos2[1], pos2[2]);
        distance = floatsqroot(floatpower(floatabs(floatsub(pos1[0], pos2[0])),2)+floatpower(floatabs(floatsub(pos1[1], pos2[1])),2)+floatpower(floatabs(floatsub(pos1[2], pos2[2])),2));
    } return floatround(distance);
}
How can I do it correctly?
Reply


Messages In This Thread
[help] distance between object and player - by OTACON - 21.12.2013, 08:56
Re: [help] distance between object and player - by Ada32 - 21.12.2013, 09:04
Respuesta: [help] distance between object and player - by OTACON - 21.12.2013, 09:39
Re: [help] distance between object and player - by Ada32 - 21.12.2013, 10:56
Re: [help] distance between object and player - by RajatPawar - 21.12.2013, 11:39
AW: [help] distance between object and player - by Nero_3D - 21.12.2013, 12:34

Forum Jump:


Users browsing this thread: 1 Guest(s)