Names _ - 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: Names _ (
/showthread.php?tid=366432)
Names _ -
Dare Devil..... - 06.08.2012
Hey can I do something that when a player connects to the server if he have _ between his name like James_Mcay he can register or login but if his name is like James Mcay or James or Doriftar something it kicks him
Re: Names _ -
BlackBank - 06.08.2012
Yes, use strfind for this.
Re: Names _ -
BigBaws - 06.08.2012
Код:
Public OnPlayerConnect(playerid)
{
LoggedTime[playerid] = 0;
new string[256];
gPlayerLogged[playerid] = 0;
gAdminLogged[playerid] = 0;
new plname[MAX_PLAYER_NAME],tmpvar;
GetPlayerName(playerid, plname, sizeof(plname));
if(!NameIsRP(plname)) {
SendClientMessage(playerid, COLOR_WHITE, "Your ServerName: Your name is not applicable on Test Server Dare Devil.");
SendClientMessage(playerid, COLOR_YELLOW2, "HINT: Your name must be in the format of Firstname_Lastname.");
Kick(playerid); //yes, use Kick here because theres no data to save . ( this is lets player to be kicked after the message (Dare Devil)
return 1;
}
PS : if i helped you Dont forget to Rep
Re: Names _ -
RelaxCafe - 06.08.2012
Quote:
Originally Posted by BigBaws
if(!NameIsRP(plname))
|
^fail. Where is this function, eh?
Код:
stock IsValidRPName(playerid)
{
new name[MAX_PLAYER_NAME];
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, name, sizeof(name));
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if (name[i] == '_') return 1;
if (name[i] == ']' || name[i] == '[') return 0;
}
}
return 0;
}
put this onplayerconnect
Код:
if(!IsValidRPName(playerid))
{
SendClientMessage(playerid,0xFF000000, "Change name asshole, this is an RP server");
Kick(playerid);
}
Re: Names _ -
leonardo1434 - 06.08.2012
Made this quirckly, it gonna make their names valid's for rp servers.
pawn Код:
stock validname(playerid)
{
static i = -1,name[25];
GetPlayerName(playerid,name,sizeof(name));
while(++i < strlen(name))
{
if(name[i] == '_' && name[i] == '[' && name[i] == ']') strdel(name,i,i+1);
}
return SetPlayerName(playerid,name),i = 0;
}
// just do that on onplayerconnect
validname(playerid);
Re: Names _ -
Vince - 06.08.2012
Are you aware that players can join with @, $ and dots in their name as well? Not to mention numbers.
Re: Names _ -
leonardo1434 - 06.08.2012
forgot about it.
pawn Код:
stock validname(playerid)
{
static i = -1,name[25];
GetPlayerName(playerid,name,sizeof(name));
while(++i < strlen(name))
{
if(name[i] == '_' && name[i] == '[' && name[i] == ']' && name[i] == '@' && name[i] == '$' && name[i] == '.' && name[i] >= '0' && name[i] <= '9') strdel(name,i,i+1);
}
return SetPlayerName(playerid,name),i = 0;
}