
{
if(strcmp("/afk",cmdtext, true) == 0) {
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
TextDrawShowForAll(IsAFK);
TogglePlayerControllable(playerid,0);
return 1;
}
IsAFK = TextDrawCreate(260.000000,222.000000,"%s is now AFK!"); 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)
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
new str[48];//put this in your command
format(str,48,"%s is now AFK!",PlayerName(playerid);
TextDrawSetString(IsAFK,str);
TextDrawHideForAll(IsAFK);
TextDrawShowForAll(IsAFK);
SetTimer("HideTextTimer",5000,0);//optional
forward HideTextTimer();//optional
public HideTextTimer()
{
TextDrawHideForAll(IsAFK);
}

format(str,48,"%s is now AFK!",PlayerName(playerid);
format(str,48,"%s is now AFK!",PlayerName(playerid));
//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;
}
|
Originally Posted by Remi-X
Line 27: I never said something about a public called AFKTextdraw(), but you need to forward it as I did with HideAFK().
|
|
Originally Posted by Remi-X
Код:
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);
}
|