Mariusik Posted March 18, 2017 Posted March 18, 2017 Am facut un sistem de tutveh, pentru versiunea de mysql R40, dar problema e ca dupa ce dau rr la server nu se incarca masinile la OnGameModeInit mysql_format(handle, gQuery, sizeof(gQuery), "SELECT * FROM `vehicles`"); mysql_pquery(handle, gQuery, "LoadVehicles", "i"); function LoadVehicles() { new id = 0; id++; cache_get_value_name_int(0, "CarID", vInfo[id][vCarID]); cache_get_value_name_int(0, "Model", vInfo[id][vModel]); cache_get_value_name_int(0, "Color1", vInfo[id][vColor1]); cache_get_value_name_int(0, "Color2", vInfo[id][vColor2]); cache_get_value_name_int(0, "Price", vInfo[id][vPrice]); cache_get_value_name(0, "Owner", vInfo[id][vOwner]); cache_get_value_name_float(0, "vPosX", vInfo[id][vPosX]); cache_get_value_name_float(0, "vPosY", vInfo[id][vPosY]); cache_get_value_name_float(0, "vPosZ", vInfo[id][vPosZ]); cache_get_value_name_float(0, "vPosA", vInfo[id][vPosA]); cache_get_value_name(0, "Plate", vInfo[id][vPlate]); cache_get_value_name_int(0, "PaintJ", vInfo[id][vPaintJ]); cache_get_value_name_int(0, "Locked", vInfo[id][vLocked]); cache_get_value_name_int(0, "Spawned", vInfo[id][vSpawned]); cache_get_value_name_int(0, "Destroyed", vInfo[id][vDestroyed]); cache_get_value_name_float(0, "Km", vInfo[id][vKm]); cache_get_value_name_int(0, "Neon", vInfo[id][vNeon]); cache_get_value_name_int(0, "Fuel", vInfo[id][vFuel]); cache_get_value_name_int(0, "Type", vInfo[id][vType]); cache_get_value_name_int(0, "vMod1", vInfo[id][mod1]); cache_get_value_name_int(0, "vMod2", vInfo[id][mod2]); cache_get_value_name_int(0, "vMod3", vInfo[id][mod3]); cache_get_value_name_int(0, "vMod4", vInfo[id][mod4]); cache_get_value_name_int(0, "vMod5", vInfo[id][mod5]); cache_get_value_name_int(0, "vMod6", vInfo[id][mod6]); cache_get_value_name_int(0, "vMod7", vInfo[id][mod7]); cache_get_value_name_int(0, "vMod8", vInfo[id][mod8]); cache_get_value_name_int(0, "vMod9", vInfo[id][mod9]); cache_get_value_name_int(0, "vMod10", vInfo[id][mod10]); cache_get_value_name_int(0, "vMod11", vInfo[id][mod11]); cache_get_value_name_int(0, "vMod12", vInfo[id][mod12]); cache_get_value_name_int(0, "vMod13", vInfo[id][mod13]); cache_get_value_name_int(0, "vMod14", vInfo[id][mod14]); cache_get_value_name_int(0, "vMod15", vInfo[id][mod15]); cache_get_value_name_int(0, "vMod16", vInfo[id][mod16]); cache_get_value_name_int(0, "vMod17", vInfo[id][mod17]); Total_Veh_Created = vInfo[id][vCarID]; for(new i = 1; i < MAX_VEHICLES; i++) OwnedVeh(i) = 0; return 1; } Ce nu am facut bine
0 Mariusik Posted March 18, 2017 Author Posted March 18, 2017 Just now, WopsS said: Poti sa ne zici cum? Am adaugat: Total_Veh_Created = vInfo[id][vCarID]; new cCar = CreateVehicle(vInfo[Total_Veh_Created][vModel], vInfo[Total_Veh_Created][vPosX], vInfo[Total_Veh_Created][vPosY], vInfo[Total_Veh_Created][vPosZ], vInfo[Total_Veh_Created][vPosA], vInfo[Total_Veh_Created][vColor1], vInfo[Total_Veh_Created][vColor2], 500000); OwnedVeh(cCar) = Total_Veh_Created; 1
0 Administrator WopsS Posted March 18, 2017 Administrator Posted March 18, 2017 Sterge acel i de la mysql_pquery. Nu ai nevoie de el din moment ce nu transmiti nici un parametru mai departe si nici nu ai functia cu un parametru.
0 Administrator WopsS Posted March 18, 2017 Administrator Posted March 18, 2017 Si trebuie sa pui acele cache_get_value_* intr-un for ca sa treci prin toate masiniile din baza de date.
0 Mariusik Posted March 18, 2017 Author Posted March 18, 2017 (edited) 26 minutes ago, WopsS said: Si trebuie sa pui acele cache_get_value_* intr-un for ca sa treci prin toate masiniile din baza de date. for(new i = 0; i < rows; i++) de genul acesta? Edited March 18, 2017 by Mariusik
0 Administrator WopsS Posted March 18, 2017 Administrator Posted March 18, 2017 2 minutes ago, Mariusik said: for(new i = 0; i < rows; i++) de genul acesta? Da, si rows trebuie sa fie egal cu cache_get_row_count() (vezi http://wiki.sa-mp.com/wiki/MySQL/R33#cache_get_row_count sau http://wiki.sa-mp.com/wiki/MySQL/R40#cache_get_row_count).
0 Mariusik Posted March 18, 2017 Author Posted March 18, 2017 36 minutes ago, WopsS said: Da, si rows trebuie sa fie egal cu cache_get_row_count() (vezi http://wiki.sa-mp.com/wiki/MySQL/R33#cache_get_row_count sau http://wiki.sa-mp.com/wiki/MySQL/R40#cache_get_row_count). Vad ca in consola apare nr de masini din mysql, dar nu o spawuneaza, oare dc? function LoadVehicles() { new row_count; if(!cache_get_row_count(row_count)) { new id = 0; for(new i = 0; i < row_count; i++) { id++; cache_get_value_name_int(i, "CarID", vInfo[id][vCarID]); cache_get_value_name_int(i, "Model", vInfo[id][vModel]); cache_get_value_name_int(i, "Color1", vInfo[id][vColor1]); cache_get_value_name_int(i, "Color2", vInfo[id][vColor2]); cache_get_value_name_int(i, "Price", vInfo[id][vPrice]); cache_get_value_name(i, "Owner", vInfo[id][vOwner]); cache_get_value_name_float(i, "vPosX", vInfo[id][vPosX]); cache_get_value_name_float(i, "vPosY", vInfo[id][vPosY]); cache_get_value_name_float(i, "vPosZ", vInfo[id][vPosZ]); cache_get_value_name_float(i, "vPosA", vInfo[id][vPosA]); cache_get_value_name(i, "Plate", vInfo[id][vPlate]); cache_get_value_name_int(i, "PaintJ", vInfo[id][vPaintJ]); cache_get_value_name_int(i, "Locked", vInfo[id][vLocked]); cache_get_value_name_int(i, "Spawned", vInfo[id][vSpawned]); cache_get_value_name_int(i, "Destroyed", vInfo[id][vDestroyed]); cache_get_value_name_float(i, "Km", vInfo[id][vKm]); cache_get_value_name_int(i, "Neon", vInfo[id][vNeon]); cache_get_value_name_int(i, "Fuel", vInfo[id][vFuel]); cache_get_value_name_int(i, "Type", vInfo[id][vType]); cache_get_value_name_int(i, "vMod1", vInfo[id][mod1]); cache_get_value_name_int(i, "vMod2", vInfo[id][mod2]); cache_get_value_name_int(i, "vMod3", vInfo[id][mod3]); cache_get_value_name_int(i, "vMod4", vInfo[id][mod4]); cache_get_value_name_int(i, "vMod5", vInfo[id][mod5]); cache_get_value_name_int(i, "vMod6", vInfo[id][mod6]); cache_get_value_name_int(i, "vMod7", vInfo[id][mod7]); cache_get_value_name_int(i, "vMod8", vInfo[id][mod8]); cache_get_value_name_int(i, "vMod9", vInfo[id][mod9]); cache_get_value_name_int(i, "vMod10", vInfo[id][mod10]); cache_get_value_name_int(i, "vMod11", vInfo[id][mod11]); cache_get_value_name_int(i, "vMod12", vInfo[id][mod12]); cache_get_value_name_int(i, "vMod13", vInfo[id][mod13]); cache_get_value_name_int(i, "vMod14", vInfo[id][mod14]); cache_get_value_name_int(i, "vMod15", vInfo[id][mod15]); cache_get_value_name_int(i, "vMod16", vInfo[id][mod16]); cache_get_value_name_int(i, "vMod17", vInfo[id][mod17]); Total_Veh_Created = vInfo[id][vCarID]; } } for(new i = 1; i < MAX_VEHICLES; i++) OwnedVeh(i) = 0; printf("Vehicles: %d", row_count); return 1; }
0 Mariusik Posted March 18, 2017 Author Posted March 18, 2017 4 minutes ago, Banditul said: Nu exista nici un CreateVehicle in functia ta nu are legatura CreateVehicle, acest function este pentru a incarca masinile din baza de date pe server
0 Administrator WopsS Posted March 18, 2017 Administrator Posted March 18, 2017 7 minutes ago, Mariusik said: nu are legatura CreateVehicle, acest function este pentru a incarca masinile din baza de date pe server Are legatura. @Banditul are dreptate, le incarca in memorie dar nu le creeaza pe server.
0 Mariusik Posted March 18, 2017 Author Posted March 18, 2017 (edited) 4 minutes ago, WopsS said: Are legatura. @Banditul are dreptate, le incarca in memorie dar nu le creeaza pe server. function SpawnVeh(playerid, vehicle) { new carid = CreateVehicle(vInfo[vehicle][vModel], vInfo[vehicle][vPosX], vInfo[vehicle][vPosY], vInfo[vehicle][vPosZ], vInfo[vehicle][vPosA], vInfo[vehicle][vColor1], vInfo[vehicle][vColor2], 500000); SetVehicleNumberPlate(carid, vInfo[vehicle][vPlate]); ChangeVehiclePaintjob(carid, vInfo[vehicle][vPaintJ]); SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective); vInfo[vehicle][vSpawned] = 1; vUpdate(vehicle, vSpawnedx); OwnedVeh(carid) = vehicle; // Fuel[carid] = vInfo[OwnedVeh(carid)][vFuel]; // ModVehicle(carid); return 1; } am asta in gamemode Edited March 18, 2017 by Mariusik
0 Administrator WopsS Posted March 18, 2017 Administrator Posted March 18, 2017 3 minutes ago, Mariusik said: AM Rezolvat, T/C Poti sa ne zici cum?
0 Administrator WopsS Posted March 18, 2017 Administrator Posted March 18, 2017 Just now, Mariusik said: Am adaugat: Total_Veh_Created = vInfo[id][vCarID]; new cCar = CreateVehicle(vInfo[Total_Veh_Created][vModel], vInfo[Total_Veh_Created][vPosX], vInfo[Total_Veh_Created][vPosY], vInfo[Total_Veh_Created][vPosZ], vInfo[Total_Veh_Created][vPosA], vInfo[Total_Veh_Created][vColor1], vInfo[Total_Veh_Created][vColor2], 500000); OwnedVeh(cCar) = Total_Veh_Created; Merci ca ne-ai spus 1
Question
Mariusik
Am facut un sistem de tutveh, pentru versiunea de mysql R40, dar problema e ca dupa ce dau rr la server nu se incarca masinile
la OnGameModeInit
Ce nu am facut bine
14 answers to this question
Recommended Posts