How to remove "_" from names in RP servers?
#1

Like while doing an Announcement from an Admin...

Code:
		new sendername[MAX_PLAYER_NAME];
		new msg[256];
		if (sscanf(params, "s", msg)) SendClientMessage(playerid, COLOR_RED, "USAGE: /ann [text]");
		else {
		    GetPlayerName(playerid, sendername, sizeof(sendername));
		    format(msg, sizeof(msg), "Announcement from %s: %s", sendername, msg);
		    SendClientMessageToAll(COLOR_LOCALMSG, msg);
		    }
		    }
	return 1;
}
How to remove "_" from message? Thanks!
Reply
#2

Use this:

pawn Code:
stock UnderscoreToSpaceName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
    }
    else
    {
        Name = "Disconnected/Nothing";
    }
    for(new name = 0; name < MAX_PLAYER_NAME; name++) if(Name[name] == '_') Name[name] = ' ';
    return Name;
}
So the command will look like this:


pawn Code:
new msg[256];
        if (sscanf(params, "s", msg)) SendClientMessage(playerid, COLOR_RED, "USAGE: /ann [text]");
        else {
            format(msg, sizeof(msg), "Announcement from %s: %s", UnderscoreToSpaceName(playerid), msg);
            SendClientMessageToAll(COLOR_LOCALMSG, msg);
            }
            }
    return 1;
}
Reply
#3

Thanks!!!
Reply
#4

Quote:
Originally Posted by Injector
View Post
Thanks!!!
No problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)