25.06.2018, 19:08
Hello, i have a garage system in my server but i don't know why its not locking, i do /lockgarage and it say's its locked but still anyone can enter! help!!!
Код:
enum __garageInfo { garageID, Float:garageXYZ[4], Text3D:garageLabel, garageCP, bool:garageStatus, bool:garageLock, garageOwner } new Garage[MAX_GARAGE][__garageInfo]; stock createGarage(playerid) { new Float:x, Float:y, Float:z, Float:angle, query[512]; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, angle); for(new i = 0; i < MAX_GARAGE; i++) { if(!Garage[i][garageStatus]) { mysql_format(koneksi, query, sizeof(query), "INSERT INTO `garage`(`x`, `y`, `z`, `angle`, `owner`, `lock`) VALUES ('%f', '%f', '%f', '%f', '-1', '0')", x, y, z, angle); mysql_tquery(koneksi, query, "OnGarageCreated", "ddffff", playerid, i, x , y, z, angle); break; } } return 1; } forward OnGarageCreated(playerid, id, Float:x, Float:y, Float:z, Float:a); public OnGarageCreated(playerid, id, Float:x, Float:y, Float:z, Float:a) { new msg[512]; Garage[id][garageID] = cache_insert_id(); Garage[id][garageXYZ][0] = x; Garage[id][garageXYZ][1] = y; Garage[id][garageXYZ][2] = z; Garage[id][garageXYZ][3] = a; format(msg, sizeof(msg), CHAT_RED"[GARAGE]\n"CHAT_WHITE"ID : "CHAT_YELLOW"%d"CHAT_WHITE"\nLocation : "CHAT_YELLOW"%s\n$500,000\n"CHAT_WHITE"/buygarage"CHAT_YELLOW" %d", Garage[id][garageID], GetXY2DZone(x, y), id); Garage[id][garageCP] = CreateDynamicCP(x, y, z, 1.0, -1, -1); Garage[id][garageLabel] = CreateDynamic3DTextLabel(msg, COLOR_WHITE, x, y, z + 0.5, 10.0); Garage[id][garageOwner] = -1; Garage[id][garageLock] = true; Garage[id][garageStatus] = true; Info(playerid, "Garage succesfully created."); return 1; } COMMAND:creategarage(playerid, params[]) { if(!adminLevel(playerid, 5)) return 0; createGarage(playerid); return 1; } COMMAND:buygarage(playerid, params[]) { new id; if(sscanf(params, "d", id)) { Usage(playerid, "buygarage <garage id>"); } else { if(IsPlayerInDynamicCP(playerid, Garage[id][garageCP])) { if(Player[playerid][playerMoney] >= 500000) { new msg[512]; takeMoney(playerid, 500000); Garage[id][garageOwner] = Player[playerid][pID]; format(msg, sizeof(msg), CHAT_INFO"[PRESS Y TO ENTER]\n"CHAT_WHITE"ID : "CHAT_YELLOW"%d"CHAT_WHITE"\nLocation : "CHAT_YELLOW"%s\n"CHAT_WHITE"Owner :"CHAT_YELLOW" %s", Garage[id][garageID], GetXY2DZone(Garage[id][garageXYZ][0], Garage[id][garageXYZ][1]), GetName(playerid)); DestroyDynamic3DTextLabel(Garage[id][garageLabel]); Garage[id][garageLabel] = CreateDynamic3DTextLabel(msg, COLOR_WHITE, Garage[id][garageXYZ][0], Garage[id][garageXYZ][1], Garage[id][garageXYZ][2] + 0.5, 10.0); mysql_format(koneksi, msg, sizeof(msg), "UPDATE `garage` SET `owner` = '%d' where `id` = '%d'", Garage[id][garageOwner], Garage[id][garageID]); mysql_query(koneksi, msg, false); } else { if(Player[playerid][english]) Server(playerid, "You didn't have enough money to buy garage."); else Server(playerid, "Kamu tidak punya cukup uang untuk membeli garasi."); } } else { if(Player[playerid][english]) Server(playerid, "You must be in garage checkpoint to buy garage."); else Server(playerid, "Kamu harus di checkpoint untuk membeli garasi."); } } return 1; } COMMAND:exitgarage(playerid, params[]) { if(Player[playerid][lastGarage] == -1) { Server(playerid, "You're not inside garage."); } else { new i = Player[playerid][lastGarage]; if(IsPlayerInAnyVehicle(playerid)) { if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vehid = GetPlayerVehicleID(playerid); SetVehicleVirtualWorld(vehid, 0); LinkVehicleToInterior(vehid, 0); SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); foreach(new c : Player) { if(c == playerid || !IsPlayerInAnyVehicle(playerid)) continue; if(GetPlayerVehicleID© == vehid) { SetPlayerInterior(c, 0); SetPlayerVirtualWorld(c, 0); loadWorld©; } } SetVehiclePos(vehid, Garage[i][garageXYZ][0], Garage[i][garageXYZ][1], Garage[i][garageXYZ][2] + 0.5); loadWorld(playerid); } } else { SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); SetPlayerPos(playerid, Garage[i][garageXYZ][0], Garage[i][garageXYZ][1], Garage[i][garageXYZ][2] + 0.5); loadWorld(playerid); } } return 1; } COMMAND:sellgarage(playerid, params[]) { if(Player[playerid][lastGarage] == -1) { Server(playerid, "You're not inside garage."); } else { new i = Player[playerid][lastGarage]; if(Garage[i][garageOwner] == Player[playerid][pID]) { ShowPlayerDialog(playerid, DIALOG_SELLGARAGE, DIALOG_STYLE_MSGBOX, "Sell Garage", "Are you sure you want to sell this garage for $1,000,000.", "Yes", "No"); } else { Server(playerid, "You're not owner of this garage."); } } return 1; } COMMAND:lockgarage(playerid, params[]) { if(Player[playerid][lastGarage] == -1) { Server(playerid, "You're not inside garage."); } else { new i = Player[playerid][lastGarage]; if(Garage[i][garageOwner] == Player[playerid][pID]) { new msg[256]; if(!Garage[i][garageLock]) { Garage[i][garageLock] = true; mysql_format(koneksi, msg, sizeof(msg), "UPDATE `garage` SET `lock` = '1' where `id` = '%d'", Garage[i][garageID]); mysql_query(koneksi, msg, false); Info(playerid, "This garage is "CHAT_YELLOW"locked"CHAT_WHITE"."); } else { Garage[i][garageLock] = false; mysql_format(koneksi, msg, sizeof(msg), "UPDATE `garage` SET `lock` = '0' where `id` = '%d'", Garage[i][garageID]); mysql_query(koneksi, msg, false); Info(playerid, "This garage is "CHAT_RED"unlocked"CHAT_WHITE"."); } } else { Server(playerid, "You're not owner of this garage."); } } return 1; } stock loadGarage() { new query[50], Cache:garagecache; mysql_format(koneksi, query, sizeof(query), "SELECT * FROM `garage`"); garagecache = mysql_query(koneksi, query, true); new rows = cache_num_rows(koneksi); if(rows > 0) { for(new z =0; z < rows; z++) { cache_set_active(garagecache); for(new i = 0; i < MAX_GARAGE; i++) { if(Garage[i][garageStatus]) continue; new msg[512]; Garage[i][garageID] = cache_get_field_content_int(z, "id"); Garage[i][garageXYZ][0] = cache_get_field_content_float(z, "x"); Garage[i][garageXYZ][1] = cache_get_field_content_float(z, "y"); Garage[i][garageXYZ][2] = cache_get_field_content_float(z, "z"); Garage[i][garageXYZ][3] = cache_get_field_content_float(z, "angle"); Garage[i][garageOwner] = cache_get_field_content_int(z, "owner"); if(cache_get_field_content_int(z, "lock") == 0) Garage[i][garageLock] = false; else Garage[i][garageLock] = true; if(Garage[i][garageOwner] == -1) format(msg, sizeof(msg), CHAT_RED"[GARAGE]\n"CHAT_WHITE"ID : "CHAT_YELLOW"%d"CHAT_WHITE"\nLocation : "CHAT_YELLOW"%s\n$500,000\n"CHAT_WHITE"/buygarage"CHAT_YELLOW" %d", Garage[i][garageID], GetXY2DZone(Garage[i][garageXYZ][0], Garage[i][garageXYZ][1]), i); else format(msg, sizeof(msg), CHAT_INFO"[PRESS Y TO ENTER]\n"CHAT_WHITE"ID : "CHAT_YELLOW"%d"CHAT_WHITE"\nLocation : "CHAT_YELLOW"%s\n"CHAT_WHITE"Owner :"CHAT_YELLOW" %s", Garage[i][garageID], GetXY2DZone(Garage[i][garageXYZ][0], Garage[i][garageXYZ][1]), findName(Garage[i][garageOwner])); Garage[i][garageCP] = CreateDynamicCP(Garage[i][garageXYZ][0], Garage[i][garageXYZ][1], Garage[i][garageXYZ][2], 1.0, -1, -1); Garage[i][garageLabel] = CreateDynamic3DTextLabel(msg, COLOR_WHITE, Garage[i][garageXYZ][0], Garage[i][garageXYZ][1], Garage[i][garageXYZ][2] + 0.5, 10.0); Garage[i][garageStatus] = true; break; } garagecache = cache_save(); } } return 1; }