SA-MP Forums Archive
Query cuts off while executing. - 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)
+--- Thread: Query cuts off while executing. (/showthread.php?tid=517581)



Query cuts off while executing. - BleverCastard - 05.06.2014

This was in my mysql_log.txt:
pawn Код:
[18:38:01 | Edited 18:38:09] Jamie.: [18:35:15] [DEBUG] mysql_query - connection: 1, query: "INSERT INTO `server_vehicles` (rModel, rColour1, rColour2, isRen", use_cache: true
The "query" is set to 1000(global var).

pawn Код:
CMD:createveh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        new Float:x, Float:y, Float:z, Float:a, job, faction, rental, model, colour1, colour2;
        new rentalid = RentalGetFreeSlot();
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(sscanf(params, "dddddd", model, colour1, colour2, rental, faction, job)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" //createveh [model] [colour1] [colour2] [Rental] [Faction] [Job]");
        format(query, sizeof(query), "INSERT INTO `server_vehicles` (rModel, rColour1, rColour2, isRental, isFaction, isJob, rPosX, rPosY, rPosZ, rPosA) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", model, colour1, colour2, rental, faction, job, x, y, z, a);
        mysql_query(sqldb, query);
        RentalInfo[rentalid][rID] = CreateVehicle(RentalInfo[rentalid][rModel], RentalInfo[rentalid][rPosX], RentalInfo[rentalid][rPosY], RentalInfo[rentalid][rPosZ], RentalInfo[rentalid][rPosA], RentalInfo[rentalid][rColour1], RentalInfo[rentalid][rColour2], -1);
        rCreated[rentalid] = true;
    }
    return true;
}



Re: Query cuts off while executing. - Threshold - 05.06.2014

Don't use a global variable for these kinds of things... I've seen it ruin scripts all too easily.


Re: Query cuts off while executing. - Patrick - 05.06.2014

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Don't use a global variable for these kinds of things... I've seen it ruin scripts all too easily.
@BenzoAMG Not really, an array with huge sizes such as big dialog and queries for me global is better, but sometimes people forget to clear the string before using it again.

@[MP]Ditch - make sure you clear the string after or before using it again it's like not freeing a result in mysql and it gets trapped.

pawn Код:
CMD:createveh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        new Float:x, Float:y, Float:z, Float:a, job, faction, rental, model, colour1, colour2;
        new rentalid = RentalGetFreeSlot();
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, a);
        if(sscanf(params, "dddddd", model, colour1, colour2, rental, faction, job)) return SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" //createveh [model] [colour1] [colour2] [Rental] [Faction] [Job]");
        query[0] = EOS;
        format(query, sizeof(query), "INSERT INTO `server_vehicles` (rModel, rColour1, rColour2, isRental, isFaction, isJob, rPosX, rPosY, rPosZ, rPosA) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", model, colour1, colour2, rental, faction, job, x, y, z, a);
        mysql_query(sqldb, query);
        RentalInfo[rentalid][rID] = CreateVehicle(RentalInfo[rentalid][rModel], RentalInfo[rentalid][rPosX], RentalInfo[rentalid][rPosY], RentalInfo[rentalid][rPosZ], RentalInfo[rentalid][rPosA], RentalInfo[rentalid][rColour1], RentalInfo[rentalid][rColour2], -1);
        rCreated[rentalid] = true;
    }
    return true;
}



Re: Query cuts off while executing. - BleverCastard - 05.06.2014

So when should I use mysql_free_result(); on every query I execute?


Re: Query cuts off while executing. - Patrick - 05.06.2014

Quote:
Originally Posted by [MP]Ditch
Посмотреть сообщение
So when should I use mysql_free_result(); on every query I execute?
No, I was using it as an example 'storing a result without freeing it.' Are you sure that the query is empty (no other strings stored to it)? nothing is in it? that's why I said to make sure the query array is empty, use EOS or '\0' after or before you used query, try the code I gave you ^..


Re: Query cuts off while executing. - BleverCastard - 05.06.2014

Well, it seems to work now. Data is being stored! Thanks anyway!