SA-MP Forums Archive
Non-RP name [+Rep^for Help] - 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: Non-RP name [+Rep^for Help] (/showthread.php?tid=514803)



Non-RP name [+Rep^for Help] - KingPersona - 23.05.2014

Hello

i want help i want make is can all name connect in Server , example :alex1 [Mp]alion , all name accept

when he connect player example this name : Krips , he say : Your name must be in the Firstname_Lastname format.

this my code in my GM , and i want do can all name accept connect , what i do ?

On PlayerConnect
pawn Код:
public OnPlayerConnect(playerid)
{
    // ONPLAYERCONNECT
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    if(strfind(playername, "_", true) != -1)
    {
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}SARP: {FFFFFF}Your name needs to be Role-Play! (For example: John_Smith) With NO numbers!");
        return Kick(playerid);
    }
    if(strfind(playername, "0", true) != -1 || strfind(playername, "1", true) != -1 || strfind(playername, "2", true) != -1 || strfind(playername, "3", true) != -1 || strfind(playername, "4", true) != -1 || strfind(playername, "5", true) != -1
    || strfind(playername, "6", true) != -1 || strfind(playername, "7", true) != -1 || strfind(playername, "8", true) != -1 || strfind(playername, "9", true) != -1)
    {
        SendClientMessage(playerid, COLOR_WHITE, "{DC0C0C}SARP: {FFFFFF}Your name needs to be Role-Play! (For example: John_Smith) With NO numbers!");
        return Kick(playerid);
    }
    PlayerSFC_Loaded[playerid] = 0;
    PlayerSFC[playerid] = 0;
    PlayerDead[playerid] = 0;
    PlayerDeadInt[playerid] = 0;
    PlayerDeadWorld[playerid] = 0;
    LoadedPatient[playerid] = INVALID_PLAYER_ID;
    Dim2D_Remove(PlayerReport, playerid);
    CheatTimer[playerid] = 5;
    for (new i = 0; i < 13; i ++)
    {
        PlayerWeapons[playerid][i] = 0;
        PlayerAmmo[playerid][i] = 0;
    }
    WarStats1[playerid] = 0;
    WarStats2[playerid] = 0;
    TogLC[playerid] = 1;
    TogAC[playerid] = 1;
    EnteredHouse[playerid] = 0;
    Hacked[playerid] = 0;
    PlayerInfo[playerid][pGPS] = 0;
    strmid(PlayerInfo[playerid][pSText], "NoText", 0, 255, 255);
    RentHouse[playerid] = 0;
    JobStep[playerid] = 0;
    PlayerInfo[playerid][pSQLID] = 0;
    AdTimer[playerid] = 0;
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    if (RegistrationStep[playerid] == 0 && gPlayerLogged[playerid] != 1)
    {
        if (gPlayerAccount[playerid] != 0)
        {
            SetPlayerTime(playerid, 24, 0);
            SendClientMessage(playerid, COLOR_YELLOW2, "{DC0C0C}Info: {FFFFFF}Welcome to San Andreas Realplay.");
            SetPlayerCameraPos(playerid, 1500.7156,-1778.1880,80.3080);
            SetPlayerCameraLookAt(playerid, 1500.7156,-1778.1880,80.3080);
            gPlayerAccount[playerid] = 1;
            new loginname[64];
            GetPlayerName(playerid,loginname,sizeof(loginname));
            ShowPlayerDialog(playerid,12346,DIALOG_STYLE_PASSWORD,"{FFFFFF}Login","{FFFFFF}Type {ee5555}your account's password {FFFFFF}below:","Login","Exit");
        }
        else
        {
            if (strfind(PlayerName(playerid), "_") == -1)
            {
                SendClientMessage(playerid, COLOR_GREY, "Your name must be in the Firstname_Lastname format.");
                return 1;
            }
            gPlayerAccount[playerid] = 0;
            new regname[64];
            GetPlayerName(playerid,regname,sizeof(regname));
            ShowPlayerDialog(playerid,12345,DIALOG_STYLE_PASSWORD,"{FFFFFF}Register","{FFFFFF}Type {ee5555}your account's password {FFFFFF}below:","Register","Exit");
        }
        SetPlayerFacingAngle(playerid, 3.41);
        SetPlayerTime(playerid, 24, 0);
        SetPlayerCameraPos(playerid, 1500.7156,-1778.1880,80.3080);
        SetPlayerCameraLookAt(playerid, 1500.7156,-1778.1880,80.3080);
        SetPlayerPos(playerid, 1437.6957,-2266.6355,13.5469);
        //PlayerPlaySound(playerid, 1187, 0.0, 0.0, 0.0);
        PlayerInfo[playerid][pModel] = Peds[classid][0];
    }
    return 1;
}



