[Help] GetPlayerName problems
#1

Hello everyone, and today I had a stroll through the SAMP forums and saw something that might be useful for my script.

Код:
stock NAMEGET(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
So, I got to work using it in these two roleplay commands.

Код:
CMD:me(playerid, params[])
{
    new textv2[128];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_NEWBIE, "SYNTAX: /me [action]");
	{
	format(textv2, sizeof(textv2), "* %s %s", NAMEGET(playerid), params);
    NearMessageSender(playerid, 6, textv2, COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1);
	}
	return 1;
}

CMD:do(playerid, params[])
{
    new textv2[128];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_NEWBIE, "SYNTAX: /do [action]");
	{
	format(textv2, sizeof(textv2), "* %s ((%s))", params, NAMEGET(playerid));
    NearMessageSender(playerid, 6, textv2, COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1);
	}
	return 1;
}
The stock for NearMessageSender is:

Код:
stock NearMessageSender(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	new Float:ix, Float:iy, Float:iz;
	new Float:cx, Float:cy, Float:cz;
	foreach(Player, i)
	{
	        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
	        {
				GetPlayerPos(i, ix, iy, iz);
				cx = (x - ix);
				cy = (y - iy);
				cz = (z - iz);
				if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
				{
				    SendClientMessage(i, col1, string);
				}
				else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
				{
				    SendClientMessage(i, col2, string);
				}
				else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
				{
				    SendClientMessage(i, col3, string);
				}
				else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
				{
				    SendClientMessage(i, col4, string);
				}
				else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
				{
				    SendClientMessage(i, col5, string);
				}
			}
	}
	return 1;
}
And when I type something in game, it comes out like such:



When it should come out like:



Can anyone help? Thanks. REP +
Reply
#2

pawn Код:
CMD:me(playerid, params[])
{
     if(isnull(params)) return SendClientMessage(playerid, COLOR_NEWBIE, "SYNTAX: /me [action]");
     new textv2[128];
     format(textv2, 128, "* %s %s", RPname(playerid), params);
     NearMessageSender(playerid, 6.0, textv2, COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1);
     return 1;
}
CMD:do(playerid, params[])
{
     if(isnull(params)) return SendClientMessage(playerid, COLOR_NEWBIE, "SYNTAX: /do [action]");
     new textv2[128];
     format(textv2, 128, "* %s (( %s ))", params, RPname(playerid));
     NearMessageSender(playerid, 6.0, textv2, COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1,COLOR_FADE1);
     return 1;
}
stock RPname(playerid)
{
    new Name[MAX_PLAYER_NAME], i = -1;
    GetPlayerName( playerid, Name, MAX_PLAYER_NAME );
    while( Name[ ++i ] )
    if(Name[i] == '_')
    Name[i] = ' ';
    return Name;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)