String Arrays
#1

Hello, I am planning to release something that came to my mind but I need to know how to make string arrays, example:
pawn Код:
new Languages[][] =
{
"English",
"Scottish"
}
Reply
#2

pawn Код:
new Languages[][] =
{
"English",
"Scottish"
}

public OnPlayerConnect(playerid)
{
    print(Languages[0]);
    return 1;
}
Reply
#3

Alrighty, how would this code actually work?
pawn Код:
new name[MAX_PLAYER_NAME];
    if(GetPlayerName(playerid, name, sizeof(name)) == CelebNames[0])
    {
        return 1;
    }
Reply
#4

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name))
    if(strcmp(name,CelebNames[0]) == 0)
    {
        return 1;
    }
Reply
#5

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
for(new i = 0; i < sizeof(CelebNames); i++) {
    if(strcmp(name,CelebNames[i],true) == 0) {
        return 1;
    }
}
Reply
#6

Its either me doing something wrong or those codes aren't working correctly.
Reply
#7

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Its either me doing something wrong or those codes aren't working correctly.
Show CelebNames
Reply
#8

pawn Код:
new CelebNames[1][20] =
{
    "David_Beckham"
};
Don't worry, I will add more once its working.
Reply
#9

I will give you an example how to use the function
pawn Код:
new CelebNames[][] = {
    "David_Beckham"
};

public OnPlayerConnect(playerid) {
    if(IsCelebName(playerid)) {
        SendClientMessage(playerid,0xFFFF00AA,"** You have a celebrity name");
        //Kick(playerid);
    }
}

IsCelebName(playerid) {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    for(new i = 0; i < sizeof(CelebNames); i++) {
        if(strcmp(name,CelebNames[i],true) == 0) {
            return 1;
        }
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)