SetTimerEx -
NigNog1 - 12.03.2009
Passing strings in SetTimerEx doesn't work, and sometimes even causes server crashes.
pawn Code:
public CreatePlayerMessage(iPlayerID, szMessage[], iSeconds, iOffset)
{
if(IsPlayerMessageShowing(iPlayerID) && iOffset == 0)
{
DestroyPlayerMessage(iPlayerID);
}
if(iOffset > 0)
{
SetTimerEx("CreatePlayerMessage", iOffset * 1000, false, "isii", iPlayerID, szMessage, iSeconds, 0);
}
else
{
// If the offset param is more than 0 and the timer has ran, the server will crash here:
iPlayerMessage[iPlayerID] = TextDrawCreate(191,372,szMessage);
// rest of code
TextDrawUseBox(iPlayerMessage[iPlayerID],1);
TextDrawBoxColor(iPlayerMessage[iPlayerID],0x00000000);
TextDrawTextSize(iPlayerMessage[iPlayerID],542,23);
TextDrawBackgroundColor(iPlayerMessage[iPlayerID],0x000000ff);
TextDrawFont(iPlayerMessage[iPlayerID],1);
TextDrawLetterSize(iPlayerMessage[iPlayerID],0.499999,2.000000);
TextDrawColor(iPlayerMessage[iPlayerID],0xffffffcc);
TextDrawSetProportional(iPlayerMessage[iPlayerID],1);
TextDrawSetShadow(iPlayerMessage[iPlayerID],1);
TextDrawShowForPlayer(iPlayerID,iPlayerMessage[iPlayerID]);
iTextTime[iPlayerID][0] = iSeconds;
iTextTime[iPlayerID][1] = GetTickCount();
}
}
P.S: the [pawn] tags cause unpredicatable results in terms of indention. It isn't my fault if the indention is slightly wrong.
Update:
It's actually the Textdraw that is causing the server crash because it's trying to display an empty string.
Re: SetTimerEx -
luby - 12.03.2009
try to use 'd' instead of 'i' in settimerex formatting
Re: SetTimerEx - Double-O-Seven - 12.03.2009
SetTimerEx crashes the server, when you want to use a string
Re: SetTimerEx -
NigNog1 - 12.03.2009
Quote:
Originally Posted by Luby
try to use 'd' instead of 'i' in settimerex formatting
|
Symbols d and i both represent integers so it will not make a difference. And if you would have read my post you would have realised that the bug happens when passing strings.
Re: SetTimerEx -
luby - 12.03.2009
Quote:
Originally Posted by Stevelo
Quote:
Originally Posted by Luby
try to use 'd' instead of 'i' in settimerex formatting
|
Symbols d and i both represent integers so it will not make a difference. And if you would have read my post you would have realised that the bug happens when passing strings.
|
Ah, sorry ;X
so, try to define array size?
ex:
public CreatePlayerMessage(iPlayerID, szMessage[256], iSeconds, iOffset)
Re: SetTimerEx -
kaisersouse - 12.03.2009
Quote:
Originally Posted by Luby
Quote:
Originally Posted by Stevelo
Quote:
Originally Posted by Luby
try to use 'd' instead of 'i' in settimerex formatting
|
Symbols d and i both represent integers so it will not make a difference. And if you would have read my post you would have realised that the bug happens when passing strings.
|
Ah, sorry ;X
so, try to define array size?
ex:
public CreatePlayerMessage(iPlayerID, szMessage[256], iSeconds, iOffset)
|
Doing that it will only pass the 255th char in the string
Re: SetTimerEx -
luby - 12.03.2009
Quote:
Originally Posted by kaisersouse
Quote:
Originally Posted by Luby
Quote:
Originally Posted by Stevelo
Quote:
Originally Posted by Luby
try to use 'd' instead of 'i' in settimerex formatting
|
Symbols d and i both represent integers so it will not make a difference. And if you would have read my post you would have realised that the bug happens when passing strings.
|
Ah, sorry ;X
so, try to define array size?
ex:
public CreatePlayerMessage(iPlayerID, szMessage[256], iSeconds, iOffset)
|
Doing that it will only pass the 255th char in the string
|
i know but it may help
Re: SetTimerEx -
Harry_Gaill - 13.03.2009
No, he wants the entire string, not 1 character.
Re: SetTimerEx -
luby - 13.03.2009
Quote:
Originally Posted by Harry_Gaill
No, he wants the entire string, not 1 character.
|
ah, sorry, but doing this will pass 255 chars not 255th char
Re: SetTimerEx -
ICECOLDKILLAK8 - 13.03.2009
Quote:
Originally Posted by Luby
Quote:
Originally Posted by Harry_Gaill
No, he wants the entire string, not 1 character.
|
ah, sorry, but doing this will pass 255 chars not 255th char
|
Nope, It will select the 256th char from the string; if any and thats all that it will use