Calling %s in a textdraw? Help needed.
#7

Код:
//Top of your script
new FALSE = false;
#define TextDrawSetFormat(%0,%1) do{new _str[128]; format(_str,128,%1); TextDrawSetString(%0,_str);}while(FALSE) //This function isn't really necessary, but it simplified the script.

new AFKTDTimer;
new bool:IsAFKShown;

forward HideAFK();
Код:
public OnGameModeInit()
{
	IsAFKShown = false;
}
Код:
public SomePublicWhereYouWantToCreateYourTextDraw(...)
{
	IsAFK = TextDrawCreate(260.000000,222.000000,"_"); //Empty TextDraw, it isn't needed to contain something.
	TextDrawAlignment(IsAFK,0);
	TextDrawBackgroundColor(IsAFK,0x000000ff);
	TextDrawFont(IsAFK,3);
	TextDrawLetterSize(IsAFK,0.599999,1.900000);
	TextDrawColor(IsAFK,0xff0000ff);
	TextDrawSetOutline(IsAFK,1);
	TextDrawSetProportional(IsAFK,1);
	TextDrawSetShadow(IsAFK,1);
}
Код:
public OnPlayerCommandText(playerid, cmdtext)
{
	if(strcmp("/afk",cmdtext, true) == 0) 
	{
		if(IsAFKShown == true) KillTimer(AFKTDTimer);
		AFKTDTimer = SetTimer("HideAFK", 5000, false);
		IsAFKShown = true;
		TogglePlayerControllable(playerid,0);
		TextDrawSetFormat(IsAFK, "%s is now AFK!", PlayerName(playerid)) //PlayerName Function from [LSD]Rac3r
		TextDrawShowForAll(IsAFK);
		return 1;
	}
	return 0;
}
Код:
public HideAFK()
{
	IsAFKShown = false;
	TextDrawHideForAll(IsAFK);
	return 1;
}
Should work.
Reply


Messages In This Thread
Calling %s in a textdraw? Help needed. - by Devine - 27.11.2009, 03:16
Re: Calling %s in a textdraw? Help needed. - by Rac3r - 27.11.2009, 07:01
Re: Calling %s in a textdraw? Help needed. - by Devine - 27.11.2009, 16:37
Re: Calling %s in a textdraw? Help needed. - by ExoSanty - 27.11.2009, 16:51
Re: Calling %s in a textdraw? Help needed. - by Devine - 27.11.2009, 16:52
Re: Calling %s in a textdraw? Help needed. - by Andy_McKinley - 27.11.2009, 16:59
Re: Calling %s in a textdraw? Help needed. - by Remi-X - 27.11.2009, 17:13
Re: Calling %s in a textdraw? Help needed. - by Devine - 27.11.2009, 22:27
Re: Calling %s in a textdraw? Help needed. - by Remi-X - 27.11.2009, 22:38
Re: Calling %s in a textdraw? Help needed. - by Devine - 28.11.2009, 00:30

Forum Jump:


Users browsing this thread: 7 Guest(s)