SA-MP Forums Archive
Allow Spaces ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Allow Spaces ? (/showthread.php?tid=163284)



Allow Spaces ? - Ribber - 26.07.2010

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


Re: Allow Spaces ? - Ribber - 27.07.2010

anyone ?


Re: Allow Spaces ? - John_F - 27.07.2010

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.


Re: Allow Spaces ? - mastasquizy - 27.07.2010

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;
}



Re: Allow Spaces ? - Ribber - 28.07.2010

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".


Re: Allow Spaces ? - mastasquizy - 28.07.2010

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