Timer / Moveobject problem -
Sascha - 04.10.2010
Hi,
I made a timer that check whether you are in range of a gate and then it should move the gate if you are higher or level 5...
However the gates doesn't move... (I am higher than level 5)
Here's the code:
newer code posted below
Re: Timer / Moveobject problem -
samgreen - 04.10.2010
Post your "ObjectMoveBack" function. Your syntax is wrong for SetTimerEx and your code could use some optimization. Post this function and I'll help you out.
Re: Timer / Moveobject problem -
Sascha - 04.10.2010
the ObjectMoveBack isn't necessary for it as far as I know...
It doesn't move the object when I'm in the range of it... so the problem can't be in the ObjectMoveBack
Re: Timer / Moveobject problem -
CrucixTM - 04.10.2010
Off-topic, but wow I hate that kind of placing brackets, in OP's post. Can't read it properly
Re: Timer / Moveobject problem -
Sascha - 05.10.2010
so any suggestions?
Re: Timer / Moveobject problem -
Scenario - 05.10.2010
pawn Код:
if(IsPlayerInRangeOfPoint(i, 1524.55212402,2779.05639648,11.42187500, 9.00 || IsPlayerInRangeOfPoint(i,1524.55212402,2767.21386719,11.42187500, 9.00 ||
IsPlayerInRangeOfPoint(i,1524.55212402,2773.19628906,10.67187500, 9.00)){
Re: Timer / Moveobject problem -
Sascha - 05.10.2010
you should at least look whether this works or whether it returns any errors, how your's does...
it is logic in my eyes that this has to return errors...
you are openeing 2 more "(" than you are closing...
(error: tag mismatch)
Re: Timer / Moveobject problem -
Scenario - 05.10.2010
Woops. Let me take another stab at that, one moment.
EDIT: You're checking if a player is in the area 2 times when it's not really necessary. Try this:
pawn Код:
public ObjectPosCheck()
{
new objectid;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerData[i][Level] >= 5)
{
if(IsPlayerInRangeOfPoint(i, 1524.55212402,2779.05639648,11.42187500, 9.00))
{
if(ObjectData[lg1][down] == 0)
{
MoveObject(lg1, 1524.55212402,2787.05566406,11.42187500, 2.00);
objectid = lg1;
SetTimerEx("ObjectMoveBack", MoveObject(lg1, 1524.55212402,2787.05566406,11.42187500, 2.00) + 2500, false, "i", objectid);
ObjectData[lg1][down] = 1;
}
}
else if(IsPlayerInRangeOfPoint(i,1524.55212402,2767.21386719,11.42187500, 9.00))
{
if(ObjectData[lg2][down] == 0)
{
MoveObject(lg2,1524.55212402,2758.96386719,11.42187500, 2.00);
objectid = lg2;
SetTimerEx("ObjectMoveBack", MoveObject(lg2,1524.55212402,2758.96386719,11.42187500, 2.00) + 2500, false, "i", objectid);
ObjectData[lg2][down] = 1;
}
}
else if(IsPlayerInRangeOfPoint(i,1524.55212402,2773.19628906,10.67187500, 9.00))
{
if(ObjectData[lg3][down] == 0)
{
MoveObject(lg3,1524.55175781,2773.19628906,0.17187500, 2.00);
objectid = lg3;
SetTimerEx("ObjectMoveBack", MoveObject(lg3,1524.55175781,2773.19628906,0.17187500, 2.00) + 2500, false, "i", objectid);
ObjectData[lg3][down] = 1;
}
}
}
}
}
return 1;
}
EDIT 2: Sorry, messed up an if statement. Try it now.
Re: Timer / Moveobject problem -
Sascha - 05.10.2010
already changed the code to this but it still doesn't works...
Код:
public ObjectPosCheck()
{
for(new i=0; i<MAX_PLAYERS; i++)
if(IsPlayerConnected(i)){
new Float:x, Float:y, Float:z;
GetPlayerPos(i, x, y, z);
if(IsPlayerInRangeOfPoint(i, 1524.55212402,2773.19628906,10.67187500, 5.00)){
if(PlayerData[i][Level] >= 5){
if(ObjectData[lg1][down] == 0){
new objectid;
MoveObject(lg1, 1524.55212402,2787.05566406,11.42187500, 2.00);
MoveObject(lg2,1524.55212402,2758.96386719,11.42187500, 2.00);
MoveObject(lg3,1524.55175781,2773.19628906,0.17187500, 2.00);
objectid = lg1;
SetTimerEx("ObjectMoveBack", MoveObject(lg1, 1524.55212402,2787.05566406,11.42187500, 2.00) + 2500, false, "i", objectid);
ObjectData[lg1][down] = 1;
}
}
}
}
return 1;
}
I also made it with a command, so I can at least drive through the gate, and the command works... it uses the same things as the function, just no the "IsPlayerInRangeOfPoint"...
anyway, I dislike the command so anyone knows how to fix this?
Re: Timer / Moveobject problem -
Sascha - 06.10.2010
bump.... any ideas? (checkout the new code posted ^)