21.11.2014, 16:16
Hello again. Today I tryed to make MySQL car system. Actualy I made that system. There is a code:
First of all, what do you think, is it good system?
And I want to make a lock system, but I dont know how to make it. Can someone help me?
Thanks a lot!
Код HTML:
enum cInfo { Id, Owner[MAX_PLAYER_NAME], Model, Float:X, Float:Y, Float:Z, Float:Angle, Color, Color, VehId }; new Car[MAX_PLAYERS][cInfo]; stock LoadcInfo(playerid) { new name[MAX_PLAYER_NAME],query[254]; GetPlayerName(playerid,name,sizeof(name)); mysql_real_escape_string(name,name); format(query,sizeof(query),"SELECT * FROM cars WHERE Owner = '%s'",name); mysql_function_query(dbhandle,query,true,"LoadCars","i",playerid); return 1; } forward LoadCars(playerid); public LoadCars(playerid) { new rows,fields; cache_get_data(rows,fields); if(rows == 1) { new tmp[64]; cache_get_row(0,0,tmp); Car[playerid][Id] = strval(tmp); cache_get_row(0,1, Car[playerid][Owner]); cache_get_row(0,2,tmp); Car[playerid][Model] = strval(tmp); cache_get_row(0,3,tmp); Car[playerid][X] = floatstr(tmp); cache_get_row(0,4,tmp); Car[playerid][Y] = floatstr(tmp); cache_get_row(0,5,tmp); Car[playerid][Z] = floatstr(tmp); cache_get_row(0,6,tmp); Car[playerid][Angle] = floatstr(tmp); cache_get_row(0,7,tmp); Car[playerid][Color] = strval(tmp); cache_get_row(0,8,tmp); Car[playerid][Color2] = strval(tmp); Car[playerid][VehId] = CreateVehicle(Car[playerid][Model],Car[playerid][X],Car[playerid][Y],Car[playerid][Z],Car[playerid][Angle],Car[playerid][Color],Car[playerid][Color2],-1); } else Car[playerid][VehId] = INVALID_VEHICLE_ID; mysql_free_result(); return 1; } stock SaveCars(playerid) { new query[128]; if(Car[playerid][VehId] == INVALID_VEHICLE_ID) return 1; new Float:pos[3]; GetVehicleZAngle(Car[playerid][VehId], Car[playerid][Angle]); GetVehiclePos(Car[playerid][VehId],pos[0],pos[1],pos[2]); format(query,sizeof(query),"UPDATE cars SET PosX=%f,PosY=%f,PosZ=%f,Angle=%f WHERE Id=%d", pos[0],pos[1],pos[2],Car[playerid][Angle],Car[playerid][Id]); mysql_function_query(dbhandle,query,false,"",""); DestroyVehicle(Car[playerid][VehId]); return 1; }
And I want to make a lock system, but I dont know how to make it. Can someone help me?
Thanks a lot!