Allow Spaces ?
#1

Is there any custom possibility to allow spaces between the username ?
Reply
#2

anyone ?
Reply
#3

You can detect certain symbols in a player's name and replace then with a space on login.

Like, say a person has a name in the format firstname_lastname:
you can make a script that detects the "_" and replaces it with a " ".
The same can be said if a person has a "." in their name or something.
Reply
#4

Quote:
Originally Posted by John_F
Посмотреть сообщение
You can detect certain symbols in a player's name and replace then with a space on login.

Like, say a person has a name in the format firstname_lastname:
you can make a script that detects the "_" and replaces it with a " ".
The same can be said if a person has a "." in their name or something.
If your thinking about something like this:
pawn Код:
public OnPlayerConnect(playerid)
{
    if(strfind(PlayerName(playerid),"_")!=-1) AddSpace(playerid);
}
pawn Код:
/*stock*/ AddSpace(playerid)
{
    new that[25];
    if(strfind(PlayerName(playerid),"_")!=-1)
    {
        strpack(that,PlayerName(playerid));//to make things simpler
        new number=strfind(that,"_");//to make things simpler(again)
        strdel(that,number,number+1);
        strins(that," ",number);//<------------
                SetPlayerName(playerid,that);
    }
    return 1;
}
This WILL NOT work only because that space (" ") is an 'invalid character', which means, the players name WILL NOT CHANGE. So instead of changing the name of the player, you would have to change something else, like, how it would display on the screen when someone types a message.

Just do something like this under OnPlayerText(blah blah blah) and SendClientMessage(blah blah blah), only the str will say their name ([that] as above) with a space:
pawn Код:
stock AddSpace(playerid)//REMEMBER TO STOOCK THIS!
{
    new that[25];
    if(strfind(PlayerName(playerid),"_")!=-1)
    {
        strpack(that,PlayerName(playerid));//to make things simpler
        new number=strfind(that,"_");//to make things simpler(again)
        strdel(that,number,number+1);
        strins(that," ",number);
    }
    return that;//AND ALSO REMEMBER TO RETURN 'that'!!!
}
then later...
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(PlayerName(playerid),"_")!=-1)
    {
        new str;
        format(str,sizeof(str),"%s: %s",AddSpace(playerid),text);//***
        SendClientMessageToAll(whatever_color,str);
        return 0;//RETURN 0!! so they don't see the original text
    }
    return 1;
}
Reply
#5

Thanks for your trouble.
But is there a custom possibility to allow spaces when the player join the server already with space ?
Example his client name is: "Jason Love".
Reply
#6

Quote:
Originally Posted by Ribber
Посмотреть сообщение
Thanks for your trouble.
But is there a custom possibility to allow spaces when the player join the server already with space ?
Example his client name is: "Jason Love".
Sorry, SA-MP doesn't allow that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)