05.09.2017, 09:19
Quote:
I'm not downloading anything. Post the related code on the forums.
|
Код:
YCMD:siren(playerid, params[], help) { new carid = GetPlayerVehicleID(playerid); if(carid == INVALID_VEHICLE_ID || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessage(playerid, X11_TOMATO_2, "* You must be in a vehicle!"); return 1; } if(!IsAnLEO(playerid)) { SendClientMessage(playerid, X11_TOMATO_2, "You aren't a cop!"); return 1; } if(!IsOnDuty(playerid)) { SendClientMessage(playerid, X11_TOMATO_2, "You are not on duty!"); return 1; } AddVehicleCarToy(carid, 0, 1); return 1; } YCMD:buycartoy(playerid, params[], help) { new carid = GetPlayerVehicleID(playerid); if(carid == INVALID_VEHICLE_ID || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessage(playerid, X11_TOMATO_2, "* You must be in a vehicle!"); return 1; } new dps = IsPlayerInRangeOfPoint(playerid, 5.0, 1264.86, -1669.73, 13.54); new job = GetPVarInt(playerid, "Job"); if(job != EJobType_Mechanic && !dps) { SendClientMessage(playerid, X11_TOMATO_2, "You must be a mechanic for this!"); return 1; } if(VehicleInfo[carid][EVType] != EVehicleType_Owned) { SendClientMessage(playerid, X11_TOMATO_2, "* You can only use this on owned vehicles"); return 1; } ShowCarToyBuyMenu(playerid, dps); return 1; } DestroyCarToy(objid, sqldelete = 1) { new carid; new obj = findCarToyByObjID(objid,carid); if(obj == -1) return 0; VehicleCarToys[carid][obj][EVehCarToy_ObjID] = 0; if(VehicleCarToys[carid][obj][EVehCarToy_SQLID] > 0 && sqldelete) { format(query, sizeof(query), "DELETE FROM `playercartoys` WHERE `id` = %d",VehicleCarToys[carid][obj][EVehCarToy_SQLID]); mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", ""); } VehicleCarToys[carid][obj][EVehCarToy_SQLID] = 0; DestroyDynamicObject(objid); return 1; } findCarToyByObjID(objid, &carid = 0) { carid = INVALID_VEHICLE_ID; for(new i=0;i<MAX_VEHICLES;i++) { for(new x=0;x<MAX_CAR_TOYS_PER_CAR;x++) { if(VehicleCarToys[i][x][EVehCarToy_ObjID] == objid) { carid = i; return x; } } } return -1; } findFreeCarToySlot(carid) { for(new i=0;i<MAX_CAR_TOYS_PER_CAR;i++) { if(VehicleCarToys[carid][i][EVehCarToy_ObjID] == 0 && VehicleCarToys[carid][i][EVehCarToy_SQLID] == 0) { return i; } } return -1; } SaveVehicleCarToy(carid, toyidx, update) { if(update) { format(query, sizeof(query), "UPDATE `playercartoys` SET `X` = %f, `Y` = %f, `Z` = %f, `RX` = %f, `RY` = %f, `RZ` = %f WHERE `id` = %d",VehicleCarToys[carid][toyidx][EVehCarToy_X],VehicleCarToys[carid][toyidx][EVehCarToy_Y],VehicleCarToys[carid][toyidx][EVehCarToy_Z],VehicleCarToys[carid][toyidx][EVehCarToy_RX],VehicleCarToys[carid][toyidx][EVehCarToy_RY],VehicleCarToys[carid][toyidx][EVehCarToy_RZ],VehicleCarToys[carid][toyidx][EVehCarToy_SQLID]); } else { format(query, sizeof(query), "INSERT INTO `playercartoys` SET `X` = %f, `Y` = %f, `Z` = %f, `RX` = %f, `RY` = %f, `RZ` = %f, `carid` = %d, `toyidx` = %d",VehicleCarToys[carid][toyidx][EVehCarToy_X],VehicleCarToys[carid][toyidx][EVehCarToy_Y],VehicleCarToys[carid][toyidx][EVehCarToy_Z],VehicleCarToys[carid][toyidx][EVehCarToy_RX],VehicleCarToys[carid][toyidx][EVehCarToy_RY],VehicleCarToys[carid][toyidx][EVehCarToy_RZ],GetVehicleSQLID(carid),VehicleCarToys[carid][toyidx][EVehCarToy_ToyIdx]); } mysql_function_query(g_mysql_handle, query, true, "OnSaveCarToy", "ddd", carid, toyidx, update); } forward OnSaveCarToy(carid, toyidx, update); public OnSaveCarToy(carid, toyidx, update) { new id = mysql_insert_id(); if(!update) { VehicleCarToys[carid][toyidx][EVehCarToy_SQLID] = id; } }
Код:
YCMD:cartoys(playerid, params[], help) { new carid = GetPlayerVehicleID(playerid); if(carid == INVALID_VEHICLE_ID || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) { SendClientMessage(playerid, X11_TOMATO_2, "* You must be in a vehicle!"); return 1; } ShowPlayerDialog(playerid, ECarToys_ToyActionMenu, DIALOG_STYLE_LIST, "Car Toy Action Menu","Edit Toy\nDelete Toy\n","Select", "Cancel"); return 1; } ShowCarToyEditMenu(playerid) { new carid = GetPlayerVehicleID(playerid); if(carid == INVALID_VEHICLE_ID) { SendClientMessage(playerid, X11_TOMATO_2, "You must be in a vehicle!"); return 1; } tempstr[0] = 0; dialogstr[0] = 0; for(new i=0;i<MAX_CAR_TOYS_PER_CAR;i++) { if(VehicleCarToys[carid][i][EVehCarToy_ObjID] != 0) { format(tempstr, sizeof(tempstr), "%s\n",CarToys[VehicleCarToys[carid][i][EVehCarToy_ToyIdx]][ECarToy_Name]); strcat(dialogstr, tempstr, sizeof(dialogstr)); } } ShowPlayerDialog(playerid, ECarToys_EditMenu, DIALOG_STYLE_LIST, "Select Car Toy",dialogstr,"Select", "Cancel"); return 1; }