[HOWTO]Creating a little script. - 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: [HOWTO]Creating a little script. (
/showthread.php?tid=151104)
[HOWTO]Creating a little script. -
Visualbr - 29.05.2010
I need to create a little script that will kick every single person who joins the game, if he doesn't have an RP name -
Firstname_Lastname - The script should be able to check that.
If, the name is something else, /kickplayer ID for non RP name reason. Just to make automatic.
Thank you.
Re: [HOWTO]Creating a little script. -
(SF)Noobanatior - 29.05.2010
so what is the cryteria for the name only a-z 2 names and sepperated by _ ?
Re: [HOWTO]Creating a little script. -
playbox12 - 29.05.2010
Quote:
Originally Posted by (SF)Noobanatior
so what is the cryteria for the name only a-z 2 names and sepperated by _ ?
|
Thats what he means yes. He means a name should look like this John_Doe and not john_doe or johndoe or JohnDoe etc etc.
Re: [HOWTO]Creating a little script. -
Calgon - 29.05.2010
pawn Код:
public OnPlayerConnect( playerid )
{
new
playerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, playerName, MAX_PLAYER_NAME );
if( strfind( PlayerName, "_", true) == -1)
{
Kick( playerid );
}
return 1;
}
Re: [HOWTO]Creating a little script. -
Visualbr - 29.05.2010
Will this work? Like if the name is John_Doe and not john_Doe neither John_doe.
Re: [HOWTO]Creating a little script. -
(SF)Noobanatior - 29.05.2010
pawn Код:
stock Validrpname(rpname[]) {
new len=strlen(rpname);
new cstate=0;
new i;
for(i=0;i<len;i++) {
if ((cstate==0 || cstate==1) && (rpname[i]>='A' && rpname[i]<='Z') || (rpname[i]>='a' && rpname[i]<='z'))continue;
else {
// Ok no A..Z,a..z
if ((cstate==0) &&(rpname[i]=='_')) {
// its an _ after the name, ok state=1;
cstate=1;
}
else return false; // Its stuff which is not allowed
}
}
if (cstate<1) return false;
else if (len<6) return false; //name must be at least 6 char
else return true;
}
public OnPlayerConnect( playerid )
{
new playerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, playerName, MAX_PLAYER_NAME );
if(!Validrpname(playername){
Kick( playerid );
}
return 1;
}
it dont look for the caps at the start of name can add though
Re: [HOWTO]Creating a little script. -
playbox12 - 29.05.2010
Quote:
Originally Posted by (SF)Noobanatior
pawn Код:
stock Validrpname(rpname[]) { new len=strlen(rpname); new cstate=0; new i; for(i=0;i<len;i++) { if ((cstate==0 || cstate==1) && (rpname[i]>='A' && rpname[i]<='Z') || (rpname[i]>='a' && rpname[i]<='z'))continue; else { // Ok no A..Z,a..z if ((cstate==0) &&(email[i]=='_')) { // its an _ after the name, ok state=1; cstate=1; } else return false; // Its stuff which is not allowed } } if (cstate<1) return false; else if (len<6) return false; //name must be at least 6 char else return true; }
it dont look for the caps at the start of name can add though
|
Ehh this kick players if there name is Jhon_Doe because it kicks on capitals.. (or I am crazy)
Re: [HOWTO]Creating a little script. -
(SF)Noobanatior - 29.05.2010
should allow a-z A-Z and _ also name must be at leat 6 chars