SA-MP Forums Archive
MySQL Problem. - 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: MySQL Problem. (/showthread.php?tid=244939)



MySQL Problem. - GaB1TzZzu - 29.03.2011

I want a command to show the name of a offline player.
EG. /mdcic 233332 .

When you type /mdcic 233332, to show the name of player which table XXXX in database `players` is 233332.



Re: MySQL Problem. - GaB1TzZzu - 30.03.2011

UP .


Re: MySQL Problem. - Calgon - 30.03.2011

Do you actually need the code or did you try make this and it doesn't work?

If you want the code and haven't made it, post in the Script Requests Thread, otherwise post your code in this thread.


Re: MySQL Problem. - GaB1TzZzu - 30.03.2011

I need just an idea. I tried to make, but i don't know how to get the name of that player, which table "XXXX" has value 233332 .


Re: MySQL Problem. - Calgon - 30.03.2011

Show us the code you have so far.


Re: MySQL Problem. - Hornet600 - 30.03.2011

pawn Код:
command(mdcic, playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
            new idx;
            new tmp[120];
            new query[120];
            new myvariable;
            tmp = strtok(params, idx);
            myvariable = strval(tmp);
            if(!strlen(tmp))
            {
                // you did not write the anumber eetc..
                return 1;
            }
            format(query, sizeof(query)," SELECT * FROM playerinfo WHERE yourid=%d",myvariable);
            mysql_query(query); // here you go this query will select whatever you write ingame from the tables where you have your playerinfo saved :P
    }
    return 1;
}



Re: MySQL Problem. - GaB1TzZzu - 30.03.2011

Look, a better eg.

I write in game /search 1555 , and this command i want to show me which player has number 1555. I have in database players, number table.


Re: MySQL Problem. - GaB1TzZzu - 30.03.2011

pawn Код:
if(strcmp(cmd, "/search", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new query[120];
            new Number;
            tmp = strtok(cmdtext, idx);
            Number= strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /search [number]");
                return 1;
            }
            format(query, sizeof(query)," SELECT * FROM players WHERE Number=%d",Number);
            samp_mysql_query(query);
        }
        return 1;
    }
After.. ?


Re: MySQL Problem. - Sergei - 30.03.2011

Код:
command(mdcic, playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
ZCMD and this ... unbelievable ...


Re: MySQL Problem. - [NoV]LaZ - 01.04.2011

Quote:
Originally Posted by GaB1TzZzu
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/search", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new query[120];
            new Number;
            tmp = strtok(cmdtext, idx);
            Number= strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /search [number]");
                return 1;
            }
            format(query, sizeof(query)," SELECT * FROM players WHERE Number=%d",Number);
            samp_mysql_query(query);
        }
        return 1;
    }
After.. ?
You sent the query, store the result, check if there are rows matching your query using mysql_num_rows and fetch the result with mysql_fetch_row_format.