Spawning Private Vehicles[MySQL]
#33

I keep getting string buffer overflow. Even with 600 cells it's possible, with the code you sent me.

pawn Code:
stock LoadPlayerVehicles(playerid)
{
    new query[600];
    format(query, sizeof(query), "SELECT * FROM `playervehicles` WHERE `Name` = '%s'", PlayerName(playerid));
    mysql_query(query);
    mysql_store_result();
    new i;
    if(mysql_num_rows() != 0)
    {
        while(i < MAX_PLAYER_OWNED_CARS && mysql_num_rows())
        {
            mysql_fetch_row_format(query);
            sscanf(query, "p<|>s[24]dffffdddddddddddddddddddddddddddddddddddd",
                PlayerOwnedVehicles[playerid][i][playerCarOwner],
                PlayerOwnedVehicles[playerid][i][playerCarModel],
                PlayerOwnedVehicles[playerid][i][playerCarX],
                PlayerOwnedVehicles[playerid][i][playerCarY],
                PlayerOwnedVehicles[playerid][i][playerCarZ],
                PlayerOwnedVehicles[playerid][i][playerCarRot],
                PlayerOwnedVehicles[playerid][i][playerCarColor1],
                PlayerOwnedVehicles[playerid][i][playerCarColor2],
                PlayerOwnedVehicles[playerid][i][playerCarPaintjob],
                PlayerOwnedVehicles[playerid][i][playerCarMod1],
                PlayerOwnedVehicles[playerid][i][playerCarMod2],
                PlayerOwnedVehicles[playerid][i][playerCarMod3],
                PlayerOwnedVehicles[playerid][i][playerCarMod4],
                PlayerOwnedVehicles[playerid][i][playerCarMod5],
                PlayerOwnedVehicles[playerid][i][playerCarMod6],
                PlayerOwnedVehicles[playerid][i][playerCarMod7],
                PlayerOwnedVehicles[playerid][i][playerCarMod8],
                PlayerOwnedVehicles[playerid][i][playerCarMod9],
                PlayerOwnedVehicles[playerid][i][playerCarMod10],
                PlayerOwnedVehicles[playerid][i][playerCarMod11],
                PlayerOwnedVehicles[playerid][i][playerCarMod12],
                PlayerOwnedVehicles[playerid][i][playerCarMod13],
                PlayerOwnedVehicles[playerid][i][playerCarMod14],
                PlayerOwnedVehicles[playerid][i][playerCarMod15],
                PlayerOwnedVehicles[playerid][i][playerCarMod16],
                PlayerOwnedVehicles[playerid][i][playerCarMod17],
                PlayerOwnedVehicles[playerid][i][playerCarHasLock],
                PlayerOwnedVehicles[playerid][i][playerCarLocked],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkCash],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkGun1],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkGun2],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkGun3],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkGun4],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkAmmo1],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkAmmo2],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkAmmo3],
                PlayerOwnedVehicles[playerid][i][playerCarTrunkAmmo4],
                PlayerOwnedVehicles[playerid][i][playerCarSpawned],
                PlayerOwnedVehicles[playerid][i][playerCarOwned],
                PlayerOwnedVehicles[playerid][i][playerCarOwnerID],
                PlayerOwnedVehicles[playerid][i][playerCarFuel],
                PlayerOwnedVehicles[playerid][i][playerCarSlotID]
            );
            PlayerOwnedVehicles[playerid][i][playerCarID] = CreateVehicle(PlayerOwnedVehicles[playerid][i][playerCarModel], PlayerOwnedVehicles[playerid][i][playerCarX], PlayerOwnedVehicles[playerid][i][playerCarY], PlayerOwnedVehicles[playerid][i][playerCarZ], PlayerOwnedVehicles[playerid][i][playerCarRot], PlayerOwnedVehicles[playerid][i][playerCarColor1], PlayerOwnedVehicles[playerid][i][playerCarColor2], -1);
            AddVehicleMods(playerid, i);
            i++;
        }
    }
    mysql_free_result();
    return true;
}
This is the only code that's managed to spawn the vehicles I know i'm loading them through mysql_num_rows as it should be mysql_retrieve_row but this is the closest i've been to spawning vehicles and having it working. Though it spams 4 vehicles of the same kind. I'm not saying leave it like that but it must be a good thing. The [i] is used to get the vehicle slot id. MAX_PLAYER_OWNED_VEHICLES 2 would be slot 2 for the player. I'm trying to do it like that, thankyou all for your help again so far.
Reply


Messages In This Thread
Spawning Private Vehicles[MySQL] - Vehicle Not Spawning. - by Peach - 21.12.2012, 16:21
Re: Spawning Private Vehicles[MySQL] - by Peach - 22.12.2012, 16:45
Re: Spawning Private Vehicles[MySQL] - by Faisal_khan - 22.12.2012, 16:51
Re: Spawning Private Vehicles[MySQL] - by Peach - 22.12.2012, 16:52
Re: Spawning Private Vehicles[MySQL] - by ReneG - 22.12.2012, 17:08
Re: Spawning Private Vehicles[MySQL] - by Peach - 22.12.2012, 17:50
Re: Spawning Private Vehicles[MySQL] - by ReneG - 22.12.2012, 17:57
Re: Spawning Private Vehicles[MySQL] - by Peach - 22.12.2012, 18:05
Re: Spawning Private Vehicles[MySQL] - by Peach - 23.12.2012, 17:58
Re: Spawning Private Vehicles[MySQL] - by ReneG - 24.12.2012, 01:23
Re: Spawning Private Vehicles[MySQL] - by Peach - 24.12.2012, 08:56
Re: Spawning Private Vehicles[MySQL] - by ReneG - 24.12.2012, 20:28
Re: Spawning Private Vehicles[MySQL] - by Peach - 24.12.2012, 20:42
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 24.12.2012, 23:56
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 08:30
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 25.12.2012, 10:17
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 11:18
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 25.12.2012, 12:00
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 13:29
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 25.12.2012, 13:46
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 14:59
Re: Spawning Private Vehicles[MySQL] - by ReneG - 25.12.2012, 16:30
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 16:32
Re: Spawning Private Vehicles[MySQL] - by ReneG - 25.12.2012, 16:41
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 16:43
Re: Spawning Private Vehicles[MySQL] - by ReneG - 25.12.2012, 16:57
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 17:06
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 25.12.2012, 18:26
Re: Spawning Private Vehicles[MySQL] - by Peach - 25.12.2012, 19:36
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 25.12.2012, 20:51
Re: Spawning Private Vehicles[MySQL] - by Peach - 27.12.2012, 18:33
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 27.12.2012, 19:43
Re: Spawning Private Vehicles[MySQL] - by Peach - 27.12.2012, 20:42
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 27.12.2012, 21:19
Re: Spawning Private Vehicles[MySQL] - by Peach - 28.12.2012, 09:51
Re: Spawning Private Vehicles[MySQL] - by Peach - 30.12.2012, 14:43
Re: Spawning Private Vehicles[MySQL] - by BlackBank - 31.12.2012, 14:48
Re: Spawning Private Vehicles[MySQL] - by Peach - 01.01.2013, 16:07

Forum Jump:


Users browsing this thread: 1 Guest(s)