All pastes #636737 Raw Edit

Anonymous

public text v1 · immutable
#636737 ·published 2007-07-28 04:33 UTC
rendered paste body
public spawnStatics(){
     samp_mysql_select_db(mysqldb);
     samp_mysql_query("select vehicleid,x,y,z,angle from staticVehicles");
     samp_mysql_store_result();
     if(samp_mysql_num_rows() > 0){
     new result[1024];
     new vehicleid,Float:x,Float:y,Float:z,Float:angle;
     if(samp_mysql_num_rows() > 0){
     print("Spawning static vehicles.");
          while(samp_mysql_fetch_row(result)){
               new index;
               vehicleid = strval(strtok(result,index,'|'));
               x = floatstr(strtok(result,index,'|'));
               y = floatstr(strtok(result,index,'|'));
               z = floatstr(strtok(result,index,'|'));
               angle = floatstr(strtok(result,index,'|'));
               AddStaticVehicle(vehicleid,x,y,z,angle,-1,-1);
          }
     }else{
          print("No vehicles found that need to be spawned.");
     }
     samp_mysql_query("select id,type,x,y,z,rx,ry,rz from staticObjects order by gameid");
     samp_mysql_store_result();
     new result2[256];
     new counter;
     new objtype;
     new dbid;
     new crossref[250][2];
     new Float:rx,Float:ry,Float:rz;
     counter = 0;
     printf("found %d objects to spawn.",samp_mysql_num_rows());
     if(samp_mysql_num_rows() > 0){
     print("Spawning static objects.");
          while(samp_mysql_fetch_row(result2)){
               new index2;
               dbid = strval(strtok(result2,index2,'|'));
               objtype = strval(strtok(result2,index2,'|'));
               x = floatstr(strtok(result2,index2,'|'));
               y = floatstr(strtok(result2,index2,'|'));
               z = floatstr(strtok(result2,index2,'|'));
               rx = floatstr(strtok(result2,index2,'|'));
               ry = floatstr(strtok(result2,index2,'|'));
               rz = floatstr(strtok(result2,index2,'|'));
               
               new newobjid = CreateObject(objtype,x,y,z,rx,ry,rz);
               crossref[counter][0] = dbid;
               crossref[counter][1] = newobjid;
               printf("%d - created object: %d",counter,newobjid);
               counter++;
          }
          printf("%d",sizeof(crossref));
          for(new i = 0; i <= sizeof(crossref)+1 ;i++){
               new query[256];
               format(query,256,"update staticObjects set gameid = %d where id = %d",crossref[i][1],crossref[i][0]);
               print(query);
               samp_mysql_query(query);
          }
     }else{
          print("No objects found that need to be spawned.");
     }
}
return 1;
}