How to make a anti-non-rp-name system help. -
nicholasramdhan - 14.03.2015
Well, the name says it all. I'm here again with an issue with my RP script, where anyone can log in with a NON-RP name such as 'Dre'. I want it to be where they have to login with a RP name like Dre_Valencia or something. So can anyone please tell me a line or something that I need to add to my script that'll automatically kick the players who log in with an UNRP name? Please and thanks.
I don't really know if i should post lines from my script, but if I need to, please tell me which lines I should post.
Re: How to make a anti-non-rp-name system help. -
ReD_HunTeR - 14.03.2015
Use this on OnPlayerConnect, so whenever player connect with non-rp name(Ex: Dre) Will kick him.
pawn Код:
public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(strfind(pName "_", true) == -1)
{
SendClientMessage(playerid, 0xFF0000AA, "This is a Roleplay Server, Please get a name in the correct format: Firstname_Lastname. (Ex. Dre_Valencia)" );
Kick(playerid);
}
return 1;
}
Re: How to make a anti-non-rp-name system help. -
nicholasramdhan - 14.03.2015
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(104989) : warning 217: loose indentation
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107454) : error 021: symbol already defined: "Itter_OnPlayerConnect"
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107456) : error 035: argument type mismatch (argument 2)
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107456) : error 035: argument type mismatch (argument 2)
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : error 035: argument type mismatch (argument 1)
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : warning 215: expression has no effect
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : warning 215: expression has no effect
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : error 001: expected token: ";", but found ")"
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : error 029: invalid expression, assumed zero
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : fatal error 107: too many error messages on one line
Код:
public OnPlayerConnect(playerid)
{
for (new i = 0; i < 4; i ++)
{
DriveThruItems[playerid][i] = 0;
}
if(Security != 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "Host has broken one of the Agreement rules, action has been taken.");
Kick(playerid);
return 1;
}
I already have that under OnPlayerConnect, so can you show me how I would add it to that?
Re : How to make a anti-non-rp-name system help. -
MrAlexisX2 - 14.03.2015
Quote:
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(104989) : warning 217: loose indentation
|
Problem of indentation.
Quote:
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107454) : error 021: symbol already defined: "Itter_OnPlayerConnect"
|
You have "public OnPlayerConnect(playerid)" hook or assemble it.
Quote:
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107456) : error 035: argument type mismatch (argument 2)
|
Give line.
Quote:
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : warning 215: expression has no effect
|
Give line.
Quote:
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(107457) : error 001: expected token: ";", but found ")"
|
Give line.
Re: How to make a anti-non-rp-name system help. -
Abagail - 14.03.2015
First of all, using his example people can scam the system by just putting "name_". A better example would be checking if the surname has a greater length than 1 assuming they have an _.
pawn Код:
if(strfind(pName, "_", true) == -1)
{
// code
}
else
{
if(strlen(GetPlayerSurname(playerid) == 0)
{
SendClientMessage(playerid, -1, "Invalid last name.");
Kick(playerid);
return 0;
}
}
Using a stock such as:
pawn Код:
stock GetPlayerSurname(playerid)
{
new pName[24];
GetPlayerName(playerid, pName, sizeof(pName));
for(new i = 0; i < 24; i++)
{
if(pName[i] == '_')
{
strdel(pName, 0, i);
}
}
return pName;
}
Re: How to make a anti-non-rp-name system help. -
nicholasramdhan - 14.03.2015
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(24810) : error 001: expected token: ",", but found "-string-"
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(24810) : warning 215: expression has no effect
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(24810) : warning 215: expression has no effect
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(24810) : error 001: expected token: ";", but found ")"
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(24810) : error 029: invalid expression, assumed zero
C:\Users\Nicholas\Desktop\AG-RP\gamemodes\AGRP.pwn(24810) : fatal error 107: too many error messages on one line
Okay well, I narrowed it down to 4 errors, but, now here's the code.
public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(strfind(pName "_", true) == -1)
{
SendClientMessage(playerid, 0xFF0000AA, "This is a Roleplay Server, Please get a name in the correct format: Firstname_Lastname. (Ex. Dre_Valencia)" );
Kick(playerid);
}
return 1;
}
That's line 24806-24816
Re: How to make a anti-non-rp-name system help. -
nicholasramdhan - 14.03.2015
Quote:
Originally Posted by Abagail
First of all, using his example people can scam the system by just putting "name_". A better example would be checking if the surname has a greater length than 1 assuming they have an _.
pawn Код:
if(strfind(pName, "_", true) == -1) { // code }
else { if(strlen(GetPlayerSurname(playerid) == 0) { SendClientMessage(playerid, -1, "Invalid last name."); Kick(playerid); return 0; } }
Using a stock such as:
pawn Код:
stock GetPlayerSurname(playerid) { new pName[24]; GetPlayerName(playerid, pName, sizeof(pName)); for(new i = 0; i < 24; i++) { if(pName[i] == '_') { strdel(pName, 0, i); } } return pName; }
|
Then give me a line to add to the script please that will kick them if it isn't like that.
Re: How to make a anti-non-rp-name system help. -
Abagail - 14.03.2015
That is it, but ok
pawn Код:
public OnPlayerConnect(playerid) {
new player_name[MAX_PLAYER_NAME];
GetPlayerName(playerid, player_name, MAX_PLAYER_NAME);
if(!IsValidName(player_name))
{
SendClientMessage(playerid, -1, "You're name is not roleplay! Come back with a RP-suitable name.");
SetTimerEx("KickEx", 1000, false, "i", playerid);
return 0;
}
else {
return 1; // There name is good.
}
return 1;
}
stock IsValidName(name[])
{
if(strlen(name) >= MAX_PLAYER_NAME) return 0;
if(strfind(name, "_", true) == -1 || strlen(GetPlayerSurname(playerid)) return 0;
return 1;
}
stock GetPlayerSurname(player_name[])
{
for(new i = 0; i < 24; i++)
{
if(player_name[i] == '_')
{
strdel(player_name, 0, i);
}
}
return player_name;
}