08.11.2010, 10:03
hi .. i have a question..
its possibile do this functions (OnObjectStopMoving) ?? thx
its possibile do this functions (OnObjectStopMoving) ?? thx
forward OnObjectStopMoving(objectid);//forward the timer
public OnPlayerCommandText(playerid, cmdtext[])//from the wiki
{
if(strcmp(cmdtext, "/moveobject", true) == 0)
{
new string[50];
new movetime = MoveObject(obj, 0, 0, 10, 2.00);
format(string, sizeof(string), "Object will finish moving in %d milliseconds", movetime);
SendClientMessage(playerid, 0xFF000000, string);
SetTimerEx("OnObjectStopMoving", movetime, false, "i", objectid);// swap objectid for your gate/moving objects id
return 1;
}
return 0;
}
public OnObjectStopMoving(objectid)//this is called when the object stops moving
{
//do something with your object id here
return 1;
}
#include <a_samp>
new OldMove;
new NewMove;
new ObjectMoving;
forward isobjectmoving(Objectid);
forward OnObjectStopMoving(Objectid);
public OnFilterScriptInit()
{
OldMove = 0;
NewMove = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/moveobject", cmdtext, true) == 0)
{
// here you put something like new ObjectId;
// place something to check the ID for it;
ObjectMoving = SetTimer("isobjectmoving", 3000, 1); // this is a loop that repeats every 3 sec
return 1;
}
return 0;
}
public isobjectmoving(Objectid)
{
// here you put something to check if a object is moving something like NewMove = CheckObjectPosition(Objectid)
if(NewMove == OldMove)
{
KillTimer(ObjectMoving);
OnObjectStopMoving(Objectid);
return 1;
}
else
{
OldMove = NewMove;
}
return 1;
}
public OnObjectStopMoving(Objectid)
{
// your stuff here
return 1;
}