[HELP] AFK Puts [AFK] In-Front Of Name (eg. /afk = [AFK]Name) ?
#1

Ok i have a working /afk command. I want to know how to make the /afk command put a "[AFK]" tag in there name when in AFK so players know when people are AFK and when they /back there name is back to normal?

Any help?

pawn Код:
CMD:afk(playerid, params[])
{
        new string[128];
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == false)
        {
            if(afktimer[playerid]) return SendClientMessage(playerid,RED,"Please Wait Before Being AFK Again!");
            afktimer[playerid] =30;
            isafk[playerid] = true;
            SetPlayerHealth(playerid, 9999);
            GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            format(string, sizeof(string), "%s Is Now AFK",name);
            printf(string);
            SendClientMessage(playerid, YELLOW, "Type /back To Stop Being AFK.");
            SendClientMessageToAll(RED, string);
            TogglePlayerControllable(playerid,0);
        }
        else
        {
            SendClientMessage(playerid, RED, "You Are Already AFK!");
        }
    return true;
}

CMD:back(playerid, params[])
{
        new string[128];
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == true)
        {
            isafk[playerid] = false;
            GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            format(string, sizeof(string), "%s Is No Longer AFK",name);
            SendClientMessageToAll(YELLOW, string);
            printf(string);
            TogglePlayerControllable(playerid,1);
        }
        else
        {
        SendClientMessage(playerid, RED, "You Are Not AFK!");
        }
    return true;
}
Thanks In Advanced!
Reply
#2

pawn Код:
CMD:afk(playerid, params[])
{
        new string[128];
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == false)
        {
            if(afktimer[playerid]) return SendClientMessage(playerid,RED,"Please Wait Before Being AFK Again!");
            afktimer[playerid] =30;
            isafk[playerid] = true;
            SetPlayerHealth(playerid, 9999);
            GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            format(string, sizeof(string), "%s Is Now AFK",name);
            new NewName[24];//
            format(NewName,24,"[AFK]%s",name);//
            SetPlayerName(playerid,NewName);
            printf(string);
            SendClientMessage(playerid, YELLOW, "Type /back To Stop Being AFK.");
            SendClientMessageToAll(RED, string);
            TogglePlayerControllable(playerid,0);
        }
        else
        {
            SendClientMessage(playerid, RED, "You Are Already AFK!");
        }
    return true;
}

CMD:back(playerid, params[])
{
        new string[128];
        new name[MAX_PLAYER_NAME];
        if(isafk[playerid] == true)
        {
            isafk[playerid] = false;
            GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            strdel(name,0,5);//
            SetPlayerName(playeri,name);//
            format(string, sizeof(string), "%s Is No Longer AFK",name);
           
            SendClientMessageToAll(YELLOW, string);
            printf(string);
            TogglePlayerControllable(playerid,1);
        }
        else
        {
        SendClientMessage(playerid, RED, "You Are Not AFK!");
        }
    return true;
}
I hope it will work
Reply
#3

I suggest you NOT to use this.
I had it on my server over one year, and just now I've found out that this sucks.

Take a very long name (Maximum) and put the [AFK] infront. => Means the name gets 5 chars longer. By doing /back again, the last letters of the name will miss.

I have removed the Tag at my server. Just a info for you.
Reply
#4

@Gavibro

Thanks!~ i GTG now ill test in 20mins


@ Jeffry

Hmm interesting.Thanks for sharing this with me.
Reply
#5

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
I suggest you NOT to use this.
I had it on my server over one year, and just now I've found out that this sucks.

Take a very long name (Maximum) and put the [AFK] infront. => Means the name gets 5 chars longer. By doing /back again, the last letters of the name will miss.

I have removed the Tag at my server. Just a info for you.
Thought you would of know that since the name can only be like 20/24/25 characters i can't remeber lol but yea...seems like a good idea until the long run.
Reply
#6

You could just set the AFK player's name to AFKPLAYER(INSERT PLAYER ID HERE ), store their name and return it back to them when they use /back
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)