Afk-System have terrible bugs
#1

Hello,

Today I have a little problem with my afk system. It seems I have change something and now it wonґt work as it does like 2 weeks before.
It was all fine. I have a /afk and a /back command. It works perfectly. But since I delete something in the script it wonґt work.
So my problems are:

- I type /afk and I go normaly afk. IT puts me a Tag behind my Name Flashy[AFK]. But when I type /afk again it put me again a tag and the message appears that I go afk. Itґs useless cause I am already afk.
- I type /back and it says I am not afk? Before I type /afk and it was ok. I ytpe /back and it donґt work.

How to fix that problems? The script of ~70 lines is in the pastebin file. I will give you credits in my server wehn you fix that.

Thanks Flashy

http://pastebin.com/pQq90yQP
Reply
#2

This might work :

Код:
	new isafk[MAX_PLAYERS];
	new afktag[MAX_PLAYERS];


	if (strcmp("/afk", cmdtext, true) == 0)
	{
		if(isafk[playerid]==1) return SendClientMessage(playerid, COLOR_BRIGHTRED,"You are already AFK!");
		
		isafk[playerid] = 1;
		TogglePlayerControllable(playerid,false);
		SetCameraBehindPlayer(playerid);
		new string[256];
		new name[128];
		GetPlayerName(playerid,name,128);
		format(string, sizeof(string), "%s is now AFK",name);
		new setname[16];
		format(setname, sizeof(setname), "%s[AFK]",name);
		if(!strlen(name[11]))
		{
			afktag[playerid] = 1;
			SetPlayerName(playerid,setname);
		}
		SendClientMessageToAll(COLOR_YELLOW, string);
		SendClientMessage(playerid, COLOR_YELLOW, "Type /BACK when you are back!");
			
		return 1; //return value
	}

	if (strcmp("/back", cmdtext, true) == 0)
	{
		if(isafk[playerid]==0) return SendClientMessage(playerid, COLOR_BRIGHTRED,"You are not AFK!");
		
		isafk[playerid] = 0;
		TogglePlayerControllable(playerid,true);
		SetCameraBehindPlayer(playerid);
		new string[128];
		new pname[32];
		GetPlayerName(playerid,pname,32);
		strdel(pname, strlen(pname)-5, strlen(pname));
		if(afktag[playerid] == 1)
		{
			afktag[playerid] = 0;
			SetPlayerName(playerid,pname);
		}
		new name2[16];
		GetPlayerName(playerid,name2,16);
		format(string, sizeof(string), "%s is now BACK",name2);
		SendClientMessageToAll(COLOR_YELLOW, string);
		SendClientMessage(playerid, COLOR_YELLOW, "Type /AFK to go AFK again!");
		
		return 1; //return value
	}
Reply
#3

Thanks for the asnwer but nothing changed. I get the some bugs.



