Simply install to your project:
sampctl package install r4sheed/pawn-plus-tasksInclude in your code and begin using the library:
#include <pp-tasks>Use the task macro to define functions that run automatically at a set interval.
#include <pp-tasks>
task TaskName[interval]()
{
// This task executes every <interval> milliseconds.
}Warning
Tasks can only take playerid for ptask. Adding any other parameters will cause compiler errors because the system runs them automatically and cannot handle extra arguments.
Use the ptask macro to define player-specific tasks. These run at the specified interval for each connected player.
#include <pp-tasks>
ptask PlayerTaskName[interval](playerid)
{
// This task executes for each connected player every <interval> milliseconds.
}Note
Player tasks do not run for NPCs.
#include <pp-tasks>
ptask HealPlayer[5_000](playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
new Float:bonus = 5.0;
if ((health + bonus) <= 100.0)
SetPlayerHealth(playerid, (health + bonus));
}