make a maximum name length...?
#1

HI! I need a fast way to make a thing that makes the max player name length thing be.. 15 or so.. PLEASE HELP!
Reply
#2

Put were your defines go:


pawn Код:
#define REAL_MAX_PLAYER_NAME 15
Should work.
Reply
#3

pawn Код:
#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 15
Reply
#4

Quote:
Originally Posted by [03]Garsino
Посмотреть сообщение
pawn Код:
#undef MAX_PLAYER_NAME
#define MAX_PLAYER_NAME 15
use this
Reply
#5

but then... will this kick the player if his name is larger than 15? also, can we make the 15 into 12. 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...
Reply
#6

ok.. i am real sorry to bump, but this is mega extremely extram urgent!!! please reply!
Reply
#7

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?
Reply
#8

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
Reply
#9

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
It should not, as sizeof is part of the PAWN pre-processor. Use strlen() instead: if(strlen(name) >= 13)
Reply
#10

Quote:
Originally Posted by Meta
Посмотреть сообщение
use this
Can you also do this on a global declared string?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)