Spawn car problem
#1

Hello.
I got this code right now:
PHP код:
forward onPlayerCarLoad(playerid);
public 
onPlayerCarLoad(playerid)
{
new 
num_fields,num_rows;
new 
temp_carowner[35],temp_plate[50],string[420],string2[420];
cache_get_data(num_rows,num_fields,dbhandle);
if(!
num_rows)return 1;
 for(new 
i=0i<num_rowsi++)
 {
  new 
id=getFreeCarID();
  
cInfo[id][carmodelid]=cache_get_field_content_int(id,"model",dbhandle);
  
cInfo[id][c_x]=cache_get_field_content_float(id,"x",dbhandle);
  
cInfo[id][c_y]=cache_get_field_content_float(id,"y",dbhandle);
  
cInfo[id][c_z]=cache_get_field_content_float(id,"z",dbhandle);
  
cInfo[id][c_r]=cache_get_field_content_float(id,"a",dbhandle);
  
cInfo[id][c_color1]=cache_get_field_content_int(id,"color1",dbhandle);
  
cInfo[id][c_color2]=cache_get_field_content_int(id,"color2",dbhandle);
  
cInfo[id][c_respawntime]=cache_get_field_content_int(id,"autorespawn",dbhandle);
  
cInfo[id][carteam]=cache_get_field_content_int(id,"carteam",dbhandle);
cache_get_field_content(id"plate"temp_plate);
cache_get_field_content(id"owner"temp_carowner);
format(string,sizeof(string),"%s",temp_plate);
format(string2,sizeof(string2),"%s",temp_carowner);
myStrcpy(cInfo[id][plate],string);
myStrcpy(cInfo[id][carowner],string2);
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]);
cInfo[id][cnitro]=cache_get_field_content_int(i,"nitro",dbhandle);
AddVehicleComponent(id,cInfo[id][cnitro]);
SetVehicleNumberPlate(id,cInfo[id][plate]);
SetVehicleToRespawn(id);
}
return 
1;
}
loadPlayerCars(playerid)
{
new 
query[128],name[35];
GetPlayerName(playerid,name,35);
format(query,sizeof(query),"SELECT * FROM vehicles WHERE owner='%s'",name);
mysql_function_query(dbhandle,query,true,"onPlayerCarLoad","i",playerid);

This are the lines i got a question about:
PHP код:
format(string,sizeof(string),"%s",temp_plate);
format(string2,sizeof(string2),"%s",temp_carowner);
myStrcpy(cInfo[id][plate],string);
myStrcpy(cInfo[id][carowner],string2); 
Right now it only loads into 1 string, so when they load 2 cars, it only loads the first one, and it just skips the second car.
Now is my question;
How do i do this for a loop?

(if i'm vague, tell me)
Reply
#2

Hmm or should this work?
I'm really confused.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)