Problem
#1

Well I am making command Signal which will add a signal next to you. I found object and everything needed as I wanted, but I have problem now. I want to set a timer 5 seconds, which will after 5 seconds delete the object, but I don't get it what's the problem with this.

When I added the timer the script just stopped working. Please help me. Without the timer it was working normaly but still I want the timer with it.

Код:
if (strcmp("/signal", cmdtext, true) == 0)
	{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        new Signal;
        Signal = CreateObject(18674,x,y,z, 0.0, 0.0, 96.0);
        CreateObject(Signal,x,y,z, 0.0, 0.0, 96.0);
	{
	        SetTimer("Signal", 5000, false);
	}
	DestroyObject(Signal);
        return 1;
	}
Bump: I never worked with these timers before.
Reply
#2

pawn Код:
if (strcmp("/signal", cmdtext, true) == 0)
{
    new Float:x, Float:y, Float:z, SignalObj;
    GetPlayerPos(playerid, x, y, z);
    SignalObj = CreateObject(18674,x,y,z, 0.0, 0.0, 96.0);
    SetTimer("Signal", 5000, false);
    return 1;
}

forward Signal();
public Signal()
{
    DestroyObject(SignalObj);
    return 1;
}
Structure should look like this
Reply
#3

All that bellow OnPlayerCommand?
Reply
#4

only the command under OnPlayerCommand.

The timer and its forward you can place where ever you want it to have but OUTside of a callback/function.
Reply
#5

Just a little edit of BlackWolf's code.
pawn Код:
// The command.
if (strcmp("/signal", cmdtext, true) == 0)
{
    new Float:x, Float:y, Float:z, SignalObj;
    GetPlayerPos(playerid, x, y, z);
    SignalObj = CreateObject(18674,x,y,z, 0.0, 0.0, 96.0);
    SetTimerEx( "Signal", 5000, false, "i", SignalObj );
    return 1;
}

// Somewhere outside onplayercommandtext.
forward Signal( objectid );
public Signal( objectid )
{
    DestroyObject( objectid );
    return 1;
}
Reply
#6

overloocked that, thx Psymetrix, should work now.
Reply
#7

Thanks ^_^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)