Jump to content

Sergey_Walter

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by Sergey_Walter

  1. Воу воу парень палехче Во первых доброе утро! Во вторых кликая по любому элементу срабатывает функция onPlayerClick - onClientGUIClick В третьих глобальные переменные можно создавать через функцию setElementData - getElementData В четвёртых команда /time находится на стороне клиента у всех, в скрипте commands_client.lua
  2. Да я вот боюсь он будет нагружать клиентскую сторону, так как он на рендере... Код воще жёсткий =) sx,sy = guiGetScreenSize() function wantNeon(state) if state == true then addEventHandler("onClientPreRender",root,loop) else removeEventHandler("onClientPreRender",root,loop) end end function loop() for i,veh in ipairs(getElementsByType("vehicle")) do x,y,z = getElementPosition(veh) a,b,c = getElementPosition(getLocalPlayer()) dis = getDistanceBetweenPoints3D(x,y,z,a,b,c) vis = isElementOnScreen(veh) if vis and dis < 50 then x,y,rot = getElementRotation(veh) if x < 50 or x > 310 then if y < 50 or y > 310 then if getElementData(veh,"neonlight") ~= "off!!!" then drawIt(veh,rot) end end end end end end addEventHandler("onClientPreRender",root,loop) function drawIt(veh,rot) x,y,z = getElementPosition(veh) az = getGroundPosition(x,y,z) dis = getDistanceBetweenPoints3D(x,y,z,x,y,az) if dis < 2 then a = 100 model = getElementModel(veh) data = getElementData(veh,"neonlight") if data then r = tonumber(gettok(data,1,string.byte(","))) g = tonumber(gettok(data,2,string.byte(","))) b = tonumber(gettok(data,3,string.byte(","))) ck = tonumber(gettok(data,4,string.byte(","))) --if ck and ck <= 255 and ck >= 0 then a = ck end rot = rot if --rot < 1 or rot > 359 1 == 1 then rx,ry,rz = getElementRotation(veh) x,y,z = getElementPosition(veh) r3 = rz-30 r4 = rz-150 r3 = math.abs(r3-360) r4 = math.abs(r4-360) r1 = r3-60 r2 = r4-300 r1 = math.rad(r1) r2 = math.rad(r2) r3 = math.rad(r3) r4 = math.rad(r4) cr1 = math.cos(r1) sr1 = math.sin(r1) cr2 = math.cos(r2) sr2 = math.sin(r2) cr3 = math.cos(r3) sr3 = math.sin(r3) cr4 = math.cos(r4) sr4 = math.sin(r4) x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.03*cr1 sr1 = 1.03*sr1 cr2 = 1.03*cr2 sr2 = 1.03*sr2 cr3 = 1.03*cr3 sr3 = 1.03*sr3 cr4 = 1.03*cr4 sr4 = 1.03*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x y1 = cr1+y x2 = sr2+x y2 = cr2+y x3 = sr3+x y3 = cr3+y x4 = sr4+x y4 = cr4+y az1 = getGroundPosition(x1,y1,z+2) az2 = getGroundPosition(x2,y2,z+2) az3 = getGroundPosition(x3,y3,z+2) az4 = getGroundPosition(x4,y4,z+2) dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3) dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3) cr1 = 1.02*cr1 sr1 = 1.02*sr1 cr2 = 1.02*cr2 sr2 = 1.02*sr2 cr3 = 1.02*cr3 sr3 = 1.02*sr3 cr4 = 1.02*cr4 sr4 = 1.02*sr4 x1 = sr1+x
  3. Как вы думаете что лучше, поставить этот неон: https://community.multitheftauto.com/in ... ls&id=1833 http://screenshot.su/show.php?img=65436 ... 7db6a3.jpg или вырезать dff, txd неона из сампа и заменить ненужные обьекты в мта этим неоном? http://screenshot.su/show.php?img=20330 ... 0048b9.jpg Беда в том что самповский неон горит только после 21.00 или при определённой погоде
  4. exports["savevehicle-system"]:saveVehicleMods(vehicle) правда что такой экспорт не работает со стороны клиента?
  5. Аа ну я так и сделал =)
  6. local color1, color2, color3, color4 = getVehicleColor ( theVehicle ) а где тут rgb? color1,color2,color3 здесь?
  7. а это не оно? function hsv2rgb(h, s, v) local r, g, b local i = math.floor(h * 6) local f = h * 6 - i local p = v * (1 - s) local q = v * (1 - f * s) local t = v * (1 - (1 - f) * s) local switch = i % 6 if switch == 0 then r = v g = t b = p elseif switch == 1 then r = q g = v b = p elseif switch == 2 then r = p g = v b = t elseif switch == 3 then r = p g = q b = v elseif switch == 4 then r = t g = p b = v elseif switch == 5 then r = v g = p b = q end return math.floor(r*255), math.floor(g*255), math.floor(b*255) end function rgb2hsv(r, g, b) r, g, b = r/255, g/255, b/255 local max, min = math.max(r, g, b), math.min(r, g, b) local h, s local v = max local d = max - min s = max == 0 and 0 or d/max if max == min then h = 0 elseif max == r then h = (g - b) / d + (g < b and 6 or 0) elseif max == g then h = (b - r) / d + 2 elseif max == b then h = (r - g) / d + 4 end h = h/6 return h, s, v end
  8. Возможно ли узнать цвет автомобиля через getVehicleColor ( theVehicle ) и превратить в такой код #ffffff ?
  9. function openPicker(id, start, title) if id and not pickerTable[id] then pickerTable[id] = colorPicker.create(id, start, title) pickerTable[id]:updateColor() return true end return false end addEvent( "openPicker", true ) addEventHandler ( "openPicker", openPicker ) local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) function picker() local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end addEventHandler ( "onColShapeHit", sphere, picker ) так? чёто не срабатывает всё равно( это на стороне клиента..
  10. local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) function picker( thePlayer, matchingDimension) if getElementType ( thePlayer ) == "player" then local theVehicle = getPedOccupiedVehicle(thePlayer) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end end addEventHandler ( "onColShapeHit", sphere, picker ) сделал так пишет: http://screenshot.su/show.php?img=a1387 ... b07363.jpg
  11. Не очень хорошо обьяснил, ну ладно, возможно ли этот же код реализовать на стороне клиента? Так как функция openPicker находится там же... Или может сделать так? https://wiki.multitheftauto.com/wiki/OnColShapeHit
  12. local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) addEventHandler("onColShapeHit", sphere, function() local theVehicle = getPedOccupiedVehicle(???) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end) Помогите узнать ид элемента игрока на стороне сервера... Да и почему этот же код нельзя использовать на стороне клиента? Он попросту у меня не срабатывает..
  13. local login = "Никогда" if (not memberLastLogin[k]) then login = "Никогда" else if (memberLastLogin[k]==0) then login = "Сегодня" else login = "" .. memberLastLogin[k] .. " ".. math.decl( memberLastLogin[k], "день назад", "дня назад", "дней назад" ) end end Сдела так, всё чики пуки терь, спс
  14. local login = "Никогда" if (not memberLastLogin[k]) then login = "Никогда" else if (memberLastLogin[k]==0) then login = "Сегодня" elseif (memberLastLogin[k]==1) then login = tostring(memberLastLogin[k]) .. " день назад" elseif (memberLastLogin[k]==2 or memberLastLogin[k] == 3 or memberLastLogin[k] == 4) then login = tostring(memberLastLogin[k]) .. " дня назад" else login = tostring(memberLastLogin[k]) .. " дней назад" end end guiGridListSetItemText(gMemberGrid, row, colLastLogin, login, false, false) Подскажите как сделать чтоб например на числа 2,3,4 ДАЛЕЕ +10 дней, тоесть 22 дня, 23 дня, 24 дня, писало дня, мне кажется что то там типо gsuba надо сделать... заранее спасибо)
  15. Да действительно эта функция помогает удалять и пикапы и иконки, буду изучать эти древа элементов =)
  16. Ну вот, если я например сделаю так, local interiorElement = createElement("interior", "int"..tostring(row.id)) setElementDataEx(interiorElement, "dbid", row.id, true) setElementDataEx(interiorElement, "entrance", { row.x, row.y, row.z, row.interiorwithin, row.dimensionwithin, row.angle, row.fee }, true ) setElementDataEx(interiorElement, "exit", { row.interiorx, row.interiory, row.interiorz, row.interior, row.id, row.angleexit, 0 }, true ) setElementDataEx(interiorElement, "status", { row.type, row.disabled == 1, row.locked == 1, row.owner, row.cost, row.supplies}, true ) setElementDataEx(interiorElement, "name", row.name, true ) if row.owner == -1 then local blip = createBlip(row.x, row.y, 10, 31, 2, 255, 0, 0, 255, 0, 180) setElementData ( interiorElement, "blip", blip ) elseif row.owner > 0 then local blip = createBlip(row.x, row.y, 10, 32, 2, 255, 0, 0, 255, 0, 180) setElementData ( interiorElement, "blip", blip ) end и удалю этот элемент, destroyElement(interiorElement) то всё что в нём хранилось, данные и иконка на радаре удалится?
  17. for i = 1, 150 do for x = 1, 4 do onZone = { } onZone[i] = { } onZone[i][x] = 0 end end Так можно делать? У меня как никрути вылазит эти ошибки.. http://screenshot.su/show.php?img=de6e3 ... 917873.jpg Мне просто нужно записать в эту строку два значения, onZone[faction] = onZone[faction] + 1 там где i индекс гангзоны, там где faction номер банды, и к этому нужно прибавить единицу в зависимости сколько там стоит человек..
  18. Вот мой скрипт системы гангзон.. mysql = exports.mysql local null = mysql_null() local toLoad = { } local threads = { } local zoneInfo = { } local frakCD = { } local onZone = { } function resume() for key, value in ipairs(threads) do coroutine.resume(value) end end function loadAllGangZones() local result = mysql:query("SELECT id FROM gangzones ORDER BY `id` ASC") if result then while true do local row = mysql:fetch_assoc(result) if not row then break end toLoad[tonumber(row["id"])] = true end mysql:free_result(result) for id in pairs( toLoad ) do local co = coroutine.create(loadOneGangZone) coroutine.resume(co, id, true) table.insert(threads, co) end setTimer(resume, 1000, 4) setTimer(gzCheck, 1000, 0) for i = 1, 4 do frakCD[i] = 0 end else outputDebugString( "loadAllGangZones failed" ) end end addEventHandler("onResourceStart", getResourceRootElement(), loadAllGangZones) function loadOneGangZone(id, hasCoroutine) if (hasCoroutine==nil) then hasCoroutine = false end local row = mysql:query_fetch_assoc("SELECT * FROM gangzones WHERE id = " .. mysql:escape_string(id) .. " LIMIT 1" ) if row then if (hasCoroutine) then coroutine.yield() end for k, v in pairs( row ) do if v == null then row[k] = nil else row[k] = tonumber(row[k]) or row[k] end end zoneInfo[row.id] = { ["x"] = row.x, ["y"] = row.y, ["zoneBattle"] = false, ["safeTime"] = 0, ["zoneTimer"] = 0, ["gangNapad"] = 0 } zoneInfo[row.id]["colShape"] = createColRectangle(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], 100.0, 100.0) if row.faction == 1 then zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], 100.0, 100.0, 0, 255, 255, 175) elseif row.faction == 2 then zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], 100.0, 100.0, 52, 201, 36, 175) elseif row.faction == 3 then zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], 100.0, 100.0, 255, 0, 255, 175) elseif row.faction == 4 then zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], 100.0, 100.0, 255, 165, 0, 175) end setElementData ( zoneInfo[row.id]["colShape"], "faction", row.faction ) setElementData ( zoneInfo[row.id]["colShape"], "type", "turf" ) setElementData ( zoneInfo[row.id]["colShape"], "ID", row.id) addEventHandler("onColShapeHit", getRootElement(), function(player) if(getElementData(source, "type") == "turf") then local id = getElementData(source, "ID") if(getPlayerTurf(player) == id) then setElementData(player, "turfID", id) end end end) end end function capture( thePlayer ) local gangid = getElementData(thePlayer, "turfID") if isInAllowed(thePlayer) ~= 0 then outputChatBox ("#ff0500x #ffffffВы не можете атаковать банды", thePlayer, 0,0,0, true) return true end --if frakCD[getElementData( thePlayer, "faction" )] > 0 then --outputChatBox ("#ff0500x #ffffffВаша банда уже атакует одну гангзону, подождите ".. math.floor(frakCD[getElementData( thePlayer, "faction" )] / 60) .." минут", thePlayer, 0,0,0, true) --return true --end if(getPlayerTurf(thePlayer) ~= gangid) then outputChatBox ("#ff0500x #ffffffВы не находитесь на територии банды", thePlayer, 0,0,0, true) return true end --if isPlayerInBandOnline(gangid) then -- outputChatBox ("#ff0500x #ffffffЗону банды которую вы хотите атаковать нет в онлайне", thePlayer, 0,0,0, true) -- return true -- end outputChatBox ("#ff0500x #ffffffВы начали захват гангзоны", thePlayer, 0,0,0, true) setRadarAreaFlashing ( zoneInfo[gangid]["radarArea"], true ) frakCD[getElementData( thePlayer, "faction" )] = 1800 zoneInfo[gangid]["zoneBattle"] = true zoneInfo[gangid]["safeTime"] = 10 zoneInfo[gangid]["zoneTimer"] = 200 zoneInfo[gangid]["gangNapad"] = getElementData(thePlayer, "faction") triggerClientEvent(thePlayer, "showGangText", getRootElement(), true) end addCommandHandler ( "capture", capture ) function gzcolor( thePlayer, command, gangid ) destroyElement(zoneInfo[getPlayerTurf(thePlayer)]["radarArea"]) mysql:query_free("UPDATE gangzones SET `faction` = '".. gangid .."' WHERE id='" .. getPlayerTurf(thePlayer) .. "'") loadOneGangZone(getPlayerTurf(thePlayer)) end addCommandHandler ( "gzcolor", gzcolor, gangid ) function isInAllowed( thePlayer ) local theTeam = getPlayerTeam( thePlayer ) local factionType = getElementData( theTeam, "type" ) return factionType end function isPlayerInBandOnline(gangid) local players = exports.pool:getPoolElementsByType("player") for k, arrayPlayer in ipairs(players) do if getElementData( arrayPlayer, "faction" ) == getElementData( zoneInfo[gangid]["colShape"], "faction" ) then return false end end return true end function getPlayerTurf(player) local x, y, _ = getElementPosition(player) for i, _ in ipairs(zoneInfo) do if(x >= zoneInfo[i]["x"] and y >= zoneInfo[i]["y"] and x <= (zoneInfo[i]["x"]+100.0) and y <= (zoneInfo[i]["y"]+100.0)) then return i end end return -1 end function gzCheck() local players = exports.pool:getPoolElementsByType("player") local kol1 = 0 local kol2 = 0 for x,_ in ipairs(frakCD) do if frakCD[x] > 0 then frakCD[x] = frakCD[x] - 1 end end for i,_ in pairs(zoneInfo) do if zoneInfo[i]["safeTime"] > 0 then zoneInfo[i]["safeTime"] = zoneInfo[i]["safeTime"] - 1 end if zoneInfo[i]["zoneBattle"] == true and zoneInfo[i]["safeTime"] == 0 then zoneInfo[i]["zoneTimer"] = zoneInfo[i]["zoneTimer"] - 5 if zoneInfo[i]["zoneTimer"] <= 0 then sendFamilyMessage (zoneInfo[i]["gangNapad"], getElementData( zoneInfo[i]["colShape"], "faction" ), "#ff0500x #ffffffВремя на захват зоны вышел. Ничья" ) zoneInfo[i]["zoneBattle"] = false setRadarAreaFlashing ( zoneInfo[i]["radarArea"], false ) for k, arrayPlayer in ipairs(players) do local faction = getElementData(arrayPlayer, "faction") if faction == getElementData( zoneInfo[i]["colShape"], "faction" ) or faction == zoneInfo[i]["gangNapad"] then triggerClientEvent(arrayPlayer, "showGangText", getRootElement(), false) end end end for k, arrayPlayer in ipairs(players) do local faction = getElementData(arrayPlayer, "faction") if getPlayerTurf(arrayPlayer) == i and isInAllowed(arrayPlayer) == 0 and faction == getElementData( zoneInfo[i]["colShape"], "faction" ) or faction == zoneInfo[i]["gangNapad"] then local faction = getElementData(arrayPlayer, "faction") onZone[i][faction] = onZone[i][faction] + 1 end end local asd = 0 for x,_ in ipairs(onZone) do if onZone[i][x] > 0 then asd = asd + 1 end end if asd == 1 then for x,_ in ipairs(onZone) do if onZone[i][x] > 0 then if getElementData( zoneInfo[i]["colShape"], "faction" ) == x then sendFamilyMessage (zoneInfo[i]["gangNapad"], getElementData( zoneInfo[i]["colShape"], "faction" ), "#ff0500x #ffffffБанда ".. GetGangName(getElementData( zoneInfo[i]["colShape"], "faction" )) .." отстояла свою территорию" ) else sendFamilyMessage (zoneInfo[i]["gangNapad"], getElementData( zoneInfo[i]["colShape"], "faction" ), "#ff0500x #ffffffБанда ".. GetGangName(zoneInfo[i]["gangNapad"]) .." выигрывает войну за территорию" ) end for k, arrayPlayer in ipairs(players) do local faction = getElementData(arrayPlayer, "faction") if faction == getElementData( zoneInfo[i]["colShape"], "faction" ) or faction == zoneInfo[i]["gangNapad"] then triggerClientEvent(arrayPlayer, "showGangText", getRootElement(), false) end end zoneInfo[i]["zoneBattle"] = false zoneInfo[i]["zoneTimer"] = 0 onZone[i][x] = 0 mysql:query_free("UPDATE gangzones SET `faction` = '".. x .."' WHERE id='" .. i .. "'") setRadarAreaFlashing ( zoneInfo[i]["radarArea"], false ) destroyElement(zoneInfo[i]["radarArea"]) loadOneGangZone(i) break end end end end if zoneInfo[i]["zoneBattle"] == true then for k, arrayPlayer in ipairs(players) do local faction = getElementData(arrayPlayer, "faction") if faction == getElementData( zoneInfo[i]["colShape"], "faction" ) or faction == zoneInfo[i]["gangNapad"] then triggerClientEvent(arrayPlayer, "showGangText", getRootElement(), true) if faction == getElementData( zoneInfo[i]["colShape"], "faction" ) and getPlayerTurf(arrayPlayer) == i then kol1 = kol1 + 1 end if faction == zoneInfo[i]["gangNapad"] and getPlayerTurf(arrayPlayer) == i then kol2 = kol2 + 1 end triggerClientEvent(arrayPlayer, "varText", getRootElement(), kol1, kol2, GetGangName(getElementData( zoneInfo[i]["colShape"], "faction" )), GetGangName(zoneInfo[i]["gangNapad"]), zoneInfo[i]["safeTime"]) end end end end end function sendFamilyMessage(gangnapad, gangvlad, text) local players = exports.pool:getPoolElementsByType("player") for k, arrayPlayer in ipairs(players) do if getElementData(arrayPlayer, "faction") == gangnapad or getElementData(arrayPlayer, "faction") == gangvlad then outputChatBox (text, arrayPlayer, 0,0,0, true) end end end function GetGangName(gangid) local string if gangid == 1 then string = "Los Santos Aztecaz" end if gangid == 2 then string = "Groove Street" end if gangid == 3 then string = "The Ballas Gang" end if gangid == 4 then string = "Los Santos Vagos Gang" end return string end
  19. Как сделать в луа двумерный массив на подобие павновского: new OnZONE[150][24]; например чтоб использовать его в цикле: onZone[i][faction] = onZone[i][faction] + 1 вместо павновского: OnZONE[i][faction] ++; Помогите плиз, всю голову сломал, раньше как-то получалось, нечаянно скрипт удалил и всё забыл =(
  20. Да, да Vamp1r ты прав.. У мну на самповском моде зоны на проверку по позиции было. Flaker, я вижу ты за оптимизацию, я тоже, но иногда бывают безысходные ситуации даже в самом лучшем на мой взгляд по функциям программирования мта
  21. isElementWithinColShape срабатывает не корректно при переходе с одной зоны в другую, что то её перебивает и она не успевает сработать =( Пришлось использовать пример Vamp1r.
  22. Всё, всем огромное спасибо, оба помогли! запилил так: function loadOneGangZone(id, hasCoroutine) if (hasCoroutine==nil) then hasCoroutine = false end local row = mysql:query_fetch_assoc("SELECT * FROM gangzones WHERE id = " .. mysql:escape_string(id) .. " LIMIT 1" ) if row then if (hasCoroutine) then coroutine.yield() end for k, v in pairs( row ) do if v == null then row[k] = nil else row[k] = tonumber(row[k]) or row[k] end end zoneInfo[row.id] = { ["x"] = row.x, ["y"] = row.y, ["width"] = 100.0, ["height"] = 100.0 } zoneInfo[row.id]["colShape"] = createColRectangle(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], zoneInfo[row.id]["width"], zoneInfo[row.id]["height"]) if row.faction == 1 then zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], zoneInfo[row.id]["width"], zoneInfo[row.id]["height"], 255, 0, 0, 175) elseif row.faction == 2 then zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], zoneInfo[row.id]["width"], zoneInfo[row.id]["height"], 0, 255, 0, 175) else zoneInfo[row.id]["radarArea"] = createRadarArea(zoneInfo[row.id]["x"], zoneInfo[row.id]["y"], zoneInfo[row.id]["width"], zoneInfo[row.id]["height"], 0, 0, 255, 175) end setElementData(zoneInfo[row.id]["colShape"], "faction", row.faction) setElementData(zoneInfo[row.id]["colShape"], "type", "turf") setElementData(zoneInfo[row.id]["colShape"], "ID", row.id) addEventHandler("onColShapeHit", getRootElement(), function(player) if(getElementData(source, "type") == "turf") then local id = getElementData(source, "ID") if(getPlayerTurf(player) == id) then setElementData(player, "turfID", id) end end end) --addEventHandler ( "onColShapeLeave", colcircle[row.id], function(thePlayer) --setElementData(thePlayer, "gangid", 0, true ) --end) end end function capture( thePlayer ) local gangid = getElementData(thePlayer, "turfID") if isInAllowed(thePlayer) ~= 0 then outputChatBox ("#ff0500x #ffffffВы не можете атаковать банды", thePlayer, 0,0,0, true) return true end if(getPlayerTurf(thePlayer) ~= gangid) then outputChatBox ("#ff0500x #ffffffВы не находитесь на територии банды", thePlayer, 0,0,0, true) return true end if isPlayerInBandOnline(gangid) then outputChatBox ("#ff0500x #ffffffЗону банды которую вы хотите атаковать нет в онлайне", thePlayer, 0,0,0, true) return true end outputChatBox ("#ff0500x #ffffffВы начали захват гангзоны", thePlayer, 0,0,0, true) setRadarAreaFlashing ( zoneInfo[gangid]["radarArea"], true ) end addCommandHandler ( "capture", capture ) function isInAllowed( thePlayer ) local theTeam = getPlayerTeam( thePlayer ) local factionType = getElementData( theTeam, "type" ) return factionType end function isPlayerInBandOnline(gangid) local players = exports.pool:getPoolElementsByType("player") for k, arrayPlayer in ipairs(players) do if getElementData( arrayPlayer, "faction" ) == getElementData( zoneInfo[gangid]["colShape"], "faction" ) then return false end end return true end function getPlayerTurf(player) local x, y, _ = getElementPosition(player) for i, _ in ipairs(zoneInfo) do if(x >= zoneInfo[i]["x"] and y >= zoneInfo[i]["y"] and x <= (zoneInfo[i]["x"]+zoneInfo[i]["width"]) and y <= (zoneInfo[i]["y"]+zoneInfo[i]["height"])) then return i end end return -1 end С меня пиво...
  23. Вот в чём прикол, как определить находится ли он в этой зоне или нет? Нет же такой функции в мта на подобе самповской PlayerToPoint. Вот скрипт системы: mysql = exports.mysql local toLoad = { } local threads = { } local null = mysql_null() local gangzone = { } local colcircle = { } local gangZonesElement = { } function loadAllGangZones(res) local result = mysql:query("SELECT id FROM `gangzones` ORDER BY `id` ASC") if result then while true do local row = mysql:fetch_assoc(result) if not row then break end toLoad[tonumber(row["id"])] = true end mysql:free_result(result) for id in pairs( toLoad ) do local co = coroutine.create(loadOneGangZone) coroutine.resume(co, id, true) table.insert(threads, co) end setTimer(resume, 1000, 4) else outputDebugString( "loadAllGangZones failed" ) end end addEventHandler("onResourceStart", getResourceRootElement(), loadAllGangZones) function resume() for key, value in ipairs(threads) do coroutine.resume(value) end end function loadOneGangZone(id, hasCoroutine) if (hasCoroutine==nil) then hasCoroutine = false end local row = mysql:query_fetch_assoc("SELECT * FROM gangzones WHERE id = " .. mysql:escape_string(id) .. " LIMIT 1" ) if row then if (hasCoroutine) then coroutine.yield() end for k, v in pairs( row ) do if v == null then row[k] = nil else row[k] = tonumber(row[k]) or row[k] end end colcircle[row.id] = createColRectangle ( row.x, row.y, 100.0, 100.0 ) gangZonesElement[row.id] = createElement("status", row.id) if row.faction == 1 then gangzone[row.id] = createRadarArea ( row.x, row.y, 100, 100, 0, 255, 0, 175 ) setElementData(gangZonesElement[row.id], "status", row.faction, true ) elseif row.faction == 2 then gangzone[row.id] = createRadarArea ( row.x, row.y, 100, 100, 255, 0, 0, 175 ) setElementData(gangZonesElement[row.id], "status", row.faction, true ) else gangzone[row.id] = createRadarArea ( row.x, row.y, 100, 100, 0, 0, 255, 175 ) setElementData(gangZonesElement[row.id], "status", row.faction, true ) end addEventHandler ( "onColShapeHit", colcircle[row.id], function(thePlayer) setElementData(thePlayer, "gangid", row.id, true ) end) addEventHandler ( "onColShapeLeave", colcircle[row.id], function(thePlayer) setElementData(thePlayer, "gangid", 0, true ) end) end end function capture( thePlayer ) local gangid = getElementData(thePlayer, "gangid") if isInAllowed(thePlayer) ~= 0 then outputChatBox ("#ff0500x #ffffffВы не можете атаковать банды", thePlayer, 0,0,0, true) return true end if gangid == 0 then outputChatBox ("#ff0500x #ffffffВы не находитесь на територии банды", thePlayer, 0,0,0, true) return true end if isPlayerInBandOnline(gangid) then outputChatBox ("#ff0500x #ffffffЗону банды которую вы хотите атаковать нет в онлайне", thePlayer, 0,0,0, true) return true end setRadarAreaFlashing ( gangzone[gangid], true ) end addCommandHandler ( "capture", capture ) function isInAllowed( thePlayer ) local theTeam = getPlayerTeam( thePlayer ) local factionType = getElementData( theTeam, "type" ) return factionType end function isPlayerInBandOnline(gangid) local players = exports.pool:getPoolElementsByType("player") for k, arrayPlayer in ipairs(players) do if getElementData( arrayPlayer, "faction" ) == getElementData( gangZonesElement[gangid], "status" ) then return false end end return true end
×
×
  • Create New...