Cars from MySQL
#1

I have created a MySQL database with all my cars for the server. Structure goes like this: type, vehid, x, y, z, o, color1, color2. I'm not a superawesome scripter, so..

This is my code:
Код:
		case VEHICLE_LOAD:
		{
		  mysql_store_result(SQLPtr);
		  if(extraid == 333)
		  {
		    printf("MySQL Vehicle Rows: %d", mysql_num_rows(SQLPtr));
		  	for(new c = 0; c < mysql_num_rows(SQLPtr); c++)
		  	{
		  	  format(string, sizeof(string), "SELECT * FROM vehicles WHERE type = '%d'", c);
					mysql_query(string, VEHICLE_LOAD);
				}
			}
	    new id,model,Float:x,Float:y,Float:z,Float:o,c1,c2, idx;
	    mysql_fetch_row_format(string, " ", SQLPtr);
	    id = strval(strtok(string, idx));
	    strval(strtok(string,idx));
	    model = strval(strtok(string, idx));
	    x = strval(strtok(string, idx));
	    y = strval(strtok(string, idx));
	    z = strval(strtok(string, idx));
	    o = strval(strtok(string, idx));
	    c1 = strval(strtok(string, idx));
			c2 = strval(strtok(string, idx));
			
	    CreateVehicle(model,x,y,z,o,c1,c2, 300);
		}
When I start the server it spams messages about vehicles getting loaded, but I can't see them IG.
Reply
#2

What I'm trying to do is spawn vehicles with info from a MySQL database. Anyone?
Reply
#3

Check if you pass correct values to the CreateVehicle() function. Also strval() returns an integer, you need floatstr() to get float from string. You may also want to use CreateStaticVehicleEx() rather thatn CreateVehicle() if you load vehicles in OnGamemodeInit().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)