AFK And SetName Command - 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: AFK And SetName Command (
/showthread.php?tid=86604)
AFK And SetName Command -
Alec24 - 15.07.2009
The code works fine but it wont change the players name to '[AFK] <name>' it just says there away and leaves the name as it was:
pawn Код:
if(strcmp("/afk",cmdtext,true)==0)
{
if(!IsPlayerConnected(playerid)) return SysMsg(playerid,"Please wait until you are fully connected!");
if(IsAFK[playerid] == 0)
{
format(string,sizeof(string),"[AFK] %s",Name(playerid));
SetPlayerName(playerid,string);
IsAFK[playerid] = 1;
format(string,sizeof(string),"%s is now Away From Keyboard (AFK)",Name(playerid));
SendClientMessageToAll(COLOUR_GREEN,string);
printf("[Cmd] %s Is Now AFK",Name(playerid));
}else{
new nName[256],nFile[128];
nFile = GetPlayersFile(playerid);
nName = dini_Get(File,"Account Name");
SetPlayerName(playerid,nName);
format(string,sizeof(string),"%s is no longer Away From Keyboard (AFK)",Name(playerid));
SendClientMessageToAll(COLOUR_GREEN,string);
IsAFK[playerid] = 0;
printf("[Cmd] %s Is No Longer AFK",Name(playerid));
}
return 1;
}
Re: AFK And SetName Command -
yom - 15.07.2009
Try with no space.
Re: AFK And SetName Command -
Jefff - 15.07.2009
Or
Re: AFK And SetName Command -
Alec24 - 15.07.2009
Ok now it will change the name to [AFK] but when i try to /afk again to remove the [AFK] it says that samp-server.exe has crashed?
Re: AFK And SetName Command -
Alec24 - 15.07.2009
Ok no problem its fixed, i just added 'UserName[MAX_PLAYERS][24]' instead of using dini to get the name:
OnPlayerConnect: UserName[playerid] = Name(playerid);
pawn Код:
if(strcmp("/afk",cmdtext,true)==0)
{
if(!IsPlayerConnected(playerid)) return SysMsg(playerid,"Please wait until you are fully connected!");
//SysMsg(playerid,"Currently Disabled.");
if(IsAFK[playerid] == 0)
{
format(string,sizeof(string),"%s is now Away From Keyboard (AFK)",Name(playerid));
SendClientMessageToAll(COLOUR_GREEN,string);
format(string,sizeof(string),"[AFK]%s",Name(playerid));
SetPlayerName(playerid,string);
IsAFK[playerid] = 1;
printf("[Cmd] %s Is Now AFK",Name(playerid));
}else{
SetPlayerName(playerid,UserName[playerid]);
format(string,sizeof(string),"%s is no longer Away From Keyboard (AFK)",Name(playerid));
SendClientMessageToAll(COLOUR_GREEN,string);
IsAFK[playerid] = 0;
printf("[Cmd] %s Is No Longer AFK",Name(playerid));
}
return 1;
}
Re: AFK And SetName Command -
yom - 15.07.2009
Waste of memory, just delete the first 5 characters of the name.