a little problem
#1

hello.
each time i run this script, for some reason it doesn't create 1 car, it creates 560.
wtf
ok

this is the script;
PHP код:
forward carSavedToDB(carid);
public 
carSavedToDB(carid)
{
    
cInfo[carid][db_id]=cache_insert_id(dbhandle);
    return 
1;
}
saveCarToDB(playerid,carid)
{
new 
query[128];
format(query,sizeof(query),"INSERT INTO vehicles(owner,model,x,y,z,a) VALUES ('%s','%i','%f','%f','%f','%f')",cInfo[playerid][carowner],cInfo[carid][carmodelid],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]);
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
}
createPlayerCar(playerid,mID,Float:x,Float:y,Float:z,Float:r,temp_color1,temp_color2,temp_autorespawn)
{
    for(new 
i=0isizeof(cInfo); i++)
    {
     if(
cInfo[i][id_x]!=0)continue;
     
format(cInfo[i][carowner],MAX_PLAYER_NAME,"%s",PlayerName(playerid));
     
cInfo[i][c_x]=x;
     
cInfo[i][c_y]=y;
     
cInfo[i][c_z]=z;
     
cInfo[i][c_r]=r;
     
cInfo[i][c_color1]=temp_color1;
      
cInfo[i][c_color2]=temp_color2;
      
cInfo[i][c_autorespawn]=temp_autorespawn;
      
cInfo[i][carmodelid]= mID;
     
cInfo[i][id_x]= CreateVehicle(mID,x,y,z,r,temp_color1,temp_color2,temp_autorespawn);
     
saveCarToDB(playerid,i);
     
SetVehicleNumberPlate(i,"NOTREG");
    }
    return 
1;

Reply
#2

Maybe like this?

Код HTML:
forward carSavedToDB(carid); 
public carSavedToDB(carid) 
{ 
    cInfo[carid][db_id]=cache_insert_id(dbhandle); 
    return 1; 
} 
saveCarToDB(playerid,carid) 
{ 
new query[128]; 
format(query,sizeof(query),"INSERT INTO vehicles(owner,model,x,y,z,a) VALUES ('%s','%i','%f','%f','%f','%f')",cInfo[playerid][carowner],cInfo[carid][carmodelid],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]); 
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid); 
} 
createPlayerCar(playerid,mID,Float:x,Float:y,Float:z,Float:r,temp_color1,temp_color2,temp_autorespawn) 
{ 
    for(new i=0; i< sizeof(cInfo); i++) 
    { 
     if(cInfo[i][id_x]!=0)continue; 
     format(cInfo[i][carowner],MAX_PLAYER_NAME,"%s",PlayerName(playerid)); 
     cInfo[i][c_x]=x; 
     cInfo[i][c_y]=y; 
     cInfo[i][c_z]=z; 
     cInfo[i][c_r]=r; 
     cInfo[i][c_color1]=temp_color1; 
      cInfo[i][c_color2]=temp_color2; 
      cInfo[i][c_autorespawn]=temp_autorespawn; 
      cInfo[i][carmodelid]= mID; 
     cInfo[i][id_x]= CreateVehicle(mID,x,y,z,r,temp_color1,temp_color2,temp_autorespawn); 
     saveCarToDB(playerid,i); 
     SetVehicleNumberPlate(i,"NOTREG"); 
     break;
    } 
    return 1; 
}
Reply
#3

Quote:
Originally Posted by Ivan_Ino
Посмотреть сообщение
Maybe like this?

Код HTML:
forward carSavedToDB(carid); 
public carSavedToDB(carid) 
{ 
    cInfo[carid][db_id]=cache_insert_id(dbhandle); 
    return 1; 
} 
saveCarToDB(playerid,carid) 
{ 
new query[128]; 
format(query,sizeof(query),"INSERT INTO vehicles(owner,model,x,y,z,a) VALUES ('%s','%i','%f','%f','%f','%f')",cInfo[playerid][carowner],cInfo[carid][carmodelid],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]); 
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid); 
} 
createPlayerCar(playerid,mID,Float:x,Float:y,Float:z,Float:r,temp_color1,temp_color2,temp_autorespawn) 
{ 
    for(new i=0; i< sizeof(cInfo); i++) 
    { 
     if(cInfo[i][id_x]!=0)continue; 
     format(cInfo[i][carowner],MAX_PLAYER_NAME,"%s",PlayerName(playerid)); 
     cInfo[i][c_x]=x; 
     cInfo[i][c_y]=y; 
     cInfo[i][c_z]=z; 
     cInfo[i][c_r]=r; 
     cInfo[i][c_color1]=temp_color1; 
      cInfo[i][c_color2]=temp_color2; 
      cInfo[i][c_autorespawn]=temp_autorespawn; 
      cInfo[i][carmodelid]= mID; 
     cInfo[i][id_x]= CreateVehicle(mID,x,y,z,r,temp_color1,temp_color2,temp_autorespawn); 
     saveCarToDB(playerid,i); 
     SetVehicleNumberPlate(i,"NOTREG"); 
     break;
    } 
    return 1; 
}
works ty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)