SetTimerEx
#1

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.
Reply
#2

try to use 'd' instead of 'i' in settimerex formatting
Reply
#3

SetTimerEx crashes the server, when you want to use a string
Reply
#4

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.
Reply
#5

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)
Reply
#6

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
Reply
#7

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
Reply
#8

No, he wants the entire string, not 1 character.
Reply
#9

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
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)