Mysql Cargo System
#1

Hello I just wanted to make a new system like LS:RP Cargo Trucker like going to some type (food, fruits, meat, etc) type / cargo buy puts a box in your hand with a SetPlayerSpecialAction to carry and this You can put it in your car and transport it to another factory where you sell it more expensive but to the same type.

The phase is that I have a problem, I loaded from mysql `cargo` 2 ids, fruits and meat, which you will see in the picture below, if I buy fruits and put them in the car at check I see ID 2 in the database Not what I bought and the name 'meat' not 'fruits' that I ordered. At meat, if I throw the box on foot, createdynamic3dtextlabel appears 'fruits' now inversely? thank you a lot.

IMAGE:
Код:
stock LoadCargos()
{
	new query[256];
	for(new i = 1; i < MAX_CARGO; i++)
	{
		format(query, sizeof(query), "SELECT * FROM cargos WHERE ID=%d", i);
		mysql_function_query(handlesql, query, true, "LoadCargo", "d", i);
	}

	printf("LOADING CARGO...");
	return 1;
}
forward LoadCargo(id);
public LoadCargo(id)
{
    new fields, rows;
    cache_get_data(rows, fields);
    if(rows)
    {
		new fetch[512];
    	cache_get_field_content(0, "ID", fetch);
		CargoInfo[id][ID]= strval(fetch);
		
		cache_get_field_content(0, "Xo", fetch);
		CargoInfo[id][Xo] = floatstr(fetch);
		
		cache_get_field_content(0, "Yo", fetch);
		CargoInfo[id][Yo] = floatstr(fetch);
		
		cache_get_field_content(0, "Zo", fetch);
		CargoInfo[id][Zo] = floatstr(fetch);
		
		cache_get_field_content(0, "Products", fetch);
		CargoInfo[id][Products] = strval(fetch);
		
		cache_get_field_content(0, "MaxProducts", fetch);
		CargoInfo[id][MaxProducts] = strval(fetch);
		
		cache_get_field_content(0, "Name", fetch);
		format(CargoInfo[id][Name], 128, fetch);
		
		cache_get_field_content(0, "Type", fetch);
		CargoInfo[id][Type] = strval(fetch);
		
		cache_get_field_content(0, "Price", fetch);
		CargoInfo[id][Bank] = strval(fetch);
		
		cache_get_field_content(0, "Tpdaname", fetch);
		format(CargoInfo[id][Tpda], 128, fetch);
		
		cache_get_field_content(0, "Tpdaprimary", fetch);
		format(CargoInfo[id][Tpdaprimary], 128, fetch);
		
		cache_get_field_content(0, "Open", fetch);
		CargoInfo[id][Open] = strval(fetch);
  		
		CargoInfo[id][Icon] = CreateDynamicPickup(1318, 1, CargoInfo[id][Xo], CargoInfo[id][Yo], CargoInfo[id][Zo], -1, -1, -1, 50);

		new msg[1024];

		format(msg, sizeof(msg), "[{E5FF00}%s{FFFFFF}]\n{FFFFFF}Storage: %d / %d\n{FFFFFF}Price: $%d / unit",CargoInfo[id][Name], CargoInfo[id][Products], CargoInfo[id][MaxProducts], CargoInfo[id][Bank]);

		CargoInfo[id][Text] = CreateDynamic3DTextLabel(msg, COLOR_WHITE, CargoInfo[id][Xo], CargoInfo[id][Yo], CargoInfo[id][Zo] + 0.7, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1);
		
		Iter_Add(CargoIterator, id);

		printf("Cargo %i a fost incarcat! (Name: %s cu tipul %i)", id, CargoInfo[id][Name], CargoInfo[id][Type]);

	}
	return 1;
}
Код:
Cargo ID:1 has loaded! (Name: fruits with type 1)
Cargo ID:2 has loaded! (Name: meat with type 2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)