Jump to content

Recommended Posts

Posted

Salut, m am apucat de cva timp de un proiect frumos de la 0 si am ajuns la punctul masini personale, ma poate ajuta si pe mn cnv u un tutorial pentru vehicule personale? comanda /v si daca se poate si /buycar dar ma intereseaza in mare parte comanda /v si systemul in sine de masini personale. 

Multumesc anticipat :))

Posted

Salut, gasesti pe canalul lu Growy TUTS de yt. un tutorial explicativ cum sa faci sistemul de vehicule personale.

Posted

Am inceput sa creez usor usor systemul de masini personale si am o problema cu incarcarea numelui vehicului, nu l gaseste, ma poate ajuta cnv?

https://imgur.com/pqAHfBb

Quote

YCMD:vehicles(playerid, params[], help)
{
    if(!Iter_Count(PlayerVehicles[playerid]))
        return SCM(playerid, COLOR_WHITE,"Nu ai niciun vehicul personal");

    new string[2048] = "Slot\tVehicle\tStatus\tDespawn Time\n";
    foreach(new i : PlayerVehicles[playerid])
    {
        if(PersonalVehicle[i][pvSpawnedID] == INVALID_VEHICLE_ID)
        {
            format(string, 2048, "%s{ffffff}%d\t%s\tHidded\t-\n", string, (i + 1),  GetVehicleName(PersonalVehicle[i][pvModel]));
        }
        else
        {
            format(string, 2048, "%s{ffffff}%d\t%s\t%s\t%d min\n", string, (i + 1), GetVehicleName(PersonalVehicle[i][pvModel]), (IsVehicleOccupied(PersonalVehicle[i][pvSpawnedID])) ? ("{ffffff}Occupied") : ("{FFFFFF}Available"), ((PersonalVehicle[i][pvDespawnTime] - gettime()) / 60)); 
        }
    }

    new title[64];
    format(title, 64, "%s's garage (%d slots)", GetName(playerid), PlayerInfo[playerid][pVehicleSlots]);
    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_TABLIST_HEADERS, title, string, "Select","Close");
    return true;
}

 

Posted

Arată-ne funcția care încarcă vehiculele, văd că lucrezi pe iteratorii, probabil nu ai băgat vehiculul corect în iteratoriul PlayerVehicles.

