27.02.2015, 18:08
Hello guys. For past days I've got new idea for my RP server. So bassically I want to create /findcarp and then input dialog pops up, you enter the number plate and pops up dialog with player stats (name, etc.)! So my problem is, how to check for car owner? This is my Player Car System:
Bassically, I don't know how to get the vehicle ID and then the cOwner...
P.S The vehicle number plate is stored at cPlate, it's completely working and randomized, saved.
Код:
#define MAX_CARS 200 enum cInfo { id, cModel, Float:cX, Float:cY, Float:cZ, Float:cFa, Float:cHeal, cFuel, cColors[16], cColor[2], cOwner[MAX_PLAYER_NAME], cLock, cCost, cVehcom[127], cVehcoms[15], cPaintjob, cPlate }; new CarInfo[MAX_CARS][cInfo];
Код:
stock LoadCars() // cars { new time = GetTickCount(); mysql_query("SELECT * FROM `"TABLE_CARS"`"); mysql_store_result(); for(new i; i < TOTALCARS; i++) { strmid(CarInfo[i][cOwner],"None_Nones",0,strlen("None_Nones"),32); } if(mysql_num_rows() > 0) { for(new idx = 1; idx <= mysql_num_rows(); idx++) { mysql_fetch_row(query); sscanf(query, "p<|>is[32]iffffifis[16]is[128]is[128]", CarInfo[idx][id], CarInfo[idx][cOwner], CarInfo[idx][cModel], CarInfo[idx][cX], CarInfo[idx][cY], CarInfo[idx][cZ], CarInfo[idx][cFa], CarInfo[idx][cFuel], CarInfo[idx][cHeal], CarInfo[idx][cCost], CarInfo[idx][cColors], CarInfo[idx][cLock], CarInfo[idx][cVehcom], CarInfo[idx][cPaintjob], CarInfo[idx][cPlate]); sscanf(CarInfo[idx][cColors], "p<,>a<i>[2]",CarInfo[idx][cColor]); sscanf(CarInfo[idx][cVehcom], "p<,>a<i>[14]",CarInfo[idx][cVehcoms]); TOTALCARS++; } } mysql_free_result(); printf(" [Masinas]: Tika ieladetas - %d speletaju auto %d (ms)", TOTALCARS,GetTickCount() - time); return 1; }
Код:
stock LoadMyCar(playerid) { if(GetPlayerHouse(playerid) == 0) return 1; if(GetPlayerCar(playerid) == 0) return 1; new c = GetPVarInt(playerid, "PlayerCars"); new carid = CreateVehicle(CarInfo[c][cModel], CarInfo[c][cX], CarInfo[c][cY], CarInfo[c][cZ], CarInfo[c][cFa], CarInfo[c][cColor][0], CarInfo[c][cColor][1], 90000); CarDoors(carid, CarInfo[c][cLock]); Fuel[carid] = CarInfo[c][cFuel]; SetVehicleNumberPlate(carid, CarInfo[c][cPlate]); SetVehicleHealth(carid, CarInfo[c][cHeal]); Engine[carid] = false; Lights[carid] = false; switch(CarInfo[c][cLock]) { case 0: IsLocked[carid] = false; case 1: IsLocked[carid] = true; } SetPVarInt(playerid,"CREVEH",carid); if(CarInfo[c][cVehcoms][0]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][0]); if(CarInfo[c][cVehcoms][1]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][1]); if(CarInfo[c][cVehcoms][2]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][2]); if(CarInfo[c][cVehcoms][3]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][3]); if(CarInfo[c][cVehcoms][4]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][4]); if(CarInfo[c][cVehcoms][5]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][5]); if(CarInfo[c][cVehcoms][6]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][6]); if(CarInfo[c][cVehcoms][7]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][7]); if(CarInfo[c][cVehcoms][8]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][8]); if(CarInfo[c][cVehcoms][9]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][9]); if(CarInfo[c][cVehcoms][10]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][10]); if(CarInfo[c][cVehcoms][11]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][11]); if(CarInfo[c][cVehcoms][12]!=0) AddVehicleComponent(carid, CarInfo[c][cVehcoms][12]); if(CarInfo[c][cVehcoms][13]!=0) AddVehicleComponent(carid,CarInfo[c][cVehcoms][13]); if(CarInfo[c][cVehcoms][14]!=0) AddVehicleComponent(carid,CarInfo[c][cVehcoms][14]); if(CarInfo[c][cPaintjob]!=0) ChangeVehiclePaintjob(carid, CarInfo[c][cPaintjob]); return true; }
P.S The vehicle number plate is stored at cPlate, it's completely working and randomized, saved.