SetPlayerName Problem -
DBan - 13.04.2012
Hello SA:MP!
I am having some trouble with SetPlayerName. I am trying to make an afk command that also sets the players name to "playername<AFK>"
However, it doesn't set my name. Any idea why
Here's the code:
pawn Код:
CMD:afk(playerid, params[])
{
new originalname[24], string[29]; //Created the variables
GetPlayerName(playerid, originalname, sizeof(originalname)); //Stored the player's name into the originalname variable
FM(fString, sizeof(fString), "%s is now <AFK>", GetName(playerid)); //Formatted fString
SendClientMessageToAll(cyellow, fString); //Sent fString
FM(string, sizeof(string), "%s<AFK>", originalname); //Formatted originalname to add <AFK>
SetPlayerName(playerid, string); //Set the player's name
return 1;
}
Thanks for you help.
~ DBan
Re: SetPlayerName Problem -
Cjgogo - 13.04.2012
pawn Код:
COMMAND:afk(playerid,params[])
{
new oName[24],aName[24],message[128];//original and afk name+message for players
GetPlayerName(playerid,oName,sizeof(oName));
format(message,sizeof(message),"%s(%d) is now <AFK>",oName,playerid);
SendClientMessageToAll(cyellow,message);
format(aName,sizeof(aName),"%s<AFK>",oName);
SetPlayerName(playerid,aName);
return 1;
}
Replace the whole command with what I gave you
Re: SetPlayerName Problem -
DBan - 13.04.2012
Quote:
Originally Posted by Cjgogo
pawn Код:
COMMAND:afk(playerid,params[]) { new oName[24],aName[24],message[128];//original and afk name+message for players GetPlayerName(playerid,oName,sizeof(oName)); format(message,sizeof(message),"%s(%d) is now <AFK>",oName,playerid); SendClientMessageToAll(cyellow,message); format(aName,sizeof(aName),"%s<AFK>",oName); SetPlayerName(playerid,aName); return 1; }
Replace the whole command with what I gave you
|
That's basically the same thing, just without using
my definitions and global variables...
Re: SetPlayerName Problem -
Cjgogo - 13.04.2012
Why won't you try it -.-,really,and + you forgot to define fString in your command
Re: SetPlayerName Problem -
RollTi - 13.04.2012
pawn Код:
new CName[MAX_PLAYER_NAME], string[24];
GetPlayerName(playerid, CName, sizeof(CName));
format(string, sizeof(string), "%s<AFK>", CName);
SetPlayerName(playerid, string);
Re: SetPlayerName Problem -
DBan - 13.04.2012
Quote:
Originally Posted by Cjgogo
Why won't you try it -.-,really,and + you forgot to define fString in your command
|
Read my last post...
BTW I did try it and it's giving me the same results. I didn't "forget" to define fString, I use it as a global variable. I didn't say that the script didn't compile...
Quote:
Originally Posted by RollTi
pawn Код:
new CName[MAX_PLAYER_NAME], string[24]; GetPlayerName(playerid, CName, sizeof(CName)); format(string, sizeof(string), "%s<AFK>", CName); SetPlayerName(playerid, string);
|
It's the same thing.
Re: SetPlayerName Problem -
[MG]Dimi - 13.04.2012
And what is your name in-game before you do /afk
Re: SetPlayerName Problem -
iPLEOMAX - 13.04.2012
I wonder if Player name accepts '<' or '>' as a character..
pawn Код:
CMD:afk(playerid, params[])
{
new tempstr[MAX_PLAYER_NAME + 6], message[42];
GetPlayerName(playerid, tempstr, sizeof tempstr);
format(message, sizeof message, "%s is now <AFK>", tempstr);
SendClientMessageToAll(cyellow, message);
format(tempstr, sizeof tempstr, "%s[AFK]", tempstr);
SetPlayerName(playerid, tempstr);
return 1;
}
Re: SetPlayerName Problem -
DBan - 13.04.2012
Quote:
Originally Posted by iPLEOMAX
I wonder if Player name accepts '<' or '>' as a character..
pawn Код:
CMD:afk(playerid, params[]) { new tempstr[MAX_PLAYER_NAME + 6], message[42]; GetPlayerName(playerid, tempstr, sizeof tempstr); format(message, sizeof message, "%s is now <AFK>", tempstr); SendClientMessageToAll(cyellow, message);
format(tempstr, sizeof tempstr, "%s[AFK]", tempstr); SetPlayerName(playerid, tempstr); return 1; }
|
I've seen this done on another server so i'm pretty sure it does

I also tested it and unfortunately, it still comes out with the same result (no change in the player's name)
Re: SetPlayerName Problem -
Angel.Why - 14.04.2012
iPleo you ar the one who did that fs with cellphone?