Posted
function LoadPersonalVehicles(playerid)
{
	if(!chache_num_rows())
		return true;

	new id, string[64];
	for(new i = 1; i < (cache_num_rows() + 1); i++)
	{
		id = Iter_Free(TotalPlayerVehicles);

		PersonalVehicle[id][pvID] = cache_get_field_content_int(i - 1, "ID", mysql);
		PersonalVehicle[id][pvModelID] = cache_get_field_content_int(i - 1, "ModelID", mysql);
		PersonalVehicle[id][pvOwnerID] = cache_get_field_content_int(i - 1, "OwnerID", mysql);
		PersonalVehicle[id][pvColorOne] = cache_get_field_content_int(i - 1, "ColorOne", mysql);
		PersonalVehicle[id][pvColorTwo] = cache_get_field_content_int(i - 1, "ColorTwo", mysql);
		PersonalVehicle[id][pvX] = cache_get_field_content_float(i - 1, "X", mysql);
		PersonalVehicle[id][pvY] = cache_get_field_content_float(i - 1, "Y", mysql);
		PersonalVehicle[id][pvZ] = cache_get_field_content_float(i - 1, "Z", mysql);
		PersonalVehicle[id][pvAngle] = cache_get_field_content_float(i - 1, "Angle", mysql);
		PersonalVehicle[id][pvOdometer] = cache_get_field_content_float(i - 1, "Odometer", mysql);
		PersonalVehicle[id][pvFuel] = cache_get_field_contentfloatt(i - 1, "Fuel", mysql);
		PersonalVehicle[id][pvAge] = cache_get_field_content_int(i - 1, "Age", mysql);
		PersonalVehicle[id][pvInsurancePoints] = cache_get_field_content_int(i - 1, "InsurancePoints", mysql);
		PersonalVehicle[id][pvLock] = cache_get_field_content_int(i - 1, "LockStatus", mysql);


		PersonalVehicle[id][pvSpawnedID] = INVALID_VEHICLE_ID;
		PersonalVehicle[id][pvDespawnTime] = 0;

		cache_get_field_content(i - 1, "CarPlate", PersonalVehicle[id][pvCarPlate], mysql, 12);
		cache_get_field_content(i - 1, "Components", string, mysql, 64);
		sscanf(string, "p<|>ddddddddddddddddd", PersonalVehicle[id][pvComponents][0], PersonalVehicle[id][pvComponents][1], PersonalVehicle[id][pvComponents][2], PersonalVehicle[id][pvComponents][3], PersonalVehicle[id][pvComponents][4], PersonalVehicle[id][pvComponents][5], PersonalVehicle[id][pvComponents][6], PersonalVehicle[id][pvComponents][7], PersonalVehicle[id][pvComponents][8], PersonalVehicle[id][pvComponents][9], PersonalVehicle[id][pvComponents][10], PersonalVehicle[id][pvComponents][11], PersonalVehicle[id][pvComponents][12], PersonalVehicle[id][pvComponents][13], PersonalVehicle[id][pvComponents][14], PersonalVehicle[id][pvComponents][15], PersonalVehicle[id][pvComponents][16]);



		Iter_Add(TotalPlayerVehicles, id);
		Iter_Add(PlayerVehicles[playerid], id);
	}



	return printf("[Account] %s loaded %d vehicles.", GetName(playerid),Iter_count(PlayerVehicles[playerid]));
}
function LoadPersonalVehicles(playerid)
{
	new Cache: db = mysql_query (SQL, "SELECT * FROM `cars` ORDER BY `cars`.`ID` ASC");
	new
		id, 
		string[64];

 	for (new i, j = cache_get_row_count (); i != j; ++i)
	{
		cars ++;
		id = Iter_Free(TotalPlayerVehicles);
		PersonalVehicle[id][pvID] = cache_get_field_content_int(i - 1, "ID", SQL);
		PersonalVehicle[id][pvModel] = cache_get_field_content_int(i - 1, "Model", SQL);
		PersonalVehicle[id][pvOwnerID] = cache_get_field_content_int(i - 1, "OwnerID", SQL);
		PersonalVehicle[id][pvColorOne] = cache_get_field_content_int(i - 1, "ColorOne", SQL);
		PersonalVehicle[id][pvColorTwo] = cache_get_field_content_int(i - 1, "ColorTwo", SQL);
		PersonalVehicle[id][pvX] = cache_get_field_content_float(i - 1, "X", SQL);
		PersonalVehicle[id][pvY] = cache_get_field_content_float(i - 1, "Y", SQL);
		PersonalVehicle[id][pvZ] = cache_get_field_content_float(i - 1, "Z", SQL);
		PersonalVehicle[id][pvAngle] = cache_get_field_content_float(i - 1, "Angle", SQL);
		PersonalVehicle[id][pvOdometer] = cache_get_field_content_float(i - 1, "Odometer", SQL);
		PersonalVehicle[id][pvFuel] = cache_get_field_content_float(i - 1, "Fuel", SQL);
		PersonalVehicle[id][pvAge] = cache_get_field_content_int(i - 1, "Age", SQL);
		PersonalVehicle[id][pvInsurancePoints] = cache_get_field_content_int(i - 1, "InsurancePoints", SQL);
		PersonalVehicle[id][pvLock] = cache_get_field_content_int(i - 1, "LockStatus", SQL);

		PersonalVehicle[id][pvSpawnedID] = INVALID_VEHICLE_ID;
		PersonalVehicle[id][pvDespawnTime] = 0;

		cache_get_field_content(i - 1, "CarPlate", PersonalVehicle[id][pvCarPlate], SQL, 12);
		cache_get_field_content(i - 1, "Owner", PersonalVehicle[id][pvOwner], SQL, 32);
		cache_get_field_content(i - 1, "Components", string, SQL, 64);
		sscanf(string, "p<|>ddddddddddddddddd", PersonalVehicle[id][pvComponents][0], PersonalVehicle[id][pvComponents][1], PersonalVehicle[id][pvComponents][2], PersonalVehicle[id][pvComponents][3], 
			PersonalVehicle[id][pvComponents][4], PersonalVehicle[id][pvComponents][5], PersonalVehicle[id][pvComponents][6], PersonalVehicle[id][pvComponents][7], PersonalVehicle[id][pvComponents][8], PersonalVehicle[id][pvComponents][9], PersonalVehicle[id][pvComponents][10], PersonalVehicle[id][pvComponents][11], PersonalVehicle[id][pvComponents][12], PersonalVehicle[id][pvComponents][13], PersonalVehicle[id][pvComponents][14], PersonalVehicle[id][pvComponents][15], PersonalVehicle[id][pvComponents][16]);



		Iter_Add(TotalPlayerVehicles, id);
		Iter_Add(PlayerVehicles[playerid], id);
	}


	printf("[SERVER]: %d personal cars loaded.", cars);
	cache_delete(db);
	return 1;
}

Prima functie este cea standard pe care am scris o din tutoialul lui Growy iar a doua functie am adaptato ca cea de la loadhouse dar nu ar cam aveam nicio treaba deoarece stiu ca systemul de masini trebuie facut pe iteratori.

  • 1 month later...
Posted

Salut stiu ca este cam vechi acest topic dar am sa imi spun opinia parerea mea sincera este ca daca noi iti dam sistemul intreg tu nu ai sa inveti niciodata cum se face daca cauti pe youtube sau daca iti bati putin capul :) 

Web Developer 
My portfolio: Click

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.