SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Reload vehicle sql (https://forum.sa-mp.com/showthread.php?t=671204)

EAGLE 15/12/2019 05:02 PM

Reload vehicle sql
 
Hello, when I use my command "/v stats" on my vehicle create with "/v add" I don't have a return with stats.

But when I reboot my server, "/v stats" is work

I think I have a problem with reload vehicle after create a new vehicle, but I don't know how make

And if I need to reboot my server every time I create a new vehicle, it's annoying

Create Vehicle function
https://pastebin.com/C94RCQHZ

CXdur 15/12/2019 06:29 PM

Re: Reload vehicle sql
 
Quote:

Originally Posted by EAGLE (Post 4125102)
Hello, when I use my command "/v stats" on my vehicle create with "/v add" I don't have a return with stats.

But when I reboot my server, "/v stats" is work

I think I have a problem with reload vehicle after create a new vehicle, but I don't know how make

And if I need to reboot my server every time I create a new vehicle, it's annoying

Create Vehicle function
https://pastebin.com/C94RCQHZ

So if I understand correctly, there's only an issue when an admin spawns a vehicle with some sort of command? Players have no issues with vehicles themselves because they cannot spawn it? If I misunderstand, please explain!

It would be helpful with some code of what /v stats look like. It would also be nice to see the lines from where callback SQL_CallVehicleCreate(playerid, model, Float:x, Float:y, Float:z, Float:a, color1, color2) is called from.

The thing is, we can't really know how you retrieve the /v stats. Is it fetched from the DB directly when you do /vstats, or have you already fetched the data to memory?

EAGLE 15/12/2019 06:32 PM

Re: Reload vehicle sql
 
Yes, it's like the vehicle doesn't exist on the server, until I reboot

I have my house system, and it works correctly, when I create a new house, I can check its information, buy it, sell it, I can interact with it, while vehicles not, I have to reboot to be able to interact with them

I have copy a same code for my vehicle system

Load Vehicles: https://pastebin.com/9tRnCR5s
Commands: https://pastebin.com/69xn7DcJ

CXdur 15/12/2019 06:55 PM

Re: Reload vehicle sql
 
How come you access the vehicle info array with vInfo[vehicleId]][], but you also have vId? I think you could stick with just the vehicle ID for its inde, and get rid of the vInfo[vid][vID]?
Code:

new vehicleid = GetPlayerVehicleID(playerid);
        vInfo[vehicleid][vPlaque]

Also, why are you looping through the max vehicles? I believe the issue is that when the vehicle is spawned, it might get a different vehicle ID from what you've used.
Code:

            new vehicle = CreateVehicle(model, x, y, z, a, color1, color2, -1);
                if (vehicle != INVALID_VEHICLE_ID)
                {
                    vInfo[vehicle][vDbId] = id;
                    vInfo[vehicle][vLocked] = false;
                    // set variables

You can apply this to Chargement_Vehicules as well. Only start changing the car data once you have spawned the vehicle, to ensure that you always have the correct vehicle id as your vInfo index.

EAGLE 15/12/2019 07:25 PM

Re: Reload vehicle sql
 
Ok nice, fixed, thank you so much, I have deleted vID and add INVALID_VEHICLE for create, its ok


All times are GMT. The time now is 10:07 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.