SA-MP Forums Archive
Detecting if in range of multiple objects - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detecting if in range of multiple objects (/showthread.php?tid=350432)



[SOLVED]Detecting if in range of multiple objects - V1ceC1ty - 12.06.2012

So I'm trying to detect if the player is in range of different objects around the map but it doesn't seem to come back with anything in game, this is the code. How can I fix this, I get no errors when compiling.

pawn Код:
#define PICKUP KEY_CROUCH
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new trash1 = 849;
new trash2 = 850;
new trash3 = 851;

new trash[2];

public OnGameModeInit()
{
    trash[0] = CreateStreamObject(trash1,-1434.83980000,-1543.10680000,101.15780000,0,0,0,250);
    trash[1] = CreateStreamObject(trash2,-1458.52770000,-1568.13610000,101.15780000,0,0,0,250);
    trash[2] = CreateStreamObject(trash3,-1461.26840000,-1571.22050000,101.15000000,0,0,0,250);
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    if (PRESSED(PICKUP))
    {
   
        new Float:x,Float:y,Float:z;
        for(new object;object<sizeof(trash);object++)
        {
            GetObjectPos(trash[object],x,y,z);
            if(IsPlayerInRangeOfPoint(playerid,3.0,x,y,z))
            {
                GameTextForPlayer(playerid, "~w~Looking through trash.", 1000, 3);
                ApplyAnimation(playerid,"MISC","pickup_box",4.1,0,1,1,0,1,1);
                break;
            }
        }
    }
    return 1;
}



Re: Detecting if in range of multiple objects - Riddick94 - 12.06.2012

GetDynamicObjectPos.


Re: Detecting if in range of multiple objects - Jonny5 - 12.06.2012

try using the x,y,z from the array instead of getting the pos with a function,

also what streamer are you using?
I ask because it may have its own GetObjectPos function.


Re: Detecting if in range of multiple objects - V1ceC1ty - 12.06.2012

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
try using the x,y,z from the array instead of getting the pos with a function,

also what streamer are you using?
I ask because it may have its own GetObjectPos function.
Damn it, I'm an idiot. I'm using MidoStreamer, thanks for your help I've fixed it