Closed ZantetsukenGT closed 2 years ago
Are you able to reproduce this on windows too?
Okay look I think I know what's the issue here.
Giving a little more of context, this pause timer thing is used to freeze the players, vehicles and other timers in place to pause an attack vs defender round, maintaining the round state integrity for both teams.
The round pause can be triggered through a command, key bind or when a player in the round
crashes/timeouts/gets kicked or promptly /q'd.
Players crash/quit/get kicked all the time and only managed to cause the crash when one of the players in the round disconnects and triggers the pause function.
So generally speaking i think it only crashes when one of the player is no longer online and i call the TextDrawSetString
function, prolly a race condition or similar.
In short the snippet above isn't enough and will provide one later.
Can you give it a little more test, and see if you are calling TextDrawSetString for that disconnected player as well? Shouldn't be an issue by default, but just asking, or calling TextDrawSetString and then show it in OnPlayerDisconnect when your player disconnects
try this snippet instead, this crashes on windows as well, but doesn't give a fancy stack trace
#include <a_samp>
main() {}
new Text: PauseTD;
new TotalPausesInRound;
new PauseTimeElapsed;
public OnPlayerDisconnect()
{
PauseTD = TextDrawCreate(324.000000, 390.000000, "~r~~h~~h~Round paused");
TextDrawBackgroundColor(PauseTD, 0x00000044);
TextDrawFont(PauseTD, 1);
TextDrawLetterSize(PauseTD, 0.280000, 1.500000);
TextDrawColor(PauseTD, 255);
TextDrawSetOutline(PauseTD, 1);
TextDrawSetProportional(PauseTD, 1);
TextDrawAlignment(PauseTD, 2);
TextDrawShowForAll(PauseTD);
SetTimer("PauseStopWatch", 3000, true);
return 1;
}
forward PauseStopWatch();
public PauseStopWatch()
{
PauseTimeElapsed++;
new str[68];
format(str, sizeof str, "~r~~h~Round is paused!~n~~w~Time: ~r~~h~%02d:%02d ~w~Count: ~r~~h~%d", PauseTimeElapsed / 60, PauseTimeElapsed % 60, TotalPausesInRound);
TextDrawSetString(PauseTD, str);
return 1;
}
Fixed next build.
Description
Im currently using a textdraw which is never destroyed, only hidden or set text to "_" and its only purpose is to show time passed every 1000 ms and crashes when using
TextDrawSetString(textdraw, text[])
How to re-produce this bug
it may be related to passing in a buffer without proper null terminator Im sharing a snippet which has an oddly sized buffer just to showcase the bug, try to play around the timer repeat values
prolly i could prevent the crash using va_return instead, this is just legacy code i happen to be maintaining and didn't crash on samp
Relevant log output
open.mp server version
*build 2
Operating system or distribution
*Debian 11 64-bit with
Contact information
*Zantetsuken#2220