Stopping a timer using y_timers.
#1

I can easily start a timer, it works fine, but I can't stop it for some reason?

Код:
COMMAND:timer(playerid, params[])
{
    SendClientMessage(playerid, COLOR_GREEN, "1 Second timer launched!");
    repeat PlayerData(playerid);
    return 1;
}

COMMAND:killtimer(playerid, params[])
{
    SendClientMessage(playerid, COLOR_GREEN, "1 Second timer stopped!");
    new Timer:x = repeat PlayerData(playerid);
    stop x;
    return 1;
}

timer PlayerData[1000](playerid)
{
    SendClientMessage(playerid, COLOR_YELLOW, "ONE SECOND HAS PASSED!");
}
Reply
#2

You need to name the timer when you first create it. Here's an example:

You'll need to of course add a new timer variable at the top of your script to make it global. So... new Timer:OneSecTimer[MAX_PLAYERS];

This is going to have to be under the first command: OneSecTimer[playerid] = repeat PlayerData(playerid);

Then in the killtimer command, you'll just need to have: stop OneSecTimer[playerid];

See how that works for you. If you have any questions, please ask!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)