Stocks Being Mean To Me :'(
#1

Ok, i have 2 mysql based stocks origianlly coded in Gstyles, but i switched to strikenkids for better speed and stableness.

When i switched, alot of things had to change but i fixed them, but i did everythign i know how to these and nothing works.

Can someone help me get them working again?

This stock is supposed to load vehicle form a mysql db.
pawn Код:
stock LoadOwnedVehicles()
{
    new
        String[512],
        ModelL,
        CL[2],
        PriceL,
        OwnerL[MAX_PLAYER_NAME],
        Float:PosL[4],
        ID,
        PlateNumL[32];
       
    mysql_query("SELECT * FROM `ownedcars` WHERE `ID`");
    mysql_store_result();
   
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(String))
        {
            sscanf(String,"p<|>iiiiis[24]ffffs[32]", ID, ModelL, CL[0], CL[1], PriceL, OwnerL, PosL[0], PosL[1], PosL[2], PosL[3], PlateNumL);//1695
            vehicledata[ID][Model] = ModelL;
            vehicledata[ID][Color1] = CL[0];
            vehicledata[ID][Color2] = CL[1];
            vehicledata[ID][Price] = PriceL;
            format(vehicledata[ID][Owner], 24, "%s", OwnerL);
            vehicledata[ID][PosX] = PosL[0];
            vehicledata[ID][PosY] = PosL[1];
            vehicledata[ID][PosZ] = PosL[2];
            vehicledata[ID][PosA] = PosL[3];
            format(vehicledata[ID][Plate], 32, "%s", PlateNumL);

            new
                ownedcar = CreateVehicle(ModelL, PosL[0], PosL[1], PosL[2], PosL[3], CL[0], CL[1], 500000);//1708
            SetVehicleNumberPlate(ownedcar, PlateNumL);

            isowned[ID] = ownedcar;
            printf("Owned vehicle %d spawned!",ID);
        }
    }
    mysql_free_result();
    return 1;
}
This stock is supposed to load 3dTexts and Pickups from a mysql db.
pawn Код:
stock AddStoreFromMysql()
{
    new Str[67], Float:X, Float:Y, Float:Z, STotal;
    mysql_query("SELECT * FROM `stores`");
    mysql_store_result();

    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>fff", X, Y, Z);
            StorePickup = CreateDynamicPickup(1274, 23, X, Y, Z, -1, -1, -1, PICKUPDISTANCE);
            CreateDynamic3DTextLabel("Store", COLOR_YELLOW, X, Y, Z, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
            CreateDynamicMapIcon(X, Y, Z, 38, 0, -1, -1, -1, MAPICONDISTANCE);
            STotal++;
        }
    }
    mysql_free_result();
    printf("** %i\t<->\tStores Loaded From\t<->\tMySQL\t\t   **", STotal);
    return 1;
}
Reply
#2

Please someone i really need help.
Reply
#3

I do not know Mysql but tried using blasters db system? I don't know the link for now but are you sure you have the correct mysql syntax and so on? Maybe it's not an pawn problem at all?
And what do the prints say?
Can you give us the output?
Reply
#4

This log shows that somewhere between the sscanf loading it and it applying that to my functions its being set to 0.

Код:
[18:12:36] [MySQL] Connected (0) to root @ 127.0.0.1 via TCP/IP.
[18:12:36] [MySQL] Server Version 5.5.8.
[18:12:36] [MySQL] Auto reconnect is off.
[18:12:36] 6|-152.795|70.2877|6.28111
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 7|143.203|-201.151|1.57812
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 8|251.889|-57.1905|1.57031
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 9|822.329|-557.76|16.3359
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 10|1315.47|-898.572|39.5781
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 11|437.34|-1310.69|15.1121
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 12|802.697|-1794.76|13.0234
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 13|1450.04|-2287.26|13.5469
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 14|1940.92|-2116.01|13.6953
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 15|1833.02|-1842.61|13.5781
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 16|2685.08|-2515.12|13.1273
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 17|2117.83|897.498|11.1797
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 18|2319.67|-89.3282|26.4844
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 19|2302.48|57.4316|26.4844
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 20|-78.7974|-1169.57|2.14838
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 21|-2034.19|148.741|28.8359
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] ** 16	<->	Stores Loaded From	<->	MySQL		   **
[18:12:36] Number of vehicle models: 3
And this shows that even though there is a car in the db, its not being loaded at all.
Код:
[Thu Mar 24 18:12:36 2011] Function: mysql_query executed: "SELECT * FROM `ownedcars` WHERE `ID`" with result: "0".
[Thu Mar 24 18:12:36 2011] Function: mysql_store_result executed with result: "1"
[Thu Mar 24 18:12:36 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:12:36 2011] Function: mysql_free_result executed.
Reply
#5

You are missing the delimiter "|" on mysql_fetch_row
Reply
#6

