CreateObject
#1

Hello!

I want to do this, if i have 3 object maked.
pawn Код:
new Object[3];
Object[0] = CreateObject(3409, x, y, z, - 1.3, 0.0, 0.0);
Object[1] = CreateObject(3409, x, y, z, - 1.3, 0.0, 0.0);
Object[2] = CreateObject(3409, x, y, z, - 1.3, 0.0, 0.0);
Then if i touch some object.
pawn Код:
public removeObjects()
{
    foreach (new i : Player)
    {
        if(IsPlayerInRangeOfPoint(i, 1, x, y, z)) // I dont know what do add here.
        {
            DestroyObject(Object[something here]); // And here.
        }
    }
    return 1;
}
I don't understand how do make this.
Need using loops or something?
Reply
#2

So if I understand you right, you want to make 3 objects and when someone touches them what should happen then?
Reply
#3

No idea, how to make it properly. =(
Maybe you can destroy it, if player shot in object?
Would be something like this:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == BULLET_HIT_TYPE_OBJECT)
    {
        if(hitid >= Object[0] && hitid <= Object[2])
        {
             DestroyObject(hitid);
        }  
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by DavidSparks
Посмотреть сообщение
So if I understand you right, you want to make 3 objects and when someone touches them what should happen then?
So when someone touches first object then the first object get destroyed and when someone touches the second object then seconds object get destroyed and so..

Something like that.
pawn Код:
new Object[3];
new Float:ObjectX[3], Float:ObjectY[3], Float:ObjectZ[3];
forward removeObjects();

CMD:lol(playerid, paramas[])
{
    Object[0] = CreateObject(3409, 781.7954,317.2031,20.2952 - 1.3, 0.0, 0.0, 12.0359 + 90);
    ObjectX[0] = 781.7954;
    ObjectY[0] = 317.2031;
    ObjectZ[0] = 20.2952;
   
    Object[1] = CreateObject(3409, 786.6342,318.3507,20.2842 - 1.3, 0.0, 0.0, 22.3759 + 90);
    ObjectX[1] = 786.6342;
    ObjectY[1] = 318.3507;
    ObjectZ[1] = 20.2842;
   
    Object[2] = CreateObject(3409, 792.0835,320.0193,20.2466 - 1.3, 0.0, 0.0, 7.6490 + 90);
    ObjectX[2] = 792.0835;
    ObjectY[2] = 320.0193;
    ObjectZ[2] = 20.2466;
    return 1;
}

public removeObjects()
{
    foreach (new i : Player) //use normal loop if ur not using foreach
    {
        if(IsPlayerInRangeOfPoint(i, 1, ObjectX[0], ObjectY[0], ObjectZ[0]))
        {
            DestroyObject(Object[0]);
        }
        else if(IsPlayerInRangeOfPoint(i, 1, ObjectX[1], ObjectY[1], ObjectZ[1]))
        {
            DestroyObject(Object[1]);
        }
        else if(IsPlayerInRangeOfPoint(i, 1, ObjectX[2], ObjectY[2], ObjectZ[2]))
        {
            DestroyObject(Object[2]);
        }
    }
    return 1;
}
But when i have 100 object then i want to use loop.
Reply
#5

Help? Please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)