- Автор темы
- #1
Такая проблема.
Я могу спавнить несколько раз личные машины.
Мод Desmond.
Вот сам код спавна машины:
Я могу спавнить несколько раз личные машины.
Мод Desmond.
Вот сам код спавна машины:
Код:
CMD:car(playerid, params[])
{
if(GetPlayerOwnableCar(playerid) != INVALID_VEHICLE_ID)
{
Dialog
(
playerid, DIALOG_OWNABLE_CAR, DIALOG_STYLE_LIST,
"{"#cGold"}Óïðàâëåíèå òðàíñïîðòîì",
"{"#cW"}1. Îòêðûòü / çàêðûòü òðàíñïîðò\n"\
"{"#cW"}2. Âñòàâèòü / âûòàùèòü êëþ÷è\n"\
"{"#cW"}3. Îòìåòèòü òðàíñïîðò íà {"#cGold"}GPS {"#cW"}(300 ðóá)\n"\
"{"#cW"}4. Äîêóìåíòû íà òðàíñïîðò\n"\
"{"#cW"}5. Ïðèïàðêîâàòü òðàíñïîðò\n"\
"{FF6600}Âûãðóçèòü òðàíñïîðò ñ ñåðâåðà",
"Âûáðàòü", "Çàêðûòü"
);
}
else
{
new fmt_text[640],
Cache: result,
id;
mysql_format(mysql, fmt_text, sizeof fmt_text, "SELECT * FROM ownable_cars WHERE owner_id='%d'", GetPlayerAccountID(playerid));
result = mysql_query(mysql, fmt_text, true);
new rows = cache_num_rows();
if(!rows)
SendClientMessage(playerid, 0xFF6600FF, "Ó Âàñ íåò ëè÷íîãî òðàíñïîðòà");
else
{
if(rows == 1)
{
id = cache_get_field_content_int(0, "id");
ShowOwnableCarLoadDialog(playerid, id);
}
else
{
new query[60],
model_id,
car_number[7];
format(fmt_text, sizeof fmt_text, "{"#cW"}Òðàíñïîðò\t\t{"#cW"}Íîìåðíîé çíàê\n");
for(new i = 0; i < rows; i ++)
{
id = cache_get_field_content_int(i, "id");
model_id = cache_get_field_content_int(i, "model_id") - 400;
cache_get_field_content(i, "number", car_number);
format(query, sizeof query, "{"#cW"}%d. %s\t\t{"#cGold"}%s\n", i + 1, GetVehicleInfo(model_id, VI_NAME), car_number);
strcat(fmt_text, query);
SetPlayerListitemValue(playerid, i, id);
}
Dialog
(
playerid, DIALOG_OWNABLE_CAR_LIST, DIALOG_STYLE_TABLIST_HEADERS,
"{"#cGold"}Ëè÷íûé òðàíñïîðò",
fmt_text,
"Âûáðàòü", "Çàêðûòü"
);
}
}
cache_delete(result);
}
return 1;
}
Код:
stock ShowOwnableCarLoadDialog(playerid, id, bool: show_menu = false)
{
SetPVarInt(playerid, "ownablecar_id", id);
if(show_menu)
SetPVarInt(playerid, "show_menu", 1);
Dialog
(
playerid, DIALOG_OWNABLE_CAR_LOAD, DIALOG_STYLE_LIST,
"{FFD83D}Ñèñòåìà óïðàâëåíèÿ òðàíñïîðòîì",
"1. Îòìåòèòü òðàíñïîðò íà GPS {FF6600}(300 ðóá)\n"\
"{888888}2. Çàãðóçèòü òðàíñïîðò",
"Âûáðàòü", "Çàêðûòü"
);
}
Код:
case DIALOG_OWNABLE_CAR_LOAD:
{
if(response)
{
new idx = GetPVarInt(playerid, "ownablecar_id"),
Float: x,
Float: y,
Float: z,
Cache: result,
query[100];
mysql_format(mysql, query, sizeof query, "SELECT pos_x, pos_y, pos_z FROM ownable_cars WHERE id='%d'", idx);
result = mysql_query(mysql, query, true);
if(cache_num_rows())
{
x = cache_get_row_float(0, 0);
y = cache_get_row_float(0, 1);
z = cache_get_row_float(0, 2);
}
cache_delete(result);
switch(listitem + 1)
{
case 1:
{
if(GetPlayerGPSInfo(playerid, G_ENABLED) == GPS_STATUS_OFF)
{
if(GetPlayerMoneyEx(playerid) >= 300)
{
GivePlayerMoneyEx(playerid, -300, "Ìåòêà ÒÑ íà GPS", true, true);
EnablePlayerGPS(playerid, 55, x, y, z, "Ìåñòîïîëîæåíèå Âàøåãî òðàíñïîðòà îòìå÷åíî íà GPS");
return 1;
}
else SendClientMessage(playerid, 0xFF6600FF, "Íåäîñòàòî÷íî äåíåã");
}
else SendClientMessage(playerid, 0xFF6600FF, "Íà Âàøåì GPS óæå îòìå÷åíî ìåñòî");
}
case 2:
{
if(GetPlayerOwnableCar(playerid) != INVALID_VEHICLE_ID)
{
SendClientMessage(playerid, 0xFF6600FF, "Ñèñòåìíàÿ îøèáêà. Òðàíñïîðò óæå çàãðóæåí.");
return 1;
}
if(!IsPlayerInRangeOfPoint(playerid, 45.0, x, y, z))
{
SendClientMessage(playerid, 0xFF6600FF, "Âû ñëèøêîì äàëåêî îò ìåñòà, ãäå ïðèïàðêîâàí Âàø òðàíñïîðò");
}
else
{
if(LoadOwnableCar(idx) != -1)
{
PlayerOwnableCarInit(playerid);
SendClientMessage(playerid, 0x66CC33FF, "Âàø òðàíñïîðò óñïåøíî çàãðóæåí!");
}
else SendClientMessage(playerid, 0xFF6600FF, "Îøèáêà ïðè çàãðóçêå ëè÷íîãî òðàíñïîðòà");
}
}
}
}
else
{
if(GetPVarInt(playerid, "show_menu"))
{
DeletePVar(playerid, "show_menu");
callcmd::car(playerid, "");
}
}
}
Код:
public: PlayerOwnableCarInit(playerid)
{
new index;
new vehicleid = -1;
while(vehicleid < MAX_VEHICLES-1)
{
vehicleid ++;
index = GetVehicleData(vehicleid, V_ACTION_ID);
if(GetVehicleData(vehicleid, V_ACTION_TYPE) != VEHICLE_ACTION_TYPE_OWNABLE_CAR) continue;
if(GetOwnableCarData(index, OC_OWNER_ID) != GetPlayerAccountID(playerid)) continue;
SetPlayerData(playerid, P_OWNABLE_CAR, vehicleid);
break;
}
}