Код:
[Thu Mar 24 18:12:36 2011] Function: mysql_num_rows executed with result: "".
Hmm doesn't soud right if something returns
Код:
""
By The Way, Maybe you can TEMPORARY comment out sscanf and try the old strtok? maybe it is slow but Then we at least will know if the problem is not (or is..) sscanf.
Reply
#7

Quote:
Originally Posted by gamer_Z
Посмотреть сообщение
Код:
[Thu Mar 24 18:12:36 2011] Function: mysql_num_rows executed with result: "".
Hmm doesn't soud right if something returns
Код:
""
By The Way, Maybe you can TEMPORARY comment out sscanf and try the old strtok? maybe it is slow but Then we at least will know if the problem is not (or is..) sscanf.
He's supposed to put an delimiter.

pawn Код:
mysql_fetch_row(Str, "|")
Reply
#8

Here are the functions now, but still not working correctly.

pawn Код:
stock LoadOwnedVehicles()
{
    new
        String[2000],
        ModelL,
        CL[2],
        PriceL,
        OwnerL[MAX_PLAYER_NAME],
        Float:PosL[4],
        ID,
        PlateNumL[32];

    mysql_query("SELECT * FROM `ownedcars` WHERE `ID`");
    mysql_store_result();

    while(mysql_fetch_row(String, "|"))
    {
        if(!mysql_num_rows()) continue;
        sscanf(String,"p<|>iiiiis[24]ffffs[32]", ID, ModelL, CL[0], CL[1], PriceL, OwnerL, PosL[0], PosL[1], PosL[2], PosL[3], PlateNumL);//1695
        print(String);
        vehicledata[ID][Model] = ModelL;
        vehicledata[ID][Color1] = CL[0];
        vehicledata[ID][Color2] = CL[1];
        vehicledata[ID][Price] = PriceL;
        format(vehicledata[ID][Owner], 24, "%s", OwnerL);
        vehicledata[ID][PosX] = PosL[0];
        vehicledata[ID][PosY] = PosL[1];
        vehicledata[ID][PosZ] = PosL[2];
        vehicledata[ID][PosA] = PosL[3];
        format(vehicledata[ID][Plate], 32, "%s", PlateNumL);

        new
            ownedcar = CreateVehicle(ModelL, PosL[0], PosL[1], PosL[2], PosL[3], CL[0], CL[1], 500000);//1708
        SetVehicleNumberPlate(ownedcar, PlateNumL);

        isowned[ID] = ownedcar;
        printf("Owned vehicle %d spawned!",ID);
    }
    mysql_free_result();
    return 1;
}

