Simplest way around this?
#6

Quote:
Originally Posted by shitbird
View Post
The easiest way to go around that problem would be to not store the vehicles in their own database - but store the vehicles in the user accounts database, rendering the actual server-sided vehicleid somewhat useless and easily avoidable. I'm going to go ahead and guess that this is really isn't what you wanted in the first place, but it is an alternative that should work with no major problems.
I could see that working quite easily, except with the player being able to own up to five vehicles, that would be a hell of a lot of extra things to save for just a player. Mods, color, position.. times 5. This does seem like the simplest solution though.

Quote:
Originally Posted by BenzoAMG
View Post
Well instead of saving the vehicle ID, save the vehicle model, position, color, tuning etc. whatever you are looking to save, and save that to the table instead. Then once you relaunch your gamemode/filterscript, just create the vehicles that exist, with the model, colors etc. that are saved in the table.
I'm not saving the SAMP vehicle ID, but a server side ID assigned by the MySQL auto increment. Which actually leads me to think maybe my problem is in my loading method. My stock:
pawn Code:
stock LoadVehicle(houseid)
{
    new query[800],result[32];
    format(query,sizeof(query),"SELECT * FROM vehicles WHERE VehicleID = '%i'",houseid);
    mysql_query(query);
    mysql_store_result();
    if(mysql_num_rows() != 0) {
        while(mysql_fetch_row_format(query,"|")) {
            mysql_fetch_field_row(result, "VehicleID"); VehicleInfo[houseid][vVehID] = strval(result);
            mysql_fetch_field_row(result, "VehicleOwner"); VehicleInfo[houseid][vVehOwner] = result;
            mysql_fetch_field_row(result, "VehicleColor1"); VehicleInfo[houseid][vVehCol1] = strval(result);
            mysql_fetch_field_row(result, "VehicleColor2"); VehicleInfo[houseid][vVehCol2] = strval(result);
            mysql_fetch_field_row(result, "VehicleParkX"); VehicleInfo[houseid][vVehParkX] = floatstr(result);
            mysql_fetch_field_row(result, "VehicleParkY"); VehicleInfo[houseid][vVehParkY] = floatstr(result);
            mysql_fetch_field_row(result, "VehicleParkZ"); VehicleInfo[houseid][vVehParkZ] = floatstr(result);
            mysql_fetch_field_row(result, "VehicleParkA"); VehicleInfo[houseid][vVehParkA] = floatstr(result);
            mysql_fetch_field_row(result, "VehicleLockStatus"); VehicleInfo[houseid][vVehLockStatus] = strval(result);
            mysql_fetch_field_row(result, "VehicleModelID"); VehicleInfo[houseid][vVehModelID] = strval(result);
            //mysql_fetch_field_row(result, "VehicleSAMPID"); VehicleInfo[houseid][vVehSAMPlID] = strval(result);
        }
        CreateVehicle(VehicleInfo[houseid][vVehModelID],VehicleInfo[houseid][vVehParkX],VehicleInfo[houseid][vVehParkY],VehicleInfo[houseid][vVehParkZ],VehicleInfo[houseid][vVehParkA],VehicleInfo[houseid][vVehCol1],VehicleInfo[houseid][vVehCol2],99999999999999);
        vcount++;
    }
    mysql_free_result();
    return 1;
}
And my OnVehicleSpawn as of now:
pawn Code:
public OnVehicleSpawn(vehicleid)
{
    SetVehiclePos(vehicleid,VehicleInfo[vehicleid][vVehParkX],VehicleInfo[vehicleid][vVehParkY],VehicleInfo[vehicleid][vVehParkZ]);
    SetVehicleZAngle(vehicleid,VehicleInfo[vehicleid][vVehParkA]);
    return 1;
}
if I changed that ^ to this ->
pawn Code:
public OnVehicleSpawn(vehicleid)
{
    new vid = VehicleInfo[vehicleid][vVehID];
    SetVehiclePos(vid,VehicleInfo[vid][vVehParkX],VehicleInfo[vid][vVehParkY],VehicleInfo[vid][vVehParkZ]);
    SetVehicleZAngle(vid,VehicleInfo[vid][vVehParkA]);
    return 1;
}
Do you think that could change anything? (can't test it for a few hours) If I'm correct that should fetch the MySQL ID of the spawning vehicle first, and not set the position based on the SAMP vehicle ID like it's currently doing.

Any input?
Reply


Messages In This Thread
Simplest way around this? - by zDevon - 02.01.2013, 03:29
Re: Simplest way around this? - by ReneG - 02.01.2013, 06:37
Re: Simplest way around this? - by zDevon - 02.01.2013, 10:31
Re: Simplest way around this? - by Threshold - 02.01.2013, 10:34
Re: Simplest way around this? - by shitbird - 02.01.2013, 10:40
Re: Simplest way around this? - by zDevon - 02.01.2013, 13:42
Re: Simplest way around this? - by zDevon - 02.01.2013, 21:42
Re: Simplest way around this? - by ReneG - 03.01.2013, 00:17
Re: Simplest way around this? - by zDevon - 03.01.2013, 01:11
Re: Simplest way around this? - by ReneG - 03.01.2013, 05:23

Forum Jump:


Users browsing this thread: 1 Guest(s)