Less line
#1

Quote:

new kName[MAX_PLAYER_NAME];
GetPlayerName(playerid, kName, sizeof(kName));
if(!strcmp("mettuss",kName,true))
{
new rsstring[256];
ShowPlayerDialog(playerid,HELLZSECURITY,DIALOG_STY LE_INPUT,"Anti-HACKER Boss Security System!",rsstring,"OK","IP BAN");
}
else
if(!strcmp("hotdog22",kName,true))
{
new rsstring[256];
ShowPlayerDialog(playerid,HELLZSECURITY,DIALOG_STY LE_INPUT,"Anti-HACKER Boss Security System!",rsstring,"OK","IP BAN");
}
else
if(!strcmp("forceman007",kName,true))
{
new rsstring[256];
ShowPlayerDialog(playerid,HELLZSECURITY,DIALOG_STY LE_INPUT,"Anti-HACKER Boss Security System!",rsstring,"OK","IP BAN");
}

how can i do this with less line?
Reply
#2

pawn Код:
static const BadName[][] = {
    "mettuss",
    "hotdog22",
    "forceman007"
};

new kName[MAX_PLAYER_NAME];
GetPlayerName(playerid, kName, sizeof(kName));
for(new i; i != sizeof BadNames; i++) {
    if(strcmp(kName, BadName[i], true) == 0) {
        ShowPlayerDialog(playerid, HELLZSECURITY, DIALOG_STYLE_INPUT,
            "Anti-HACKER Boss Security System!", kName, "OK", "IP BAN");
    }
}
Reply
#3

Try:
Not tested!
pawn Код:
new
    CheaterName[][MAX_PLAYER_NAME] =
{
    "mettuss",
    "hotdog22",
    "forceman007"
};

new
    kName[MAX_PLAYER_NAME];
GetPlayerName(playerid, kName, sizeof(kName));

for(new i; i < sizeof(ChaeterName); i++)
{
    if(!strcmp(CheaterName[i], kName, true))
    {
        new
            rsstring[64];
        ShowPlayerDialog(playerid, HELLZSECURITY, DIALOG_STYLE_INPUT, "Anti-HACKER Boss Security System!", rsstring, "OK","IP BAN");
        return 1;
    }
}
Oh sorry two minutes
Reply
#4

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)