Integer isn't loading in its enum
#1

Hello.
Every variable is loading correctly, but when i wanna use the ID from the database, it keeps printing 0.

this is my onplayercarload:
PHP код:
forward onPlayerCarLoad(playerid);
public 
onPlayerCarLoad(playerid)
{
    new 
num_fields,num_rows;
    new 
string 20 ],string2[35];
    
cache_get_data(num_rows,num_fields,dbhandle);
if(
num_rows!=0)
{
    for(new 
i=0i<num_rowsi++)
    {
        for(new 
0MAX_VEHICLESv++)
        {
            
cInfo[v][carmodelid]=cache_get_field_content_int(i,"model",dbhandle);
            
cInfo[v][c_x]=cache_get_field_content_float(i,"x",dbhandle);
            
cInfo[v][c_y]=cache_get_field_content_float(i,"y",dbhandle);
            
cInfo[v][c_z]=cache_get_field_content_float(i,"z",dbhandle);
            
cInfo[v][c_r]=cache_get_field_content_float(i,"a",dbhandle);
            
cInfo[v][c_color1]=cache_get_field_content_int(i,"color1",dbhandle);
            
cInfo[v][c_color2]=cache_get_field_content_int(i,"color2",dbhandle);
            
cInfo[v][c_respawntime]=cache_get_field_content_int(i,"autorespawn",dbhandle);
            
cInfo[v][carteam]=cache_get_field_content_int(i,"carteam",dbhandle);
            
cInfo[v][cnitro]=cache_get_field_content_int(i"nitro"dbhandle);
            
cInfo[v][db_id]=cache_get_field_content_int(i"id"dbhandle);
            
cache_get_field_content(i"plate"string);
            
format(cInfo[v][plate], 20"%s"string);
            
            
cache_get_field_content(i"owner"string2);
            
format(cInfo[v][carowner], 35"%s"string2);
            
CreateVehicle2(v);
            
//CreateVehicle(cInfo[v][carmodelid],cInfo[v][c_x],cInfo[v][c_y],cInfo[v][c_z],cInfo[v][c_r],cInfo[v][c_color1],cInfo[v]        [c_color2],cInfo[v][c_respawntime]);
            //AddVehicleComponent(v, cInfo[v][cnitro]);
            //SetVehicleNumberPlate(v, cInfo[v][plate]);
            //SetVehicleToRespawn(v);
        
break;
        }
    }
}
else
 {
 return 
1;
 }
    return 
1;

this is the command i try to load the database id:

PHP код:
    else if(!strcmp(tmp"info"true4))
    {
        if(
GetAdminLevel(playerid) < 4) return SendClientError(playeridCANT_USE_CMD);
        if(!
IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid"You are not in any vehicle!");
        new 
vid GetPlayerVehicleID(playerid);
        new 
lockstr[40];
        if(
cInfo[vid][tmplocked]) myStrcpy(lockstr"Yes");
        else 
myStrcpy(lockstr"No");
        new 
stringMAX_STRING ];
        
format(stringsizeof(string), "Car id[%d] Database id[%i] Owner[%s] Colors[%d/%d] Locked[%s] Faction[%d]"vid,cInfo[vid][db_id], cInfo[cInfo[vid][data1337]][carowner],cInfo[vid][c_color1],cInfo[vid][c_color2],lockstrcInfo[vid][carteam]);
        
SendMessageToPlayer(playeridCOLOR_HELPEROOCstring);
    } 
this doesn't load:
PHP код:
Database id[%i]   cInfo[vid][db_id
Someone any idea why?
Reply
#2

Add these on your OnPLayerLoad and show us the results

PHP код:
printf("ID without handler: %i",cache_get_field_content_int(i"id"));
printf("ID with handler: %i",cache_get_field_content_int(i"id"dbhandle)); 
Also why bother making a loop for car ids too?
Loops start at SQL at 1 (AUTO_INCREMENT) if im correct and MAX_VEHICLES start at 0.
So there will be 1 ID difference in it.

For example

PHP код:
#define MAX_SOMETHING 255 //starts at 0, ends at 255
new MyVar[MAX_SOMETHING];
public 
SomeCallback() {
    new 
rows cache_num_rows();
    for(new 
i=0rowsi++) {
        new 
calc i-1//calling row 1 at start and our MAX_SOMETHNIG starts at 0, therefore sub 1 to the MAX_SOMETHING
        
MyVar[calc] = cache_get_field_content_int(i,"Something");
    }

EDIT: proper calculation is actually new calc = i-1; since rows start at 1 and car ids at 0
Reply
#3

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
Add these on your OnPLayerLoad and show us the results

PHP код:
printf("ID without handler: %i",cache_get_field_content_int(i"id"));
printf("ID with handler: %i",cache_get_field_content_int(i"id"dbhandle)); 
Also why bother making a loop for car ids too?
Loops start at SQL at 1 (AUTO_INCREMENT) if im correct and MAX_VEHICLES start at 0.
So there will be 1 ID difference in it.

For example

PHP код:
#define MAX_SOMETHING 255 //starts at 0, ends at 255
new MyVar[MAX_SOMETHING];
public 
SomeCallback() {
    new 
rows cache_num_rows();
    for(new 
i=0rowsi++) {
        new 
calc i-1//calling row 1 at start and our MAX_SOMETHNIG starts at 0, therefore sub 1 to the MAX_SOMETHING
        
MyVar[calc] = cache_get_field_content_int(i,"Something");
    }

EDIT: proper calculation is actually new calc = i-1; since rows start at 1 and car ids at 0
"Also why bother making a loop for car ids too?"

maybe cars get removed and the ID doesn't load anymore because it doesn't fill up that ID anymore.
i'll try the printf right now, sec

EDIT: http://prntscr.com/beavcz

hm, the ids are correct
Reply
#4

What about other stuff such as color etc? Does that load properly in that command?

Like if you do
cInfo[vid][c_color1]
Will it print the proper value?
Reply
#5

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
What about other stuff such as color etc? Does that load properly in that command?

Like if you do
cInfo[vid][c_color1]
Will it print the proper value?
Yes, everything loads, even the name of the player

EDIT: colors dont load in that command, didn't notice that hmm.
Reply
#6

welp it loads now, but it loads the info wrong, and it spawns 2 vehicles on the place.
hm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)