08.09.2012, 06:27
Hello today I created a vehicle system in mysql and gives me a bug: when I enter the vehicle tells me that I do not have the keys even if they are the owner.
OnPlayerEnterVehicle:
Код:
stock vehicle_load() { new Queryve[100]; format(Queryve,sizeof(Queryve),"SELECT * FROM vehicles"); mysql_query(Queryve); mysql_store_result(); new datastr[250]; printf("---------------------------"); for(new j=0; j<mysql_num_rows();++j) { mysql_fetch_row_format(Queryve,"|"); mysql_fetch_field_row(VehicleInfo[j][vproprietario],"proprietario"); mysql_fetch_field_row(datastr,"hid"); VehicleInfo[j][vhid] = strval(datastr); mysql_fetch_field_row(datastr,"spawnx"); VehicleInfo[j][vspawnx] = strval(datastr); mysql_fetch_field_row(datastr,"spawny"); VehicleInfo[j][vspawny] = strval(datastr); mysql_fetch_field_row(datastr,"spawnz"); VehicleInfo[j][vspawnz] = strval(datastr); mysql_fetch_field_row(datastr,"spawna"); VehicleInfo[j][vspawna] = strval(datastr); mysql_fetch_field_row(datastr,"color1"); VehicleInfo[j][vcolor1] = strval(datastr); mysql_fetch_field_row(datastr,"color2"); VehicleInfo[j][vcolor2] = strval(datastr); mysql_fetch_field_row(datastr,"benzina"); VehicleInfo[j][vbenzina] = strval(datastr); mysql_fetch_field_row(datastr,"vita"); VehicleInfo[j][vvita] = strval(datastr); mysql_fetch_field_row(datastr,"conessionaria"); VehicleInfo[j][vconessionaria] = strval(datastr); mysql_fetch_field_row(datastr,"prezzo"); VehicleInfo[j][vprezzo] = strval(datastr); VehicleInfo[j][vsID] = CreateVehicle(VehicleInfo[j][vhid], VehicleInfo[j][vspawnx],VehicleInfo[j][vspawny], VehicleInfo[j][vspawnz],VehicleInfo[j][vspawna], VehicleInfo[j][vcolor1],VehicleInfo[j][vcolor1], 0); vcount++; printf("%s - %d - %s - %d - Caricato",VehicleInfo[j][vproprietario],VehicleInfo[j][vhid],GetVehicleName(VehicleInfo[j][vsID]),VehicleInfo[j][vsID]); } mysql_free_result(); printf("---------------------------"); return printf("Veicoli Caricati."); }
Код:
if(strcmp(PlayerName(playerid),VehicleInfo[vehicleid][vproprietario],false) && VehicleInfo[vehicleid][vsID] == vehicleid) { SendClientMessage(playerid, -1, "Benvenuto nella tua macchina."); return 1; } else { SendClientMessage(playerid, -1, "Non hai le chiavi di questa macchina."); RemovePlayerFromVehicle(playerid); } printf("%s - %s - %d - %d",VehicleInfo[vehicleid][vproprietario],PlayerName(playerid),VehicleInfo[vehicleid][vsID],vehicleid);
Код:
[15:16:03] My_Name - My_Name - 4 - 3 [15:16:06] My_Names - My_Name - 2 - 1 [15:16:14] My_Name - My_Name - 3 - 2 [15:16:17] M - My_Name- 0 - 4