![]() |
|
[Plugin] SmartEvents - a plugin for timed events - Printable Version +- open.mp forum (https://forum.open.mp) +-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) +--- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) +---- Forum: Plugins (https://forum.open.mp/forumdisplay.php?fid=32) +---- Thread: [Plugin] SmartEvents - a plugin for timed events (/showthread.php?tid=4575) |
SmartEvents - a plugin for timed events - email.d.value - 2026-08-09 SmartEvents
SA-MP/OMP plugin for managing timed player events: Mute, Jail, VIP, etc. How it works When creating an event you need to specify:
Even for online events, data loss on crash isn't a problem. When an event is assigned, the necessary data is written to a temporary table, and it's removed when the player disconnects. If the server crashes, the data stays there. On restart the plugin checks the temporary table, calculates the difference between the saved time and the current startup time, and updates the main table. Requirements
Data storage All data is stored in an SQLite database at scriptfiles/SmartEvents.db. Integration Call two functions in your gamemode - one after login, another after registration: Code: public OnPlayerLogin(playerid)
{
// Your account loading
cache_get_value_name_int(0, "ID", PlayerInfo[playerid][pID]);
SE_OnPlayerLogin(playerid, PlayerInfo[playerid][pID]);
}
public OnPlayerSignIn(playerid)
{
// When the player has registered
PlayerInfo[playerid][pID] = cache_insert_id();
SE_OnPlayerSignIn(playerid, PlayerInfo[playerid][pID]);
}Usage example Code: new SE:gPlayerMute;
new SE:gPlayerJail;
public OnGameModeInit()
{
SE_SetLanguage("en");
gPlayerMute = SE_AddEvent("mute", "OnMuteExpired", true); // online - in-game time only
gPlayerJail = SE_AddEvent("jail", "OnJailExpired", true); // online - in-game time only
}
CMD:mute(playerid, params[])
{
SE_SetPlayerEvent(targetid, gPlayerMute, SE_MinutesToSeconds(30));
SendClientMessage(targetid, -1, "You have been muted for 30 minutes");
}
CMD:unmute(playerid, params[])
{
SE_RemovePlayerEvent(targetid, gPlayerMute);
SendClientMessage(targetid, -1, "Your mute has been removed");
}
CMD:jail(playerid, params[])
{
SE_SetPlayerEvent(targetid, gPlayerJail, SE_HoursToSeconds(1));
SendClientMessage(targetid, -1, "You have been jailed for 1 hour");
}
public OnPlayerText(playerid, text[])
{
if (SE_IsPlayerEventActive(playerid, gPlayerMute))
{
SendClientMessage(playerid, -1, "You are muted");
return 0;
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if (SE_IsPlayerEventActive(playerid, gPlayerJail))
{
SetPlayerPos(playerid, x, y, z);
}
return 1;
}
SE_Event:OnMuteExpired(playerid)
{
SendClientMessage(playerid, -1, "Your mute has expired");
}
SE_Event:OnJailExpired(playerid)
{
SetPlayerPos(playerid, x, y, z);
SendClientMessage(playerid, -1, "Your jail time has expired");
}Why is this better than subtracting and saving every second? DB queries: Tick & Save - every second per player / SmartEvents - on assignment + on disconnect Callback calls: Tick & Save - every second / SmartEvents - once, on expiration Benchmark 100 players with a 5-hour mute and 15 reconnects per player (reconnect for the plugin only). ![]() Documentation >> https://github.com/i-Saibot/SmartEvents/wiki Release >> https://github.com/i-Saibot/SmartEvents/releases |