SA-MP Forums Archive
OnObectMoved problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnObectMoved problem (/showthread.php?tid=163298)



OnObectMoved problem - VictorMartinez - 26.07.2010

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?


Re: OnObectMoved problem - Kar - 26.07.2010

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;
}
?


Re: OnObectMoved problem - VictorMartinez - 26.07.2010

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?


Re: OnObectMoved problem - VictorMartinez - 27.07.2010

maybe is used create explosion wrong?