Re : Non-RP name [+Rep^for Help] - S4t3K - 23.05.2014

Delete this from your code

PHP код:
            if (strfind(PlayerName(playerid), "_") == -1)
            {
                
SendClientMessage(playeridCOLOR_GREY"Your name must be in the Firstname_Lastname format.");
                return 
1;
            } 
Which will give you

PHP код:

public OnPlayerRequestClass(playeridclassid)
{
    if (
RegistrationStep[playerid] == && gPlayerLogged[playerid] != 1)
    {
        if (
gPlayerAccount[playerid] != 0)
        {
            
SetPlayerTime(playerid240);
            
SendClientMessage(playeridCOLOR_YELLOW2"{DC0C0C}Info: {FFFFFF}Welcome to San Andreas Realplay.");
            
SetPlayerCameraPos(playerid1500.7156,-1778.1880,80.3080);
            
SetPlayerCameraLookAt(playerid1500.7156,-1778.1880,80.3080);
            
gPlayerAccount[playerid] = 1;
            new 
loginname[64];
            
GetPlayerName(playerid,loginname,sizeof(loginname));
            
ShowPlayerDialog(playerid,12346,DIALOG_STYLE_PASSWORD,"{FFFFFF}Login","{FFFFFF}Type {ee5555}your account's password {FFFFFF}below:","Login","Exit");
        }
        else
        {

            
gPlayerAccount[playerid] = 0;
            new 
regname[64];
            
GetPlayerName(playerid,regname,sizeof(regname));
            
ShowPlayerDialog(playerid,12345,DIALOG_STYLE_PASSWORD,"{FFFFFF}Register","{FFFFFF}Type {ee5555}your account's password {FFFFFF}below:","Register","Exit");
        }
        
SetPlayerFacingAngle(playerid3.41);
        
SetPlayerTime(playerid240);
        
SetPlayerCameraPos(playerid1500.7156,-1778.1880,80.3080);
        
SetPlayerCameraLookAt(playerid1500.7156,-1778.1880,80.3080);
        
SetPlayerPos(playerid1437.6957,-2266.6355,13.5469);
        
//PlayerPlaySound(playerid, 1187, 0.0, 0.0, 0.0);
        
PlayerInfo[playerid][pModel] = Peds[classid][0];
    }
    return 
1;

Btw, using strfind just to find a char is memory wasting. Use a for loop instead.


Re: Re : Non-RP name [+Rep^for Help] - KingPersona - 23.05.2014

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
Delete this from your code

PHP код:
            if (strfind(PlayerName(playerid), "_") == -1)
            {
                
SendClientMessage(playeridCOLOR_GREY"Your name must be in the Firstname_Lastname format.");
                return 
1;
            } 
Which will give you

PHP код:

public OnPlayerRequestClass(playeridclassid)
{
    if (
RegistrationStep[playerid] == && gPlayerLogged[playerid] != 1)
    {
        if (
gPlayerAccount[playerid] != 0)
        {
            
SetPlayerTime(playerid240);
            
SendClientMessage(playeridCOLOR_YELLOW2"{DC0C0C}Info: {FFFFFF}Welcome to San Andreas Realplay.");
            
SetPlayerCameraPos(playerid1500.7156,-1778.1880,80.3080);
            
SetPlayerCameraLookAt(playerid1500.7156,-1778.1880,80.3080);
            
gPlayerAccount[playerid] = 1;
            new 
loginname[64];
            
GetPlayerName(playerid,loginname,sizeof(loginname));
            
ShowPlayerDialog(playerid,12346,DIALOG_STYLE_PASSWORD,"{FFFFFF}Login","{FFFFFF}Type {ee5555}your account's password {FFFFFF}below:","Login","Exit");
        }
        else
        {
            
gPlayerAccount[playerid] = 0;
            new 
regname[64];
            
GetPlayerName(playerid,regname,sizeof(regname));
            
ShowPlayerDialog(playerid,12345,DIALOG_STYLE_PASSWORD,"{FFFFFF}Register","{FFFFFF}Type {ee5555}your account's password {FFFFFF}below:","Register","Exit");
        }
        
SetPlayerFacingAngle(playerid3.41);
        
SetPlayerTime(playerid240);
        
SetPlayerCameraPos(playerid1500.7156,-1778.1880,80.3080);
        
SetPlayerCameraLookAt(playerid1500.7156,-1778.1880,80.3080);
        
SetPlayerPos(playerid1437.6957,-2266.6355,13.5469);
        
//PlayerPlaySound(playerid, 1187, 0.0, 0.0, 0.0);
        
PlayerInfo[playerid][pModel] = Peds[classid][0];
    }
    return 
1;

Btw, using strfind just to find a char is memory wasting. Use a for loop instead.
Thanks Worked +rep