Making a mysql car system
#1

Hello,
i'm making a mysql car saving system, but i have one bug;
i want that the car gets loaded from the id that is in the database.
this is my code right now:
PHP код:
forward onPlayerCarLoad(playerid);
public 
onPlayerCarLoad(playerid)
{
new 
num_fields,num_rows;
new 
string[420],temp_carowner[35];
cache_get_data(num_rows,num_fields,dbhandle);
if(!
num_rows)return 1;
cInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle);
 for(new 
i=0i<num_rowsi++)
 {
  new 
id=cInfo[id][db_id]();
  
cInfo[id][carmodelid]=cache_get_field_content_int(i,"model",dbhandle);
  
cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
  
cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
  
cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
  
cInfo[id][c_r]=cache_get_field_content_float(i,"a",dbhandle);
  
cInfo[id][c_color1]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_color2]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_respawntime]=cache_get_field_content_int(i,"autorespawn",dbhandle);
  
cache_get_field_content(0"owner"temp_carowner);
format(string,sizeof(string),"%s",temp_carowner);
myStrcpy(cInfo[id][carowner], string);
CreateVehicle(cInfo[id][carmodelid],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][c_color1],cInfo[id][c_color2],cInfo[id][c_respawntime]);
  
 }
return 
1;

How do i make it that new id=cInfo[id][db_id]();

Thanks
Reply
#2

if i'm vague, just tell me what you need to know to help me.
i really wanna get this done :3
Reply
#3

Make a query inside your loop and
PHP код:
SELECT FROM tablenamehere WHERE columnforidwhohasIE '%d'
Then it will be easier to load
Reply
#4

Quote:
Originally Posted by ilijap
Посмотреть сообщение
Make a query inside your loop and
PHP код:
SELECT FROM tablenamehere WHERE columnforidwhohasIE '%d'
Then it will be easier to load
thanks for your time but i already fixed it.
Reply
#5

You also have another small bug
pawn Код:
cache_get_field_content(0, "owner", temp_carowner);
should be
pawn Код:
cache_get_field_content(i, "owner", temp_carowner);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)