Converting this to mysql
#1

I have been trying many diffrent way to convert this code to mysql but i just haven't found a way, I get it to work but it dosen't load as it's suppose to. It just shows blank info. A little help on how to convert this to mysql?

pawn Код:
format(str, sizeof(str), "Vehicles/Players/%s.cfg", plname);
    if(dini_Exists(str))
    {
        strmid(PlayerVehicle[playerid][pVeh1], dini_Get(str, "Vehicle1"), 0, strlen(dini_Get(str, "Vehicle1")), 255);
        strmid(PlayerVehicle[playerid][pVeh2], dini_Get(str, "Vehicle2"), 0, strlen(dini_Get(str, "Vehicle2")), 255);
        strmid(PlayerVehicle[playerid][pVeh3], dini_Get(str, "Vehicle3"), 0, strlen(dini_Get(str, "Vehicle3")), 255);
        strmid(PlayerVehicle[playerid][pVeh4], dini_Get(str, "Vehicle4"), 0, strlen(dini_Get(str, "Vehicle4")), 255);
        strmid(PlayerVehicle[playerid][pVeh5], dini_Get(str, "Vehicle5"), 0, strlen(dini_Get(str, "Vehicle5")), 255);
        return 1;
    }
    else
    {
        dini_Create(str);
        strmid(PlayerVehicle[playerid][pVeh1], "None", 0, strlen("None"), 255);
        strmid(PlayerVehicle[playerid][pVeh2], "None", 0, strlen("None"), 255);
        strmid(PlayerVehicle[playerid][pVeh3], "None", 0, strlen("None"), 255);
        strmid(PlayerVehicle[playerid][pVeh4], "None", 0, strlen("None"), 255);
        strmid(PlayerVehicle[playerid][pVeh5], "None", 0, strlen("None"), 255);
        //return 1;
    }
This is OnplayerConnect, Basically what it does is if you own a vehicle it loads them. If you don't own a vehicle it sets all your vehicles to "None"

Oh and sscanf2 if possible
Reply
#2

Check my thread. https://sampforum.blast.hk/showthread.php?tid=177139
Reply
#3

I know how to use sscanf, I've used it for my LoadVehicles. Even with sscanf, I haven't been able to get this to work right with mysql.
Reply
#4

No one has any idea on how to do this?
Reply
#5

Someone must know how to convert this to mysql
Reply
#6

Try yourself, and if you run into problems THEN post ?

First start off with making the db structure, veh1, veh2 ETC.

Then just insert one so you can start debugging.

next, use sscanf to load like i described in my thread, THERE U GO.. isn't harder.
Reply
#7

I have tried it and it's still not working like it's suppose to.

pawn Код:
if (CMySQL_Exists1(plname))
    {
       
       
        CMySQL_Get(plname, "Vehicle1", PlayerInfo[playerid][pVeh1]);
        printf("Vehicle One %s",PlayerInfo[playerid][pVeh1]);
        CMySQL_Get(plname, "Vehicle2", PlayerInfo[playerid][pVeh2]);
        printf("Vehicle Two %s",PlayerInfo[playerid][pVeh2]);
        CMySQL_Get(plname, "Vehicle3", PlayerInfo[playerid][pVeh3]);
        printf("Vehicle Three %s",PlayerInfo[playerid][pVeh3]);
        CMySQL_Get(plname, "Vehicle4", PlayerInfo[playerid][pVeh4]);
        printf("Vehicle Four %s",PlayerInfo[playerid][pVeh4]);
        CMySQL_Get(plname, "Vehicle5", PlayerInfo[playerid][pVeh5]);
        printf("Vehicle Five %s",PlayerInfo[playerid][pVeh5]);

       
    }
    else
    {
       
        format(sql, sizeof(sql), "UPDATE players SET Vehicle1='None',Vehicle2='None',Vehicle3='None',Vehicle4='None',Vehicle5='None' WHERE Username='%s'", plname);
        mysql_query(sql);
        printf("%s",sql);
       
    {
The cmysql_exist is the only way i could think of a way to tell if the user has a car. If i add a query like Select Vehicle1 and shit like that, It dosen't do my account info right.
Reply
#8

Make Vehicle1 etc default: None then do:

if(!strmatch(Slot1, "None"))
{
// The player has an car
}
else
{
strmid(blabla); // youull get it working.
}
Reply
#9

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Make Vehicle1 etc default: None then do:

if(!strmatch(Slot1, "None"))
{
// The player has an car
}
else
{
strmid(blabla); // youull get it working.
}
whats the Slot1 for?
Reply
#10

Thats the loading, im not sure how your loading your mysql rows.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)