Name check
#1

Hello how to check name from mysql?

Код:
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(clickedplayerid, name, sizeof(name));
    if(!strcmp(name, DyrikData[clickedplayerid][Direktorius])) //PlayerName (SQL - accounts), DirectorName(SQL - jobdirectors), i want if playername == directorname got Where director in job
    {
        if(DyrikData[clickedplayerid][DarboID] == 1) dyrikas = "Police";
    }
    else
    {
        if(DyrikData[clickedplayerid][DarboID] == 0) dyrikas = "No have";
    }
Reply
#2

Show where you get the name field from mysql first.
Reply
#3

Код:
case THREAD_LOAD_DARBODYRIKAI:
        {
            new totaldarbodyriku = 0;
            if(szRows)
            {
                new temp[230];
                for(new i = 0; i < szRows; i++)
                {
                    new darboID;

                    cache_get_field_content(i, "DarboID", temp);
                    darboID = strval(temp);

                    cache_get_field_content(i, "Direktorius", temp);
                    format(DyrikData[darboID][Direktorius], 128, "%s", temp);

                    cache_get_field_content(i, "Pavaduotojas", temp);
                    format(DyrikData[darboID][Pavaduotojas], 128, "%s", temp);

                    cache_get_field_content(i, "DyrikIspejimai", temp);
                    DyrikData[darboID][DyrikIspejimai] = strval(temp);

                    cache_get_field_content(i, "PavadIspejimai", temp);
                    DyrikData[darboID][PavadIspejimai] = strval(temp);

                    cache_get_field_content(i, "TuriDyrika", temp);
                    DyrikData[darboID][TuriDyrika] = strval(temp);

                    cache_get_field_content(i, "TuriPavaduotoja", temp);
                    DyrikData[darboID][TuriPavaduotoja] = strval(temp);


                    totaldarbodyriku ++;
                }
                printf("               "PAVADINIMAS" - uћkrauta %i darbo direktorių", totaldarbodyriku);
            }
        }
Код:
Load
stock LoadDarboDyrikai()
{
    format(query, sizeof(query), "SELECT * FROM `"DYRIKU_LENTELE"`");
    mysql_function_query(Mysql_users, query, true, "OnQueryFinish", "i", THREAD_LOAD_DARBODYRIKAI);
    return 1;
}
Save:

stock SaveDarboDyrikai()
{
    format(query, sizeof(query), "UPDATE `"DYRIKU_LENTELE"` SET `Direktorius` = '%s', `Pavaduotojas` = '%s', `DyrikIspejimai` = '%d', `PavadIspejimai` = '%d', `TuriDyrika` = '%d', `TuriPavaduotoja` = '%d' WHERE `DarboID` = '%d'", DyrikData[playerid][Direktorius], DyrikData[playerid][Pavaduotojas], DyrikData[playerid][DyrikIspejimai], DyrikData[playerid][PavadIspejimai], DyrikData[playerid][TuriDyrika], DyrikData[playerid][TuriPavaduotoja]);
    return mysql_function_query(Mysql_users, query, true, "OnQueryFinish", "ii", THREAD_NO_RESULT, playerid);
}
on mysql log loading
Reply
#4

I don't understand this language, can you edit the current post, marking the name variable?
Reply
#5

Код:
case THREAD_LOAD_DARBODYRIKAI:
        {
            new totaljobsdirector = 0;
            if(szRows)
            {
                new temp[230];
                for(new i = 0; i < szRows; i++)
                {
                    new JobID;

                    cache_get_field_content(i, "JobID", temp);
                    darboID = strval(temp);

                    cache_get_field_content(i, "Director", temp);
                    format(DyrikData[JobID][Director], 128, "%s", temp);

                    cache_get_field_content(i, "Alternate", temp);
                    format(DyrikData[JobID][Alternate], 128, "%s", temp);

                    cache_get_field_content(i, "DirectorWarnings", temp);
                    DyrikData[JobID][DirectorWarnings] = strval(temp);

                    cache_get_field_content(i, "AlternateWarnings", temp);
                    DyrikData[JobID][AlternateWarnings] = strval(temp);

                    cache_get_field_content(i, "ThisJobHaveDirector", temp);
                    DyrikData[JobID][ThisJobHaveDirector] = strval(temp);

                    cache_get_field_content(i, "ThisJobHaveAlternate", temp);
                    DyrikData[JobID][ThisJobHaveAlternate] = strval(temp);


                    totaljobsdirector ++;
                }
                printf("               "SERVERNAME" - loaded %i job directors", totaljobsdirector);
            }
        }
converted to English

i want if playername == DyrikData[darboID][Director] 1:1

got where he's director

if in JOBID = 1

he's Police director
Reply
#6

By the way, show the enum.

..
Convert that to english aswell, like you did in the previous one.
Reply
#7

Код:
enum DarboDyrikai
{
    JobID,
    Director[128],
    Alternate[128],
    DirectorWarnings,
    AlternateWarnings,
    ThisJobHaveDirector,
    ThisJobHaveAlternate,
};
new DyrikData[MAX_PLAYERS][DarboDyrikai];
Reply
#8

This is how you are supposed to do it.

Note, this isn't correct, not sure of it, you need to create a new code based on mine, because mine WON'T work.
I just gave you an example of how it should look.

pawn Код:
new Name[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, Name, sizeof(Name));
if(!strcmp(Name == DyrikData[JobID][Director]))
{
    DyrikData[JobID][ThisJobHaveDirector] = 1;
}
else
{
    DyrikData[JobID][ThisJobHaveAlternate] = 1;
}
By the way, all of your vars in mysql are messed up, the format you get them, the enum, you wrote MAX_PLAYERS yet you use JobID.
Reply
#9

error 033: array must be indexed (variable "Name")

Код:
if(!strcmp(Name == DyrikData[clickedplayerid][Director]))
i want show on the TAB
Reply
#10

Ah, shit, I used strcmp in a wrong manner, fix:

pawn Код:
if(!strcmp(Name, DyrikData[clickedplayerid][Director]))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)