19.04.2015, 12:05
Hey guys, I basically want a message system where a message shows for 10 seconds displaying information and if there is already a message showing it will wait before showing itself. Right now I have the second message kill the first but I want it to queue itself. The code I currently have is:
Now I didn't write this code, a friend helped me with this but he wasn't able to help with the issue.
Basically whenever a message is shown it works first time, then if another message comes up before 10 seconds it messes around a bit. It will always override the first message but it sometimes shows for a few seconds or just for a second.. I hope I am making sense and if you need any more information please let me know. I just want to fix this and actually understand what the problem is. Thank you!
pawn Код:
new PlayerText:JobHelpText[MAX_PLAYERS];
new bool:TimerRunning[MAX_PLAYERS];
// OnPlayerConnect:
TimerRunning[playerid] = false;
CMD:info(playerid, params[])
{
new string[256];
format(string,sizeof(string),"%s",params);
if (!TimerRunning[playerid])
{
PlayerTextDrawSetString(playerid,JobHelpText[playerid], string);
PlayerTextDrawShow(playerid,JobHelpText[playerid]);
SetTimerEx("JobHelpTextTimer", 10000, false, "i", playerid);
}
else
{
new temp[12];
for (new i; ; i++) // (semi-)infinite loop
{
format(temp, sizeof(temp), "HelpText%i", i);
if (!GetPVarType(playerid, temp))
{
SetPVarString(playerid, temp, string);
break;
}
}
}
return 1;
}
forward JobHelpTextTimer(playerid);
public JobHelpTextTimer(playerid)
{
if (!GetPVarType(playerid, "HelpText0"))
{
PlayerTextDrawHide(playerid, JobHelpText[playerid]);
}
else
{
new string[256], temp[12], temp2[12];
GetPVarString(playerid, temp, string, sizeof(string));
PlayerTextDrawSetString(playerid,JobHelpText[playerid], string);
SetTimerEx("JobHelpTextTimer", 10000, false, "i", playerid);
for (new i; ; i++)
{
format(temp, sizeof(temp), "HelpText%i", i);
format(temp2, sizeof(temp2), "HelpText%i", i + 1);
if (!GetPVarType(playerid, temp2))
{
DeletePVar(playerid, temp);
break;
}
else
{
GetPVarString(playerid, temp2, string, sizeof(string));
SetPVarString(playerid, temp, string);
}
}
}
return 1;
}
Basically whenever a message is shown it works first time, then if another message comes up before 10 seconds it messes around a bit. It will always override the first message but it sometimes shows for a few seconds or just for a second.. I hope I am making sense and if you need any more information please let me know. I just want to fix this and actually understand what the problem is. Thank you!