OnObectMoved problem
#1

here's my code

Код:
public OnObjectMoved(objectid)
{
	if(objectid == Shell_1){
	    new Float:tempx; new Float:tempy; new Float:tempz;
		GetObjectPos(Shell_1,tempx,tempy,tempz);
		CreateExplosion(tempx, tempy, tempz, 7, 10);
		DestroyObject(Shell_1);
		return 1;}
	else if(objectid == Shell_2){
	    new Float:tempx; new Float:tempy; new Float:tempz;
		GetObjectPos(Shell_2,tempx,tempy,tempz);
		CreateExplosion(tempx, tempy, tempz, 12, 10);
		DestroyObject(Shell_2);
		return 1;}
	else if(objectid == Shell_3){
	    new Float:tempx; new Float:tempy; new Float:tempz;
		GetObjectPos(Shell_3,tempx,tempy,tempz);
		CreateExplosion(tempx, tempy, tempz, 11, 10);
		DestroyObject(Shell_3);
		return 1;}
	else if(objectid == Shell_4){
	    new Float:tempx; new Float:tempy; new Float:tempz;
		GetObjectPos(Shell_4,tempx,tempy,tempz);
		CreateExplosion(tempx, tempy, tempz, 10, 10);
		DestroyObject(Shell_4);
		return 1;}
     return 1;
     }
anyways, when the object is moved they all create the same size explosions, which means only the first "if" is called, no matter which object moved. How do I fix this?
Reply
#2

pawn Код:
public OnObjectMoved(objectid)
{
    if(objectid == Shell_1)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_1,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 7, 10);
        DestroyObject(Shell_1);
        return 1;
    }
    if(objectid == Shell_2)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_2,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 12, 10);
        DestroyObject(Shell_2);
        return 1;
    }
    if(objectid == Shell_3)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_3,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 11, 10);
        DestroyObject(Shell_3);
        return 1;
    }
    if(objectid == Shell_4)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_4,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 10, 10);
        DestroyObject(Shell_4);
        return 1;
    }
    return 1;
}
?
Reply
#3

Quote:
Originally Posted by Kar
Посмотреть сообщение
pawn Код:
public OnObjectMoved(objectid)
{
    if(objectid == Shell_1)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_1,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 7, 10);
        DestroyObject(Shell_1);
        return 1;
    }
    if(objectid == Shell_2)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_2,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 12, 10);
        DestroyObject(Shell_2);
        return 1;
    }
    if(objectid == Shell_3)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_3,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 11, 10);
        DestroyObject(Shell_3);
        return 1;
    }
    if(objectid == Shell_4)
    {
        new Float:tempx; new Float:tempy; new Float:tempz;
        GetObjectPos(Shell_4,tempx,tempy,tempz);
        CreateExplosion(tempx, tempy, tempz, 10, 10);
        DestroyObject(Shell_4);
        return 1;
    }
    return 1;
}
?
Yes, what happens is that it doesn't matter which object moves, only the first "if"'s code happens. Does that make sense?
Reply
#4

maybe is used create explosion wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)