/mycars - MYSQL HELP
#5

MAX_VEHICLES is preset, It will loop to the maximum number of vehicles, Although you could also change that.

What I do is I get the total amount of cars in the database, then loop it off of that.

pawn Код:
stock ReturnCCount()
{
    mysql_query("SELECT * FROM OwnedVehicles");

   
    mysql_store_result();
    new users = mysql_num_rows();

    mysql_free_result();
    return users;
}

then

pawn Код:
command(mycars, playerid, params[])
{
    if(Player[playerid][Adminlevel] == 6)
    {
        for(new i=0; i<ReturnCCount(); i++)
        {
            new Data[150],Field[258],idx;
            new MyCarPlate[10], MyCarModel, MyCarStoreID;
            mysql_queryS("SELECT * FROM `OwnedVehicles` WHERE `VehicleOwner` = '%s'",GetName(playerid));
            mysql_store_result();
            if(mysql_num_rows() == 1)
            {
                mysql_fetch_rowEx(Data);
                Field = strtuk( Data, idx, '|' );
                for(new s = 0; s < 17; s++)
                {
                    switch(s)
                    {
                        case 0: MyCarStoreID = strval(Field);
                        case 1: MyCarModel = strval(Field);
                        case 10: strmid(MyCarPlate,Field,0,strlen(Field),10);

                    }
                    Field = strtuk( Data, idx, '|' );
                }
                fSendClientMessage(playerid, WHITE, "> #%d, ModelID: %d, Plate: %s",MyCarStoreID, MyCarModel, MyCarPlate);
            }
            if(mysql_num_rows() == 0)
            {
                SCM(playerid, YELLOW, "> You do not own any vehicles yet!");
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
/mycars - MYSQL HELP - by Stefand - 30.01.2014, 18:22
Re: /mycars - MYSQL HELP - by Shockey HD - 30.01.2014, 18:59
Re: /mycars - MYSQL HELP - by Stefand - 30.01.2014, 19:52
Re: /mycars - MYSQL HELP - by Stefand - 30.01.2014, 20:46
Re: /mycars - MYSQL HELP - by Shockey HD - 30.01.2014, 20:52
Re: /mycars - MYSQL HELP - by Stefand - 30.01.2014, 21:13
Re: /mycars - MYSQL HELP - by PowerPC603 - 30.01.2014, 21:16
Re: /mycars - MYSQL HELP - by Stefand - 30.01.2014, 21:29
Re: /mycars - MYSQL HELP - by PowerPC603 - 30.01.2014, 21:32
Re: /mycars - MYSQL HELP - by Stefand - 31.01.2014, 11:33

Forum Jump:


Users browsing this thread: 2 Guest(s)