timer / textdraw bug
#1

Hi, I'm having an issue with textdraws, so when a player hits someone in the head with either a deagle or sniper, both players get something like:

PHP код:
new Text:DescriptionText[MAX_PLAYERS];
new 
DescriptionTimer[MAX_PLAYERS];
forward HideDescriptionText(playerid);
public 
OnPlayerHeadShot(playeridissueridFloat:amount)
{
    new
        
up_string128 ],
        
pk_string128 char ],
        
pNameMAX_PLAYER_NAME ]
    ;
    
GetPlayerName(issueridpNamesizeof(pName));
    
strunpack(up_stringpk_string);
    
//format(up_string, sizeof(up_string), "[DEBUG] - Headshot detected executed by %s[%i] - damage %.3f", pName, playerid, amount);
    //SendClientMessage(playerid, -1, up_string);
    //GameTextForPlayer(issuerid,"    ~g~HEAD~b~SHOT!",2000,3);
    
new string[126], stringh[126];
    
/*format(string, sizeof(string), "~n~ ~n~ ~n~ ~n~ ~n~ ~r~[HEADSHOT]~w~You got killed by:~y~%s~w~.", gName(issuerid));
    format(stringh, sizeof(stringh), "n~ ~n~ ~n~ ~n~ ~n~ ~r~[HEADSHOT]~w~You killed :~y~%s~w~!", gName(playerid));
    GameTextForPlayer(issuerid,stringh,2000,3);
    GameTextForPlayer(playerid,string,2000,3);*/
     
format(stringsizeof(string), "~r~[HEADSHOT]~w~You got killed by:~y~%s~w~."gName(issuerid));
    
format(stringhsizeof(stringh), "~r~[HEADSHOT]~w~You killed :~y~%s~w~!"gName(playerid));
    
ShowDescriptionText(issueridstringh);
    
ShowDescriptionText(playeridstring);
    
SetPlayerHealth(playerid0.0);
    return 
strpack(up_stringpk_string);
}
stock ShowDescriptionText(playeridstring[])
{
    
KillTimer(DescriptionTimer[playerid]);
    
TextDrawSetString(DescriptionText[playerid], string);
    
TextDrawShowForPlayer(playeridDescriptionText[playerid]);
    
DescriptionTimer[playerid] = SetTimerEx("HideDescriptionText"50000"i"playerid);
    return 
1;
}
forward HideDescriptionText(playerid);
public 
HideDescriptionText(playerid)
{
    
TextDrawHideForPlayer(playeridDescriptionText[playerid]);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
DescriptionText[playerid] = TextDrawCreate(310.0270.0" ");
    
TextDrawAlignment(DescriptionText[playerid], 2);
    
TextDrawFont(DescriptionText[playerid], 1);    
    
TextDrawLetterSize(DescriptionText[playerid], 0.3200001.700000);
    
TextDrawSetOutline(DescriptionText[playerid], 1);
    
TextDrawHideForPlayer(playeridDescriptionText[playerid]);
    return 
1;
}
public 
OnPlayerDisconnect(playerid)
{
    
DescriptionText[playerid] = TextINVALID_TEXT_DRAW;
    return 
1;

After approx 24 hours of uptime(server uptime) for some reason the textdraws stop appearing for all players, even if reconnected to the server, the headshot system still works tho as it's called by onplayertakedamage.

I think this may be a timer problem so I'm hoping someone here will help me understand how can I show the textdraw temporarly without creating a timer for each player.

Thanks in advance!
Reply
#2

bump
Reply
#3

bump
Reply
#4

You want to Show a textdraw whenever a player shots someone in head and hide the TD after 5 seconds?
Reply
#5

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
You want to Show a textdraw whenever a player shots someone in head and hide the TD after 5 seconds?
I don't want to do that, I already did that which works for the first 15 - 20 hours of uptime, then it magically dissapears and never shows again until I kill the server or /rcon gmx
Reply
#6

Well maybe because you are creating one textdraw again and again? Destroy it on disconnect or use playertextdraw.
Reply
#7

Quote:
Originally Posted by Matess
Посмотреть сообщение
Well maybe because you are creating one textdraw again and again? Destroy it on disconnect or use playertextdraw.
Thank you, I will try that now and give feedback within the next 24 hours!

EDT:

It seems that now the textdraws are getting overwritten.
(take a look at the commented line)
PHP код:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#if defined FILTERSCRIPT
new Text:TDEditor_TD[2];
forward HideDescriptionText(playerid);
forward OnPlayerHeadShot(playeridissueridFloat:amount);
public 
OnFilterScriptInit()
{
    
TDEditor_TD[0] = TextDrawCreate(402.1995844.378755"Watch_movies_online_for_free_at_movies1337.com"); //This one here is changing to [HEADSHOT]blablabla
    
TextDrawLetterSize(TDEditor_TD[0], 0.4000000.800000);
    
TextDrawAlignment(TDEditor_TD[0], 2);
    
TextDrawColor(TDEditor_TD[0], 255);
    
TextDrawSetShadow(TDEditor_TD[0], 0);
    
TextDrawSetOutline(TDEditor_TD[0], 1);
    
TextDrawBackgroundColor(TDEditor_TD[0], 16711935);
    
TextDrawFont(TDEditor_TD[0], 2);
    
TextDrawSetProportional(TDEditor_TD[0], 1);
    
TextDrawSetShadow(TDEditor_TD[0], 0);
    
TDEditor_TD[1] = TextDrawCreate(166.000000432.044494"play.bestsampserver.com:7777__/teles_/cmds_/rules");
    
TextDrawLetterSize(TDEditor_TD[1], 0.4000001.600000);
    
TextDrawAlignment(TDEditor_TD[1], 1);
    
TextDrawColor(TDEditor_TD[1], -1);
    
TextDrawSetShadow(TDEditor_TD[1], 0);
    
TextDrawSetOutline(TDEditor_TD[1], 1);
    
TextDrawBackgroundColor(TDEditor_TD[1], 255);
    
TextDrawFont(TDEditor_TD[1], 1);
    
TextDrawSetProportional(TDEditor_TD[1], 1);
    
TextDrawSetShadow(TDEditor_TD[1], 0);
    
    
TextDrawShowForAll(TDEditor_TD[0]);
    
TextDrawShowForAll(TDEditor_TD[1]);
    return 
1;
}
public 
OnFilterScriptExit()
{
    
TextDrawDestroy(TDEditor_TD[0]);
    
TextDrawDestroy(TDEditor_TD[1]);
    return 
1;
}
#else
main()
{
}
#endif
public OnGameModeInit()
{
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
TextDrawShowForAll(TDEditor_TD[0]);
    
TextDrawShowForAll(TDEditor_TD[1]);
    return 
1;

PS. I think this might be because ongamemodeexit(I used gmx because high player count) there's no code reseting the variable that stores the textdraw so one of the player's must have the ID of the textdraw TDEditor_TD[0].

No big deal if that's the case, I'll just reset everyone's textdraw variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)