Isn't this logic?
#1

I have this enum
vInfo aka VehicleInfo[MAX_PLAYERS]

I load the vehicles by this public using a loop.

PHP код:
public OnVehiclesAvailable()
{
    new 
rows;
    
cache_get_row_count(rows);
    for(new 
irowsi++)
    {
        
cache_get_value_int(i"ID"VehicleInfo[i][ID]);
        
cache_get_value(i"Owner"VehicleInfo[i][vOwner], 24);
        
cache_get_value_int(i"vModel"VehicleInfo[i][vModel]);
        
cache_get_value_float(i"Pos_x"VehicleInfo[i][vPos_x]);
        
cache_get_value_float(i"Pos_y"VehicleInfo[i][vPos_y]);
        
cache_get_value_float(i"Pos_z"VehicleInfo[i][vPos_z]);
        
cache_get_value_float(i"Rot"VehicleInfo[i][vRot]);
        
cache_get_value_int(i"Fuel"VehicleInfo[i][vFuel]);
        
cache_get_value_int(i"Type"VehicleInfo[i][vType]);
        
cache_get_value(i"Plate"VehicleInfo[i][vPlate], 120);
        
cache_get_value_int(i"vLock"VehicleInfo[i][vLock]);
        
cache_get_value_int(i"Color1"VehicleInfo[i][vColor1]);
        
cache_get_value_int(i"Color2"VehicleInfo[i][vColor2]);
        
cache_get_value_int(i"RespawnDelay"VehicleInfo[i][vRespawnDelay]);
        
cache_get_value_int(i"Price"VehicleInfo[i][vPrice]);
        
//VehicleInfo[i][Vehicle_Cache] = cache_save();
        
pvehicle[i] = CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vPos_x], VehicleInfo[i][vPos_y], VehicleInfo[i][vPos_z], VehicleInfo[i][vRot], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2], VehicleInfo[i][vRespawnDelay]);
        
SetVehicleNumberPlate(pvehicle[i], VehicleInfo[i][vPlate]);
    }
    return 
1;

From that I understand that the loop will run until it loops trough all the cars in the database, example 3 at the moment.
Each car will be assigned to a vehicle info in this way
VehicleInfo[1]...
VehicleInfo[2]...
VehicleInfo[3]...
and stop because thats all the vehicles.

Isn't it normal to get the data from that enum when I call it? Example this command:
PHP код:
CMD:testcar(playeridparams[])
{
    new 
string[200];
    for(new 
iMAX_PVEHICLESi++)
    
format(stringsizeof(string), "Vehicle ID: %d | Vehicle Type: %d, Plate: %s | Owner: %s"VehicleInfo[i][ID], VehicleInfo[i][vType], VehicleInfo[i][vPlate], VehicleInfo[i][vOwner] );
    
SCM(playeridCOLOR_YELLOWstring);
    return 
1;

This loop will run until it reaches 200, max pvehicles.
And it starts
VehicleInfo[1]...
VehicleInfo[2]...
VehicleInfo[3]...

But if I use the command, I get 0 on vehicle ID, vtype etc
Shouldn't this command take the information that was stored in the enum and use it in that format..?
This is my logic..
Reply
#2

Why MAX_PLAYERS? Use MAX_PVEHICLES, as you already define it.

Try this command.
PHP код:
CMD:testcar(playerid)

    new 
string[200]; 
    for(new 
iMAX_PVEHICLESi++)
    {
        
format(stringsizeof(string), "Vehicle ID: %d | Vehicle Type: %d, Plate: %s | Owner: %s"VehicleInfo[i][ID], VehicleInfo[i][vType], VehicleInfo[i][vPlate], VehicleInfo[i][vOwner] ); 
         
SCM(playeridCOLOR_YELLOWstring);
    }
    return 
1

EDIT: Also, mind explaining the command part, I didn't get you.
Reply
#3

Oh damn, yeah, I will modify the max players, also your command will run 200 times, this means that it will spam the chat 200 times.

The command is there just to check if the data loaded correctly, but it returns 0 on everything, the vehicles are created right but I can't use the variables from the enum later and I don't know why..
Reply
#4

There must be something changing them to 0 (null). Try checking out your gamemode and also, debug your vehicle loading function by adding printf.
Reply
#5

As I said, they load right

Vehicle ID: 1, LOADED, Owner: Government, Type: 2
Vehicle ID: 2, LOADED, Owner: Government, Type: 2
Vehicle ID: 11, LOADED, Owner: Noone, Type: 3

something is wrong with the enum...
Reply
#6

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
As I said, they load right

Vehicle ID: 1, LOADED, Owner: Government, Type: 2
Vehicle ID: 2, LOADED, Owner: Government, Type: 2
Vehicle ID: 11, LOADED, Owner: Noone, Type: 3

something is wrong with the enum...
You checked where do they reset?
Reply
#7

Quote:
Originally Posted by Logic_
Посмотреть сообщение
You checked where do they reset?
I made this from 0, I did not reset them once in the whole gamemode, also if I use this instead of the loop.

PHP код:
CMD:testcar(playeridparams[])
{
    new 
string[200];
    new 
GetPlayerVehicleID(playerid);
    
format(stringsizeof(string), "Vehicle ID: %d | Vehicle Type: %d, Plate: %s | Owner: %s"VehicleInfo[i][ID], VehicleInfo[i][vType], VehicleInfo[i][vPlate], VehicleInfo[i][vOwner] );
    
SCM(playeridCOLOR_YELLOWstring);
    return 
1;

It works somehow but the problem is I get the details of the next car.
Example
Car ID: 1 loaded, appears as Car ID 2
Car ID: 2 loaded, appears as Car ID 3
Car ID: 3 loaded, returns 0 on everything
Reply
#8

How about do the loop again and try it both.

PHP код:
for(new iMAXi++)
  if(
GetPlayerVehicleID(playerid) == i)
 
//your code down here 
try that.
Reply
#9

PHP код:
GetVehicleArrayID(vehid

for(new 
iMAX_PVEHICLESi++) 
if(
pvehicle[i]==vehid) return i
return 
INVALID_VEHICLE_ID 

This fixed it
Reply
#10

BTW....I would suggest to use ORM for MySQL that is really more awesome than anything and covers a lot less lines.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)