bmisiak / samp-precise-timers Goto Github PK
View Code? Open in Web Editor NEWA plugin for SA-MP providing precise timers, written in Rust.
Home Page: https://net4game.com
License: GNU Lesser General Public License v3.0
A plugin for SA-MP providing precise timers, written in Rust.
Home Page: https://net4game.com
License: GNU Lesser General Public License v3.0
WARN: failed to ensure package github.com/bmisiak/samp-precise-timers:v2.1.0: failed to ensure asset: failed to get plugin bmisiak/samp-precise-timers:v2.1.0 from net: resource matcher '^samp-precise-timers-(.*).zip$' does not match any release assets from '[ samp-precise-timers.dll samp-precise-timers.so]'
On v2.0.2 this is not a issue because the plugin has a zip file
I notice when I have something like "VAR[playerid] ++;" or "VAR[playerid] = VAR[playerid] +30 "is used in a timer loop it goes a bit crazy and the value does not increase properly. I did not have this issue until trying this plugin and when removing the plugin it works fine.
As a workaround I am now using VAR[playerid] +=1; which seems to work fine.
Everything else seems to be working great, thanks for the release!
The plugin is not compatible with open.mp
This problem exists only in 2.1.0, in version 2.0.2, this problem does not exist
create timer:
gPlayerSecondTimer[ playerid ] = SetPreciseTimer("UpdatePlayerTimer", 1000, true, "d", playerid);
consol (after creating timer):
[03:43:06] samp-precise-timers error: Error executing timer callback: Index out of bounds
I am using the v2.1.0 version of the plugin and when I send a value I get a different value.
Here is my code:
hook OnPlayerConnect(playerid)
{
if(!IClient_Auth(playerid, strval(gToken)))
{
Oyuncu_Kick(playerid);
return Y_HOOKS_BREAK_RETURN_1;
}
return 1;
}
stock Oyuncu_Kick(playerid)
{
new ping = GetPlayerPing(playerid) + 150;
SetPreciseTimer("Kicklendi", (ping > 500 ? 500 : ping), false, "d", playerid);
printf("P-1: %d", playerid);
}
forward Kicklendi(playerid);
public Kicklendi(playerid)
{
Kick(playerid);
printf("P-2: %d", playerid);
}
Result:
[17:44:33] [join] N_1_7357308 has joined the server (0:127.0.0.1)
[17:44:33] P-1: 0
[17:44:33] P-2: 46448452
Version 2.0.2 does not seem to have such a problem.
Result:
[17:46:55] [join] N_1_7357308 has joined the server (0:127.0.0.1)
[17:46:55] P-1: 0
[17:46:55] [part] N_1_7357308 has left the server (0:2)
[17:46:55] P-2: 0
Hello, I noticed the timer ID increased when I stopped and restarted the timer. For these long-term servers, I think there may be problems in the future due to the limits. I want you to add a function to update the timer duration instead of stopping the timer and starting it again.
How about adding support sampctl?
Array lengths in all other implementations, including other timer plugins, includes, and other natives like CallRemoteFunction
and CallLocalFunction
are passed using i
(or d
of course):
SetTimerEx("func", 1000, false, "ai", arr, sizeof (arr));
It would be nice if this was compatible with everything else.
So, if you want, these are the natives from the timers module in open.mp:
native SetTimer(const func[], msInterval, bool:repeat) = SetTimerEx;
native SetTimerEx(const func[], msInterval, bool:repeat, const params[], GLOBAL_TAG_TYPES:...);
native KillTimer(timer) = Timer_Kill;
// CreateTimer
native Timer:Timer_Create(const func[], usDelay, usInterval, repeatCount, const params[] = "", GLOBAL_TAG_TYPES:...);
// KillTimer
native bool:Timer_Kill(Timer:timer);
// Return time till next call.
native Timer_GetTimeRemaining(Timer:timer);
// Get number of calls left to make (0 for unlimited).
native Timer_GetCallsRemaining(Timer:timer);
// Get `repeatCount` parameter.
native Timer_GetTotalCalls(Timer:timer);
// Get `usInterval` parameter.
native Timer_GetInterval(Timer:timer);
// Reset time remaining till next call to `usInterval`.
native bool:Timer_Restart(Timer:timer);
The first two are just for backwards-compatibility (which is would be nice if this also supported, so it was a drop-in replacement that hooks and replaces the existing natives).
The rest are the improved API:
native Timer:Timer_Create(const func[], usDelay, usInterval, repeatCount, const params[] = "", GLOBAL_TAG_TYPES:...);
func
- Fairly obvious; what to call.usDelay
- Again obvious, the delay before the call (in microseconds).usInterval
- What to reset usDelay
to after the first call. So if you wanted a timer on the hour every hour, but it was 8:47am right now, the call would be Timer_Create("OnTheHour", 780 SECONDS, 3600 SECONDS, 0);
repeatCount
- Unlike the old functions, which are just "once" or "forever", this instead takes the number of times to call the function. "once" would be 1
, 500
would stop after 500 calls, and (backwards from the old API) 0
means "forever".GLOBAL_TAG_TYPES
- Like {Float, ...}
, but with more tags.What I'm saying is, if you want to get ahead of the game, implement that API.
How about this as a format specifier that passes the ID of the timer (t/T)?
Example before:
new gTimerID;
gTimerID = SetPreciseTimer("StartTimer", 1000, false, "i", playerid);
public StartTimer(playerid)
{
printf("playerid: %i, timerid: %i", playerid, gTimerID);
DeletePreciseTimer(gTimerID)
return 1;
}
Example after:
SetPreciseTimer("StartTimer", 1000, false, "it", playerid);
public StartTimer(playerid, timerid)
{
printf("playerid: %i, timerid: %i", playerid, timerid);
DeletePreciseTimer(timerid);
return 1;
}
The timerid will be passed not by the developer, and the plugin.
There seems to be a problem with the Linux version.
[sampgdk:warning] Native function not found: GetPlayerInterior
[sampgdk:warning] Native function not found: GetPlayerVirtualWorld
[sampgdk:warning] Native function not found: GetPlayerState
This only happens when loading this plugin and only on Linux.
Other plugins I use and their order is as follows: crashdetect.so mysql.so samp-previse-timers.so sscanf.so streamer.so regex.so
All of them are on their latest versions. Removing this plugin fixes the issue.
[20:24:20] Loading plugin: samp-precise-timers.so
[20:24:20] Failed (/lib/libc.so.6: version `GLIBC_2.18' not found (required by plugins/samp-precise-timers.so))
I have this error. I use CentOS 7.5 for my server. Need help
I know many people there would appreciate it. Most of the other Rust users have been banned from the SA:MP forums:
https://burgershot.gg/forumdisplay.php?fid=32
Thanks.
The default code basically does this:
switch (identifier)
{
case 'a': // array.
case 's': // string.
default: // cell.
}
Which means that while i
and d
are documented as integers, you can actually use anything. I know both Slice and I have written code that exploits this fact. YSI uses v
for reference parameters and x
for ...
(eXtra). The extra letters make no difference to SetTimerEx
, but mean that other code can also use the additional information contained in the string.
Could you support this please? Or at least an extended set of letters, off the top of my head I also know b
and l
have been used. Thanks.
Hello, does this plugin work stably on servers that remain open for a long time?
I got errors while running precise timers on my script, how can i fix it?
samp-precise-timers error: The amount of callback arguments passed (1) does not match the length of the list of types (3).
timer using:
Controller[playerid][km_Timer][keyid] = SetPreciseTimer("Key_Moving", Controller[playerid][km_Moving_Time], false, "ii", playerid, keyid);
Controller[playerid][km_Timer][keyid] = SetPreciseTimer("Key_Moving_Ex", Controller[playerid][km_Moving_Time], false, "ii", playerid, keyid);
Controller[playerid][km_ReUpdate_Timer] = SetPreciseTimer("OnPlayerFinishController", 100, true, "iiiiiiii", playerid, Controller[playerid][km_ID], Controller[playerid][km_Key_Pressed], Controller[playerid][km_Key_Missed], Controller[playerid][km_Perfect_Count], Controller[playerid][km_Great_Count], Controller[playerid][km_Cool_Count], Controller[playerid][km_Bad_Count]);
Controller[playerid][km_Generator_Timer] = SetPreciseTimer("ControllerGenerator", time_per_key, true, "i", playerid);
Controller[playerid][km_Reset_Miss_Timer] = SetPreciseTimer("ResetMissNotice", 500, false, "i", playerid);
Controller[playerid][km_Holding_Timer] = SetPreciseTimer("CheckingPlayerHoldingKeys", 10, true, "iii", playerid, keyid, lr);
Controller[playerid][km_Reset_Miss_Timer] = SetPreciseTimer("ResetMissNotice", 500, false, "i", playerid);
possible to add in the next version of the plugin native IsValidPreciseTimer(timerid); ?
for pawno code use the code bug
#define INVALID_TIMER_ID (0xFFFF)
IsValidPreciseTimer(timerid){
if(timerid != INVALID_TIMER_ID) return 1;
return 0;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.