One Word Admin Names -
Melon - 31.07.2012
Hello, my script doesn't allow the use of one word names such as 'Dan' or 'Jay'. If you could script something that allows these names, please could you do that it would help me greatly.
The line: if(strcmp(playername, "Dan", true) == 0) is listed but when I try to log in, it doesn't kick me, on entry of password it does not spawn me ingame.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[256];
if(IsPlayerNPC(playerid))
{
printf("OnDialogResponse: BotKick: %d", playerid);
Kick(playerid);
return 1;
}
if(dialogid == 1) //LOGIN
{
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
if(response)
{
if(!strlen(inputtext))
{
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password.");
return 1;
}
if(strlen(inputtext) >= 50)
{
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long.");
return 0;
}
new tmppass[64];
new playername[MAX_PLAYER_NAME];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
GetPlayerName(playerid, playername, sizeof(playername));
if(strlen(playername) == 3)
{
if(strcmp(playername, "Dan", true) == 0)
{
return 0;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Sorry, that name is too short, please change it.");
SendClientMessage(playerid, COLOR_YELLOW, "Please use the Firstname_Lastname format.");
SendClientMessage(playerid, COLOR_YELLOW, "Name Examples: Jhonny_John, Dan_Wilson, Sarah_Raven");
Kick(playerid);
return 1;
}
}
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You chose to quit from the server (/q).");
Kick(playerid);
}
}
I need this to work for only admins.
Re: One Word Admin Names -
Majed - 31.07.2012
Quote:
Originally Posted by Melon
Hello, my script doesn't allow the use of one word names such as 'Dan' or 'Jay'. If you could script something that allows these names, please could you do that it would help me greatly.
The line: if(strcmp(playername, "Dan", true) == 0) is listed but when I try to log in, it doesn't kick me, on entry of password it does not spawn me ingame.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { new string[256]; if(IsPlayerNPC(playerid)) { printf("OnDialogResponse: BotKick: %d", playerid); Kick(playerid); return 1; } if(dialogid == 1) //LOGIN { if(gPlayerLogged[playerid] == 1) { SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in."); return 1; } if(response) { if(!strlen(inputtext)) { DisplayDialogForPlayer(playerid, 1); //login SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password."); return 1; } if(strlen(inputtext) >= 50) { DisplayDialogForPlayer(playerid, 1); //login SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long."); return 0; } new tmppass[64]; new playername[MAX_PLAYER_NAME]; strmid(tmppass, inputtext, 0, strlen(inputtext), 255); GetPlayerName(playerid, playername, sizeof(playername)); if(strlen(playername) == 3) { if(strcmp(playername, "Dan", true) == 0) { return 0; } else { SendClientMessage(playerid, COLOR_YELLOW, "Sorry, that name is too short, please change it."); SendClientMessage(playerid, COLOR_YELLOW, "Please use the Firstname_Lastname format."); SendClientMessage(playerid, COLOR_YELLOW, "Name Examples: Jhonny_John, Dan_Wilson, Sarah_Raven"); Kick(playerid); return 1; } } Encrypt(tmppass); OnPlayerLogin(playerid,tmppass); } else { SendClientMessage(playerid, COLOR_RED, "You chose to quit from the server (/q)."); Kick(playerid); } }
I need this to work for only admins.
|
What are the errors that coming can you show please?
Re: One Word Admin Names -
Melon - 31.07.2012
Quote:
Originally Posted by Majed
What are the errors that coming can you show please?
|
Hi, there are no errors shown by the compiler.. If I add my name to if(strcmp(playername, "Dan", true) == 0) it doesn't trigger...
pawn Код:
SendClientMessage(playerid, COLOR_YELLOW, "Sorry, that name is too short, please change it.");
SendClientMessage(playerid, COLOR_YELLOW, "Please use the Firstname_Lastname format.");
SendClientMessage(playerid, COLOR_YELLOW, "Name Examples: Jhonny_John, Dan_Wilson, Sarah_Raven");
Kick(playerid);
return 1;
But when I enter my password into the dialog, it doesn't proceed to spawn me in-game.
Re: One Word Admin Names -
gnoomen2 - 01.08.2012
Hi Melon, it's Frank Mawrack
Maybe you can search your GM for something like max_underscores = 2 // 1 or 2
Re: One Word Admin Names -
Melon - 01.08.2012
Aye' Frank. I tried that, nothing there relating to that I'm afraid.
Re: One Word Admin Names -
gnoomen2 - 01.08.2012
Maybe its something that kicks the player on OnPlayerConnect? try to see all over there.
Re: One Word Admin Names -
Roko_foko - 01.08.2012
pawn Код:
//if(!IsPlayerAdmin(playerid)) <-- add this
if(strcmp(playername, "Dan", true) == 0)
{
return 0;//return 1; put here
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Sorry, that name is too short, please change it.");
SendClientMessage(playerid, COLOR_YELLOW, "Please use the Firstname_Lastname format.");
SendClientMessage(playerid, COLOR_YELLOW, "Name Examples: Jhonny_John, Dan_Wilson, Sarah_Raven");
Kick(playerid);
return 1;
}
Re: One Word Admin Names -
Melon - 01.08.2012
Quote:
Originally Posted by Roko_foko
pawn Код:
//if(!IsPlayerAdmin(playerid)) <-- add this if(strcmp(playername, "Dan", true) == 0) { return 0;//return 1; put here } else { SendClientMessage(playerid, COLOR_YELLOW, "Sorry, that name is too short, please change it."); SendClientMessage(playerid, COLOR_YELLOW, "Please use the Firstname_Lastname format."); SendClientMessage(playerid, COLOR_YELLOW, "Name Examples: Jhonny_John, Dan_Wilson, Sarah_Raven"); Kick(playerid); return 1; }
|
Thank you so much,
I changed
pawn Код:
if(!IsPlayerAdmin(playerid))
into
pawn Код:
if(PlayerInfo[playerid][pAdmin] >= 1)
and it works perfectly. + Rep.