help with afk
#1

I made this afk system thing and I have a problem
When you do /afk, your name is set like this: [AFK]J_money
But when you do /back, ur name is still set like this
I have the code, can anyone fix the problem for me?

Код:
if(strcmp(cmdtext, "/afk", true) == 0)
		{
		new tmp[256];
		new name[256];
		new string[256];
		new sendername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		TogglePlayerControllable(playerid, false);
		format(string, sizeof(string), "%s is afk'd", name);
		SendClientMessageToAll(COLOR_BLUEGREEN, string);
		playerid = strval(tmp);
		if (IsPlayerConnected(playerid))
		{
		GetPlayerName(playerid, sendername, sizeof(sendername));
  		format(string, sizeof(string), "[AFK]%s" ,playerid,sendername, cmdtext[2]);
		SetPlayerName(playerid, "%s");
		}
		SendClientMessage(playerid, COLOR_BLUEGREEN, "If you want to return type /back");
		return 1;
		}

		if (strcmp(cmdtext, "/back", true) == 0)
		{
		new tmp[256];
    new name[256];
		new string[256];
		new sendername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		TogglePlayerControllable(playerid, true);
		format(string, sizeof(string), "%s has returned", name);
		SendClientMessageToAll(COLOR_BLUEGREEN, string);
		playerid = strval(tmp);
		if (IsPlayerConnected(playerid))
		{
		GetPlayerName(playerid, sendername, sizeof(sendername));
  		format(string, sizeof(string), "%s", name);
		SetPlayerName(playerid, name);
		}
		SendClientMessage(playerid, COLOR_BLUEGREEN, "Welcome Back");
		return 1;
		}
Reply
#2

Inside the /back command, where you have:

Код:
format(string, sizeof(string), "%s", name);
Change that single line to:
Код:
strmid(string, name, 5, strlen(name), strlen(string));
Change that 5 over there to specify from which character the name will be splitted from. If 5 isn't working as expected, try 4 or 6.
Reply
#3

It didn't work, I even changed the values
Reply
#4

Oh, sorry, appart from changing that, also change the line below:

Код:
SetPlayerName(playerid, name);
to:

Код:
SetPlayerName(playerid, string);
That should work.
Reply
#5

tommy check your messages
Reply
#6

ok poop
and sorry Zamaroht, still didn't work, btw thx 4 the help? any more ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)