Detecting if in range of multiple objects
#1

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;
}
Reply
#2

GetDynamicObjectPos.
Reply
#3

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.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)