help with afk - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help with afk (
/showthread.php?tid=111943)
help with afk -
tommy5933 - 04.12.2009
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;
}
Re: help with afk -
Zamaroht - 04.12.2009
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.
Re: help with afk -
tommy5933 - 04.12.2009
It didn't work, I even changed the values
Re: help with afk -
Zamaroht - 04.12.2009
Oh, sorry, appart from changing that, also change the line below:
Код:
SetPlayerName(playerid, name);
to:
Код:
SetPlayerName(playerid, string);
That should work.
Re: help with afk -
p00p - 04.12.2009
tommy check your messages
Re: help with afk -
tommy5933 - 04.12.2009
ok poop
and sorry Zamaroht, still didn't work, btw thx 4 the help? any more ideas?