Need help ;(
Reply
#4

I modified my post and I hope it will work now
Reply
#5

Nope Same bugs some problems like the beginning. The problem is that when I type in /afk it didnґt save it as afk. I type again /afk and it gets again in de Afk position. (I get frozen).

And when I wanna get back I type /back but it shows me the message that I am not afk?!

DJDhan try to fix it or someone other
Reply
#6

Try this.
I added 'else' after "if(isafk[playerid]==1) return SendClientMessage(playerid, COLOR_BRIGHTRED,"You are already AFK!");"

pawn Код:
new isafk[MAX_PLAYERS];
    new afktag[MAX_PLAYERS];


    if (strcmp("/afk", cmdtext, true) == 0)
    {
        if(isafk[playerid]==1) return SendClientMessage(playerid, COLOR_BRIGHTRED,"You are already AFK!");
        else
        {
            isafk[playerid] = 1;
            TogglePlayerControllable(playerid,false);
            SetCameraBehindPlayer(playerid);
            new string[256];
            new name[128];
            GetPlayerName(playerid,name,128);
            format(string, sizeof(string), "%s is now AFK",name);
            new setname[16];
            format(setname, sizeof(setname), "%s[AFK]",name);
            if(!strlen(name[11]))
            {
                afktag[playerid] = 1;
                SetPlayerName(playerid,setname);
            }
            SendClientMessageToAll(COLOR_YELLOW, string);
            SendClientMessage(playerid, COLOR_YELLOW, "Type /BACK when you are back!");
        }
        return 1; //return value
    }

    if (strcmp("/back", cmdtext, true) == 0)
    {
        if(isafk[playerid]==0) return SendClientMessage(playerid, COLOR_BRIGHTRED,"You are not AFK!");
        else
        {
            isafk[playerid] = 0;
            TogglePlayerControllable(playerid,true);
            SetCameraBehindPlayer(playerid);
            new string[128];
            new pname[32];
            GetPlayerName(playerid,pname,32);
            strdel(pname, strlen(pname)-5, strlen(pname));
            if(afktag[playerid] == 1)
            {
                afktag[playerid] = 0;
                SetPlayerName(playerid,pname);
            }
            new name2[16];
            GetPlayerName(playerid,name2,16);
            format(string, sizeof(string), "%s is now BACK",name2);
            SendClientMessageToAll(COLOR_YELLOW, string);
            SendClientMessage(playerid, COLOR_YELLOW, "Type /AFK to go AFK again!");
        }
        return 1; //return value
    }
Reply
#7

Thanks for your answer but this donґt help, too.
I get the same bugs and nothing change with the problems.

Like I said the user who resolve that get credits on my server.
So if anyone know how to fix it, tell me
Reply
#8

Top
Код:
new isafk[MAX_PLAYERS];
Код:
	if(!strcmp("/afk", cmdtext, true, 4))
	{
		if(!isafk[playerid]) // if the array called "isafk" is 0 for the player, then
		{
			isafk[playerid] = 1;
			TogglePlayerControllable(playerid,false);
			SetCameraBehindPlayer(playerid);
			new string[36],name[24],len;
			GetPlayerName(playerid,name,24);
			len=strlen(name);
			format(string, sizeof(string), "%s is now AFK",name);
			SendClientMessageToAll(COLOR_YELLOW, string);
			strins(name,"[AFK]",len);
			SetPlayerName(playerid,name);
			SendClientMessage(playerid, COLOR_YELLOW, "Type /BACK when you are back!");
		}else SendClientMessage(playerid, COLOR_BRIGHTRED,"You are already AFK!");
		return 1; //return value
	}

	if(!strcmp("/back", cmdtext, true, 5))
	{
		if(isafk[playerid] == 1) // if the array called "isafk" is 1 for the player, then
		{
			isafk[playerid] = 0;
			TogglePlayerControllable(playerid,true);
			SetCameraBehindPlayer(playerid);
			new string[37],name[24],len;
			GetPlayerName(playerid,name,24);
			len=strlen(name);
			strdel(name, len-5, len);
			SetPlayerName(playerid,name);
			format(string, sizeof(string), "%s is now BACK",name);
			SendClientMessageToAll(COLOR_YELLOW, string);
			SendClientMessage(playerid, COLOR_YELLOW, "Type /AFK to go AFK again!");
		}else SendClientMessage(playerid, COLOR_BRIGHTRED,"You are not AFK!");
		return 1; //return value
	}
	return 0;
}
:>
Reply
#9

Thanks you too but I donґt know what you have changed xD I copy&paste it but itґs still the same errors.
WTF? Why it wonґt work? 3 sugestions and noone is right?

Neeed help
Reply
#10

Quote:
Originally Posted by Flashy
WTF? Why it wonґt work? 3 sugestions and noone is right?
Use brain, i dont know whats wrong in this ;x maybe learn more pawn?, works genius.
pawn Код:
#include <a_samp>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_BRIGHTRED 0xFF99AADD
new isafk[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    isafk[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
    if(isafk[playerid] == 1) // if the array called "isafk" is 1 for the player, then
    {
        new name[24],len;
        GetPlayerName(playerid,name,24);
        len=strlen(name);
        strdel(name, len-5, len);
        SetPlayerName(playerid,name);
    }
    isafk[playerid] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/afk", cmdtext, true, 4))
    {
        if(!isafk[playerid]) // if the array called "isafk" is 0 for the player, then
        {
            isafk[playerid] = 1;
            TogglePlayerControllable(playerid,false);
            SetCameraBehindPlayer(playerid);
            new string[36],name[24],len;
            GetPlayerName(playerid,name,24);
            len=strlen(name);
            format(string, sizeof(string), "%s is now AFK",name);
            SendClientMessageToAll(COLOR_YELLOW, string);
            strins(name,"[AFK]",len);
            SetPlayerName(playerid,name);
            SendClientMessage(playerid, COLOR_YELLOW, "Type /BACK when you are back!");
        }else SendClientMessage(playerid, COLOR_BRIGHTRED,"You are already AFK!");
        return 1; //return value
    }

    if(!strcmp("/back", cmdtext, true, 5))
    {
        if(isafk[playerid] == 1) // if the array called "isafk" is 1 for the player, then
        {
            isafk[playerid] = 0;
            TogglePlayerControllable(playerid,true);
            SetCameraBehindPlayer(playerid);
            new string[37],name[24],len;
            GetPlayerName(playerid,name,24);
            len=strlen(name);
            strdel(name, len-5, len);
            SetPlayerName(playerid,name);
            format(string, sizeof(string), "%s is now BACK",name);
            SendClientMessageToAll(COLOR_YELLOW, string);
            SendClientMessage(playerid, COLOR_YELLOW, "Type /AFK to go AFK again!");
        }else SendClientMessage(playerid, COLOR_BRIGHTRED,"You are not AFK!");
        return 1; //return value
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)