SA-MP Forums Archive
How to make RPG names Name_Surname - 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)
+--- Thread: How to make RPG names Name_Surname (/showthread.php?tid=308955)



How to make RPG names Name_Surname - Artie_Scorpion - 05.01.2012

Hi how to make players only allow to use Name_Surname... ?


Re: How to make RPG names Name_Surname - Kyosaur - 05.01.2012

Seriously? I cant even fathom how many times this has been answered! Please use the search feature, there are tons of gamemodes that use it and tons of different versions in the useful function thread alone.


Re: How to make RPG names Name_Surname - Artie_Scorpion - 05.01.2012

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Seriously? I cant even fathom how many times this has been answered! Please use the search feature, there are tons of gamemodes that use it and tons of different versions in the useful function thread alone.
shut up


Re: How to make RPG names Name_Surname - [NOR]John - 05.01.2012

Quote:
Originally Posted by Artie_Scorpion
Посмотреть сообщение
shut up
wow...


Re: How to make RPG names Name_Surname - Artie_Scorpion - 05.01.2012

Quote:
Originally Posted by [NOR]John
Посмотреть сообщение
wow...
you better too


Re: How to make RPG names Name_Surname - [NOR]John - 05.01.2012

Quote:
Originally Posted by Artie_Scorpion
Посмотреть сообщение
you better too
and if i dont?


Re: How to make RPG names Name_Surname - Mrki_Drakula - 05.01.2012

Add this somewhere under OnPlayerConnect:
PHP код:
if(!IsRolePlayName(playerid))
{
    
SendClientMessage(playerid,0xFF0000FF"That's not RolePlay Name! Example: Firstname_Lastname");
    
Kick(playerid);

Add the bottom of your script:
PHP код:
stock IsRolePlayName(playeridbool:alphaonly true)
{
    new 
trpn[MAX_PLAYER_NAME];
    
    if(
GetPlayerName(playerid,trpn,sizeof(trpn)))
    {
        new 
strd strfind(trpn"_"false);
        if(
strfind(trpn,"_",false,strd+1) == -1)
        {
            if(
strd 0)
            {
                if(
trpn[strd-1] && trpn[strd+1])
                {
                    if(
alphaonly)
                    {
                        for(new 
0strlen(trpn); la++)
                        {
                            switch(
trpn[a])
                            {
                                case 
'0' .. '9': return 0;
                                case 
'a' .. 'z': continue;
                                case 
'A' .. 'Z': continue;
                                case 
'_': continue; // easier than specifying every invalid char
                                
default: return 0;
                            }
                        }
                    }
                    return 
1;
                }
            }
        }
    }
    return 
0;

Damn, Am i the only one who's actually helping around here?!


Re: How to make RPG names Name_Surname - Artie_Scorpion - 05.01.2012

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
Add this somewhere under OnPlayerConnect:
PHP код:
if(!IsRolePlayName(playerid))
{
    
SendClientMessage(playerid,0xFF0000FF"That's not RolePlay Name! Example: Firstname_Lastname");
    
Kick(playerid);

Add the bottom of your script:
PHP код:
stock IsRolePlayName(playeridbool:alphaonly true)
{
    new 
trpn[MAX_PLAYER_NAME];
    
    if(
GetPlayerName(playerid,trpn,sizeof(trpn)))
    {
        new 
strd strfind(trpn"_"false);
        if(
strfind(trpn,"_",false,strd+1) == -1)
        {
            if(
strd 0)
            {
                if(
trpn[strd-1] && trpn[strd+1])
                {
                    if(
alphaonly)
                    {
                        for(new 
0strlen(trpn); la++)
                        {
                            switch(
trpn[a])
                            {
                                case 
'0' .. '9': return 0;
                                case 
'a' .. 'z': continue;
                                case 
'A' .. 'Z': continue;
                                case 
'_': continue; // easier than specifying every invalid char
                                
default: return 0;
                            }
                        }
                    }
                    return 
1;
                }
            }
        }
    }
    return 
0;

Damn, Am i the only one who's actually helping around here?!
You are my live saver.


Re: How to make RPG names Name_Surname - BleverCastard - 05.01.2012

@Artie, Kyosaur was doing what anyother person would say, I would say it. You need to have a bit of Respect.