SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/02/2020, 04:19 PM   #11
Sasinosoft
Little Clucker
 
Sasinosoft's Avatar
 
Join Date: Jan 2020
Location: Tampa, FL
Posts: 27
Reputation: 1
Default Re: MySQL load vehicles issue

You should really show us more code, especially the enum structure and CarInfo.

Also:
Code:
for(new i = 0; i < rows; i++)
    {
        for(new j = 1; j < sizeof(CarInfo); j++)
        { //...
Almost certainly, there is something wrong with that. It's like you are trying to create sizeof(CarInfo) cars for each car row in the table.
Sasinosoft is offline   Reply With Quote
Old 03/02/2020, 05:26 PM   #12
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 34
Reputation: 51
Spray Re: MySQL load vehicles issue

Quote:
Originally Posted by Sasinosoft View Post
You should really show us more code, especially the enum structure and CarInfo.

Also:
Code:
for(new i = 0; i < rows; i++)
    {
        for(new j = 1; j < sizeof(CarInfo); j++)
        { //...
Almost certainly, there is something wrong with that. It's like you are trying to create sizeof(CarInfo) cars for each car row in the table.
PHP Code:
enum cInfo
{
    
cID// Unique ID 
    
cCarID// Real Car ID goes from 1 to 1000 through loop carinfo
    
cModel,
    
Float:cLocationx,
    
Float:cLocationy,
    
Float:cLocationz,
    
Float:cAngle,
    
cColorOne,
    
cColorTwo,
    
cOwner[MAX_PLAYER_NAME],
    
cOwned,
    
cVirWorld
};
new 
CarInfo[600][cInfo];
new 
ownedcar[sizeof(CarInfo)]; 
Saving:

PHP Code:
new car 1;
for(new 
1sizeof(CarInfo); h++)
{
    if(
CarInfo[h][cOwned] == 0)
    {
        
car h;
        
9999;
    }
}

CarInfo[car][cOwned] = 1;
strmid(CarInfo[car][cOwner], sendername0strlen(sendername), 999);
CarInfo[car][cLocationx] = 590.3740;
CarInfo[car][cLocationy] = 1026.0565;
CarInfo[car][cLocationz] = 103.9063;
CarInfo[car][cAngle] = 317.1649;
CarInfo[car][cCarID] = car;
CarInfo[car][cModel] = model;
CarInfo[car][cVirWorld] = 0;
CarInfo[car][cColorOne] = 1;
CarInfo[car][cColorTwo] = 1;
ownedcar[car] = NBC_AddStaticVehicleEx(CarInfo[car][cModel], CarInfo[car][cLocationx], CarInfo[car][cLocationy], CarInfo[car][cLocationz], CarInfo[car][cAngle], 11600000); 
After saving part CarInfo[car][cCarID] is 1 in MySQL Database!

Now loading part:

PHP Code:
public OnGameModeInit()
{
    
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `vehicles`");
    
mysql_pquery(mysqlquery"LoadVehicles""");
    return 
1;
}

forward LoadVehicles();
public 
LoadVehicles()
{
    
// Your code here
    
return 1;



Now i've deleted all cars from the server, and ID is 1, like from my Database.
Second part is to add vehicles step by step, if problem does not accours xD
OsmanMalagic is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL - Load vehicles. DarkLouis Scripting Help 2 09/06/2015 08:27 AM
MySQL Load Issue RedCounty Scripting Help 4 14/01/2015 09:03 PM
How to load and save vehicles from MySQL R38? TheNerka Scripting Help 21 12/09/2014 02:32 PM
Load Vehicles + MYSQL Stefand Scripting Help 2 04/06/2013 02:44 PM
MySQL: Vehicles don't load... Tee Help Archive 0 08/08/2011 09:13 AM


All times are GMT. The time now is 09:12 PM.


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