Sql vehicle system conflicting with other things
#1

I've narrowed it down to this system to load vehicles, when it's in the script, it makes you re register every time you log in, it's obviously conflicting with it but I don't know what with.

pawn Код:
stock VehicleLoad(vehicleID)
    {
    new Query1[200], DBResult: Result1;
    format(Query1, sizeof(Query1), "SELECT * FROM `VEHICLES` WHERE `ID` = %d LIMIT 1", vehicleID);
    Result1 = db_query(survival, Query1);
    if(db_num_rows(Result1))
        {
        new Field1[20];
        db_get_field_assoc(Result1, "FUEL", Field1, 30);
        VehicleInfo[vehicleID][vFuel] = strval(Field1);
        db_get_field_assoc(Result1, "MODEL", Field1, 30);
        VehicleInfo[vehicleID][vModel] = strval(Field1);
        db_get_field_assoc(Result1, "COLOR1", Field1, 30);
        VehicleInfo[vehicleID][vCol1] = strval(Field1);
        db_get_field_assoc(Result1, "COLOR2", Field1, 30);
        VehicleInfo[vehicleID][vCol2] = strval(Field1);
        db_get_field_assoc(Result1, "ID", Field1, 30);
        VehicleInfo[vehicleID][vID] = strval(Field1);
        db_get_field_assoc(Result1, "SPAWNX", Field1, 30);
        VehicleInfo[vehicleID][vSpawnX] = floatstr(Field1);
        db_get_field_assoc(Result1, "SPAWNY", Field1, 30);
        VehicleInfo[vehicleID][vSpawnY] = floatstr(Field1);
        db_get_field_assoc(Result1, "SPAWNZ", Field1, 30);
        VehicleInfo[vehicleID][vSpawnZ] = floatstr(Field1);
        db_get_field_assoc(Result1, "SPAWNA", Field1, 30);
        VehicleInfo[vehicleID][vSpawnA] = floatstr(Field1);
        print(Query1);
        }
    db_free_result(Result1);
    CreateVehicle(VehicleInfo[vehicleID][vModel], VehicleInfo[vehicleID][vSpawnX], VehicleInfo[vehicleID][vSpawnY], VehicleInfo[vehicleID][vSpawnZ], VehicleInfo[vehicleID][vSpawnA], VehicleInfo[vehicleID][vCol1], VehicleInfo[vehicleID][vCol2], 999999);
    }
pawn Код:
ONPLAYERCONNECT:

GetPlayerName(playerid, name, sizeof(name));
    format(Query, sizeof(Query), "SELECT `NAME` FROM `ACCOUNTS` WHERE `NAME` = '%s' COLLATE NOCASE", DB_Escape(name));
    Result = db_query(survival, Query);
   
    if(db_num_rows(Result))
        {
        new loginstring[100];
        format(loginstring, sizeof(loginstring), "Welcome back!\n{00FF00}Username: {FFFFFF}%s\nEnter your password below\nto get playing!", name);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", loginstring, "Login", "Cancel");
        }
    else
        {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Register","Your account is not registered.\nPlease create a password and click register!","Register","Quit");
        }
    db_free_result(Result);
    return 1;
    }
Reply
#2

Remove collate and nocase from the end of the query.
Reply
#3

that didnt fix it, if I comment out the loadvehicle, the registration works fine, it has to do with the vehicle system
Reply
#4

anyone? this is very crutial
Reply
#5

What SQL Plugin are you using?
Reply
#6

I don't see any similarities between those two that can cause it. Are you sure it's inserted when you register?

Quote:
Originally Posted by 1337connor
Посмотреть сообщение
What SQL Plugin are you using?
None. It's build-in in SA-MP.

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Remove collate and nocase from the end of the query.
How would that affect it? It also needs to be set but when you create the table, only once is fine instead of using it in every query you use the player's name.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I don't see any similarities between those two that can cause it. Are you sure it's inserted when you register?



None. It's build-in in SA-MP.



How would that affect it? It also needs to be set but when you create the table, only once is fine instead of using it in every query you use the player's name.
I dunno, but if I dont comment out the vehicle system, the login won't load, everything else in the database DOES work. If I comment out VehicleLoadAll() in OnGameModeInit, everything works fine
Reply
#8

Could it be because the system to detect if the player is registered is
pawn Код:
Result = db_query(survival, Query);
   
    if(db_num_rows(Result))
and there are multiple tables? Therefore, would it work if I put the PlayerInfo in a seperate database than everything else?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)