SetPlayerName Problem
#1

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
Reply
#2

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
Reply
#3

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...
Reply
#4

Why won't you try it -.-,really,and + you forgot to define fString in your command
Reply
#5

pawn Код:
new CName[MAX_PLAYER_NAME], string[24];
GetPlayerName(playerid, CName, sizeof(CName));
format(string, sizeof(string), "%s<AFK>", CName);
SetPlayerName(playerid, string);
Reply
#6

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.
Reply
#7

And what is your name in-game before you do /afk
Reply
#8

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;
}
Reply
#9

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)
Reply
#10

iPleo you ar the one who did that fs with cellphone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)