make a maximum name length...? - 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: make a maximum name length...? (
/showthread.php?tid=250299)
make a maximum name length...? -
sciman001 - 22.04.2011
HI! I need a fast way to make a thing that makes the max player name length thing be.. 15 or so.. PLEASE HELP!
Re: make a maximum name length...? -
captainjohn - 22.04.2011
Put were your defines go:
pawn Код:
#define REAL_MAX_PLAYER_NAME 15
Should work.
Re: make a maximum name length...? - [03]Garsino - 22.04.2011
pawn Код:
#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 15
AW: Re: make a maximum name length...? -
Meta - 22.04.2011
Quote:
Originally Posted by [03]Garsino
pawn Код:
#undef MAX_PLAYER_NAME #define MAX_PLAYER_NAME 15
|
use this
Re: make a maximum name length...? -
sciman001 - 22.04.2011
but then... will this kick the player if his name is larger than 15? also, can we make the 15 into 12.
![Cheesy](images/smilies/biggrin.png)
![Cheesy](images/smilies/biggrin.png)
I was thinking something a bit more like this:
pawn Код:
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(sizeof(pname) > 12)
{
SendClientMessage(playerid, red, "GTFO!");
Kick(playerid)
}
Thats not gonna work.. but maybe we can make it work?...
I basically just need to compare the players names size to 12 or MAX_PLAYER_NAME that is redefines and if the players names size is bigger, send a message and kick the player. simple... or not...
Re: make a maximum name length...? -
sciman001 - 22.04.2011
ok.. i am real sorry to bump, but this is mega extremely extram urgent!!!
![Cheesy](images/smilies/biggrin.png)
please reply!
Re: make a maximum name length...? -
Wanted1900 - 22.04.2011
pawn Код:
public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(strlen(pName) > 15) // Will kick the player if his name is longer than 15 characters.
{
SendClientMessage(playerid, COLOR_RED, "Your name is too long, blahblah.");
Kick(playerid);
return 1;
}
return 1;
}
Do you mean something like that?
Re: make a maximum name length...? -
Rivera - 22.04.2011
pawn Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(sizeof(name) >= 13) {
SendClientMessage(playerid, COLOR_YELLOW, "GTFO!");
Kick(playerid);
}
return 1;
}
this should work
Re: make a maximum name length...? -
Hiddos - 22.04.2011
Quote:
Originally Posted by Rivera
pawn Код:
public OnPlayerConnect(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); if(sizeof(name) >= 13) { SendClientMessage(playerid, COLOR_YELLOW, "GTFO!"); Kick(playerid); } return 1; }
this should work ![Cheesy](images/smilies/biggrin.png)
|
It should not, as sizeof is part of the PAWN pre-processor. Use strlen() instead: if(strlen(name) >= 13)
Re: AW: Re: make a maximum name length...? -
Anteino - 22.04.2011
Quote:
Originally Posted by Meta
use this
|
Can you also do this on a global declared string?