pawn Код:
stock AddStoreFromMysql()
{
    new Str[1000], id, Float:X, Float:Y, Float:Z, STotal;
    mysql_query("SELECT * FROM `stores`");
    mysql_store_result();


    while(mysql_fetch_row(Str, "|"))
    {
        if(!mysql_num_rows()) continue;
        sscanf(Str, "p<|>ifff",id, X, Y, Z);
        print(Str);
        StorePickup = CreateDynamicPickup(1274, 23, X, Y, Z, -1, -1, -1, PICKUPDISTANCE);
        CreateDynamic3DTextLabel("Store", COLOR_YELLOW, X, Y, Z, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
        CreateDynamicMapIcon(X, Y, Z, 38, 0, -1, -1, -1, MAPICONDISTANCE);
        printf("Store spawned at %f %f %f!",X,Y,Z);
        STotal++;
    }
    mysql_free_result();
    printf("** %i\t<->\tStores Loaded From\t<->\tMySQL\t\t   **", STotal);
    return 1;
}
Reply
#9

Quote:
Originally Posted by Rokzlive
Посмотреть сообщение
Here are the functions now, but still not working correctly.

pawn Код:
stock LoadOwnedVehicles()
{
    new
        String[2000],
        ModelL,
        CL[2],
        PriceL,
        OwnerL[MAX_PLAYER_NAME],
        Float:PosL[4],
        ID,
        PlateNumL[32];

    mysql_query("SELECT * FROM `ownedcars` WHERE `ID`");
    mysql_store_result();

    while(mysql_fetch_row(String, "|"))
    {
        if(!mysql_num_rows()) continue;
        sscanf(String,"p<|>iiiiis[24]ffffs[32]", ID, ModelL, CL[0], CL[1], PriceL, OwnerL, PosL[0], PosL[1], PosL[2], PosL[3], PlateNumL);//1695
        print(String);
        vehicledata[ID][Model] = ModelL;
        vehicledata[ID][Color1] = CL[0];
        vehicledata[ID][Color2] = CL[1];
        vehicledata[ID][Price] = PriceL;
        format(vehicledata[ID][Owner], 24, "%s", OwnerL);
        vehicledata[ID][PosX] = PosL[0];
        vehicledata[ID][PosY] = PosL[1];
        vehicledata[ID][PosZ] = PosL[2];
        vehicledata[ID][PosA] = PosL[3];
        format(vehicledata[ID][Plate], 32, "%s", PlateNumL);

        new
            ownedcar = CreateVehicle(ModelL, PosL[0], PosL[1], PosL[2], PosL[3], CL[0], CL[1], 500000);//1708
        SetVehicleNumberPlate(ownedcar, PlateNumL);

        isowned[ID] = ownedcar;
        printf("Owned vehicle %d spawned!",ID);
    }
    mysql_free_result();
    return 1;
}

pawn Код:
stock AddStoreFromMysql()
{
    new Str[1000], id, Float:X, Float:Y, Float:Z, STotal;
    mysql_query("SELECT * FROM `stores`");
    mysql_store_result();


    while(mysql_fetch_row(Str, "|"))
    {
        if(!mysql_num_rows()) continue;
        sscanf(Str, "p<|>ifff",id, X, Y, Z);
        print(Str);
        StorePickup = CreateDynamicPickup(1274, 23, X, Y, Z, -1, -1, -1, PICKUPDISTANCE);
        CreateDynamic3DTextLabel("Store", COLOR_YELLOW, X, Y, Z, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
        CreateDynamicMapIcon(X, Y, Z, 38, 0, -1, -1, -1, MAPICONDISTANCE);
        printf("Store spawned at %f %f %f!",X,Y,Z);
        STotal++;
    }
    mysql_free_result();
    printf("** %i\t<->\tStores Loaded From\t<->\tMySQL\t\t   **", STotal);
    return 1;
}
Please post with every update the console output and Can you add a bit more debugs?
Reply
#10

MYSQL Log

Код:
[Thu Mar 24 18:27:26 2011] -------------------------
[Thu Mar 24 18:27:26 2011]      Logging Started
[Thu Mar 24 18:27:26 2011] -------------------------
[Thu Mar 24 18:27:26 2011] Function: mysql_init executed with result: "0".
[Thu Mar 24 18:27:26 2011] Connected (0) to root @ 127.0.0.1 via TCP/IP.
[Thu Mar 24 18:27:26 2011] MySQL Server Version 5.5.8.
[Thu Mar 24 18:27:26 2011] Auto reconnect is off.
[Thu Mar 24 18:27:26 2011] Function: mysql_query executed: "SELECT * FROM `stores`" with result: "0".
[Thu Mar 24 18:27:26 2011] Function: mysql_store_result executed with result: "1"
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "6|-152.795|70.2877|6.28111".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "7|143.203|-201.151|1.57812".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "8|251.889|-57.1905|1.57031".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "9|822.329|-557.76|16.3359".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "10|1315.47|-898.572|39.5781".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "11|437.34|-1310.69|15.1121".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "12|802.697|-1794.76|13.0234".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "13|1450.04|-2287.26|13.5469".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "14|1940.92|-2116.01|13.6953".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "15|1833.02|-1842.61|13.5781".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "16|2685.08|-2515.12|13.1273".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "17|2117.83|897.498|11.1797".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "18|2319.67|-89.3282|26.4844".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "19|2302.48|57.4316|26.4844".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "20|-78.7974|-1169.57|2.14838".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_fetch_row executed with result: "21|-2034.19|148.741|28.8359".
[Thu Mar 24 18:27:26 2011] Function: mysql_num_rows executed with result: "".
[Thu Mar 24 18:27:26 2011] Function: mysql_free_result executed.
[Thu Mar 24 18:27:26 2011] Function: mysql_query executed: "SELECT * FROM `ownedcars` WHERE `ID`" with result: "0".
[Thu Mar 24 18:27:26 2011] Function: mysql_store_result executed with result: "1"
[Thu Mar 24 18:27:26 2011] Function: mysql_free_result executed.
SERVER Log
Код:
[18:12:36] [MySQL] Connected (0) to root @ 127.0.0.1 via TCP/IP.
[18:12:36] [MySQL] Server Version 5.5.8.
[18:12:36] [MySQL] Auto reconnect is off.
[18:12:36] 6|-152.795|70.2877|6.28111
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 7|143.203|-201.151|1.57812
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 8|251.889|-57.1905|1.57031
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 9|822.329|-557.76|16.3359
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 10|1315.47|-898.572|39.5781
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 11|437.34|-1310.69|15.1121
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 12|802.697|-1794.76|13.0234
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 13|1450.04|-2287.26|13.5469
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 14|1940.92|-2116.01|13.6953
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 15|1833.02|-1842.61|13.5781
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 16|2685.08|-2515.12|13.1273
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 17|2117.83|897.498|11.1797
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 18|2319.67|-89.3282|26.4844
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 19|2302.48|57.4316|26.4844
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 20|-78.7974|-1169.57|2.14838
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] 21|-2034.19|148.741|28.8359
[18:12:36] Store spawned at 0.000000 0.000000 0.000000!
[18:12:36] ** 16	<->	Stores Loaded From	<->	MySQL		   **
[18:12:36] Number of vehicle models: 3
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)