3 times the same output? -
Whoop - 29.12.2010
It should give me correct messages after each 4 seconds.. But it will give me 3 times the same. :S
pawn Код:
//______________//
// The Gamemode //
//______________//
//////////////////
public OnPlayerSpawn(playerid)
{
CallRemoteFunction("ShowInfoBoxPersonal","isi",playerid, "IS SHOULD SHOW MESSAGE NUMBERO 1 I HOPE IT DOES", 4000);
CallRemoteFunction("ShowInfoBoxPersonal","isi",playerid, "IS SHOULD SHOW MESSAGE NUMBERO 2 I HOPE IT DOES", 8000);
CallRemoteFunction("ShowInfoBoxPersonal","isi",playerid, "IS SHOULD SHOW MESSAGE NUMBERO 3 I HOPE IT DOES", 12000);
}
//__________________//
// The FilterScript //
//__________________//
//////////////////////
forward ShowInfoBoxPersonal(playerid, text[], time);
public ShowInfoBoxPersonal(playerid, text[], time)
{
Slots--;
SetTimers[Slots] = SetTimerEx("CreateBox", time, false, "is", playerid, text);
if(Slots == 0) { Slots = 3; }
if(!ProcessingPersonal[playerid])
{
ProcessingPersonal[playerid] = 1;
}
}
forward CreateBox(playerid, text[]);
public CreateBox(playerid, text[])
{
printf("playerid = %d, text = %s",playerid,text);
KillTimer(HideBox[playerid]);
HideBox[playerid] = SetTimerEx("HideInfoBox",4500,false,"i",playerid);
TextDrawHideForPlayer(playerid, InfoBox[playerid]);
TextDrawSetString(InfoBox[playerid], text);
TextDrawShowForPlayer(playerid, InfoBox[playerid]);
return 1;
}
//______________________________________//
// What happens in server log by printf //
//______________________________________//
//////////////////////////////////////////
[18:19:26] playerid = 0, text = IS SHOULD SHOW MESSAGE NUMBERO 3 I HOPE IT DOES
[18:19:30] playerid = 0, text = IS SHOULD SHOW MESSAGE NUMBERO 3 I HOPE IT DOES
[18:19:35] playerid = 0, text = IS SHOULD SHOW MESSAGE NUMBERO 3 I HOPE IT DOES
Re: 3 times the same output? -
Nero_3D - 29.12.2010
SetTimerEx dislikes strings, feed him some cookies than he may be willed
Re: 3 times the same output? -
Whoop - 29.12.2010
What? I don't get it :S o.O
Re: 3 times the same output? -
Nero_3D - 29.12.2010
Just dont send strings with SetTimerEx
Re: 3 times the same output? -
Whoop - 29.12.2010
How to do this then? It has to send 3 times each 4 seconds a message. :S
Re: 3 times the same output? -
Whoop - 30.12.2010
Someone?
Re: 3 times the same output? -
Mauzen - 30.12.2010
It is not that simple, but should work: (Use a buffer string array and send its index instead of the string itself)
pawn Код:
new indexstrings[16][128]; //Global variable in your filterscript
public ShowInfoBoxPersonal(playerid, text[], time)
{
new slot;
Slots--;
for(new i = 0; i < 16; i ++) //This searches a free string in the indexstrings array
{
if(!strlen(indexstrings[i]))
{
slot = i;
break;
}
}
strcat(indexstrings[slot], text); //store the text in the free string in the array
SetTimers[Slots] = SetTimerEx("CreateBox", time, false, "ii", playerid, slot); //send the index of the string in the array
if(Slots == 0) { Slots = 3; } //instead of the array itself
if(!ProcessingPersonal[playerid])
{
ProcessingPersonal[playerid] = 1;
}
}
public CreateBox(playerid, slot)
{
new text[128] = indesxstrings[slot]; //get the string back out of the array
indexstrings[slot] = ""; //at last, empty the string, so it can be used again
printf("playerid = %d, text = %s",playerid,text);
KillTimer(HideBox[playerid]);
HideBox[playerid] = SetTimerEx("HideInfoBox",4500,false,"i",playerid);
TextDrawHideForPlayer(playerid, InfoBox[playerid]);
TextDrawSetString(InfoBox[playerid], text);
TextDrawShowForPlayer(playerid, InfoBox[playerid]);
return 1;
}
Re: 3 times the same output? -
MadeMan - 30.12.2010
Yes, sending strings in 0.3b was bugged, but it should be fixed in 0.3c ?
Re: 3 times the same output? -
Hiddos - 30.12.2010
Bug most probably existed before 0.3a:
http://forum.sa-mp.com/showthread.ph...ght=SetTimerEx
Re: 3 times the same output? -
Whoop - 30.12.2010
Thanks allot but i am getting 1 error,
Код:
error 008: must be a constant expression; assumed zero
pawn Код:
new text[128] = indexstrings[slot];
Also, shouldnt be indexstrings[slot] = ""; on the last line instead of right after
pawn Код:
new text[128] = indexstrings[slot];
Because before he could send it to the box it would be empty already