GTA-Resource

Русское сообщество

Приветствую Вас Гость • Регистрация • Вход
Воскресенье, 21.12.2025
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Модератор форума: DuXeT  
Туториал: Медвежий капкан
DuXeTДата: Вторник, 20.05.2014, 20:37 | Сообщение # 1
ADMIN
Группа: Администраторы
Сообщений: 15
Статус: Offline
Туториал по добавлению Медвежего капкана.

Требуется:
- MTA DayZ Uncompiled
- Notepad++
- Прямые руки

Файлы которые будут использоваться:
- inventory.lua
- login.lua
- spawn.lua
- pickups.lua
- survivorSystem_Client.lua
- survivorsystem.lua
- meta.xml

P.S Советую сделать копию сервера вдруг не получится с 1 раза xD

Открываем файл inventory.lua

И ищем:
["Items"] = {

И добавляем:
{"Медвежий капкан",3,"Использовать капкан"},

После того как добавили, ищем:
function playerUseItem(itemName, itemInfo)

И добавляем в конец перед end:

elseif itemInfo == "Использовать капкан" then
setElementData ( localPlayer, "Медвежий капкан", getElementData ( localPlayer, "Медвежий капкан" )-1 )
local posX, posY, posZ = getElementPosition(localPlayer)
local _, _, rotation = getElementRotation(localPlayer)
posX = posX - math.sin(math.rad(rotation)) * 2
posY = posY + math.cos(math.rad(rotation)) * 2
triggerServerEvent ( 'createBearTrapC', localPlayer, posX, posY, getGroundPosition ( posX, posY, posZ )+0.1 )

Открываем файл spawn.lua и login.lua
Теперь ищем:
local playerDataTable = {

И добавляем:
{"Медвежий капкан"},

Ищем:
local vehicleDataTable = {

И добавляем:
{"Медвежий капкан"},

ЭТО ВСЕ ДЕЛАЕМ И В spawn.lua И В login.lua !!!

Открываем файл pickups.lua
И ищем:
["farm"] = {

Теперь добавляем:
{"Медвежий капкан",1918,1,0,5},

Теперь нам нужно найти:
["other"] = {

И добавить:
{"Медвежий капкан",1918,1,0,0},

Теперь заходим в файл survivorSystem_Client.lua
И добавляем:

itemTXD = engineLoadTXD("mods/trap_closed.txd")
engineImportTXD(itemTXD, 1918)
itemDFF = engineLoadDFF("mods/trap_closed.dff", 1918)
engineReplaceModel(itemDFF, 1918)
itemCOL = engineLoadCOL ( "mods/trap_closed.col" )
engineReplaceCOL(itemCOL, 1918)
itemTXD = engineLoadTXD("mods/trap_open.txd")
engineImportTXD(itemTXD, 1920)
itemDFF = engineLoadDFF("mods/trap_open.dff", 1920)
engineReplaceModel(itemDFF, 1920)
itemCOL = engineLoadCOL ( "mods/trap_open.col" )
engineReplaceCOL(itemCOL, 1920)

Теперь идем в самый низ и добавляем

playTrapSoundClient = function()
local x,y,z = getElementPosition ( source )
playSound3D ( "sounds/trap.ogg", x, y, z )
end

addEvent("playTrapSound", true)
addEventHandler("playTrapSound", getRootElement(), playTrapSoundClient)

playTrapSoundClient = function()
local x,y,z = getElementPosition ( source )
playSound3D ( "sounds/trap.ogg", x, y, z )
end

addEvent("playTrapSound", true)
addEventHandler("playTrapSound", getRootElement(), playTrapSoundClient)

workingTrap = false

function showTrapMenu ()
if not workingTrap then
workingTrap = source
showCursor ( true )
bagWindow = guiCreateWindow(0.44, 0.40, 0.16, 0.23, "Медвежий капкан", true)
guiWindowSetSizable(bagWindow, false)
guiSetAlpha(bagWindow, 1.00)
openBag = guiCreateButton(0.07, 0.16, 0.86, 0.22, "Использовать капкан", true, bagWindow)
guiSetProperty(openBag, "NormalTextColour", "FFAAAAAA")
if not getElementData ( workingTrap, "closed" ) then -- ??? ??? ????????
guiSetEnabled ( openBag, false )
else
guiSetEnabled ( openBag, true )
end
takeBag = guiCreateButton(0.07, 0.40, 0.86, 0.22, "Убрать капкан", true, bagWindow)
guiSetProperty(takeBag, "NormalTextColour", "FFAAAAAA")
closeBag = guiCreateButton(0.07, 0.70, 0.86, 0.22, "Закрыть", true, bagWindow)
guiSetProperty(closeBag, "NormalTextColour", "FFAAAAAA")
guiSetVisible ( bagWindow, true )

addEventHandler ( "onClientGUIClick", openBag, openTrapClicked, false )
addEventHandler ( "onClientGUIClick", takeBag, takeTrapClicked, false )
addEventHandler ( "onClientGUIClick", closeBag, function ()
setElementData ( workingTrap, "inUse", false )
workingTrap = false
destroyElement ( bagWindow )
showCursor ( false )
end, false )
end
end

addEvent( "showTrapMenuS", true )
addEventHandler( "showTrapMenuS", getRootElement(), showTrapMenu )

function openTrapClicked ()
if isElement ( workingTrap ) then
setElementData ( workingTrap, "closed", false )
triggerServerEvent ( "openTrapC", workingTrap )
end
setElementData ( workingTrap, "inUse", false )
workingTrap = false
destroyElement ( bagWindow )
showCursor ( false )
end

function takeTrapClicked ()
if isElement ( workingTrap ) then
triggerServerEvent ( "takeTrapFromClient", localPlayer, workingTrap )
end
setElementData ( workingTrap, "inUse", false )
workingTrap = false
destroyElement ( bagWindow )
showCursor ( false )
end

P.S Эту часть я так и не успел отредактировать

Открываем файл survivorsystem.lua
И тут ищем:
local vehicleDataTableForTent = {

Сюда добавляем:
{"Медвежий капкан"},

И в конец файла пишем:

traps = {}

createBearTrap = function(x, y, z)
local trap = createObject ( 1920, x, y, z, 0, 0, math.random(0,360) )
table.insert ( traps, trap )
local shape = createColSphere ( x, y, z, 1 )
local shapeFar = createColSphere ( x, y, z, 2 )
setElementData ( shape, "trap", true )
setElementData ( shape, "objectLink", trap )
setElementData ( shape, "farShapeLink", shapeFar )
setElementData ( shapeFar, "nearShapeLink", shapeFar )
setElementData ( shapeFar, "objectLink", trap )
setElementData ( shapeFar, "trapFar", true )
end

addEvent("createBearTrapC", true)
addEventHandler("createBearTrapC", getRootElement(), createBearTrap)

function checkTrapPlace( theElement, matchingDimension )
if ( getElementType ( theElement ) == 'player' ) and matchingDimension then
if getElementData ( source, "trapFar" ) then
bindKey ( theElement, "E", "down", checkTrapPlacePress, getElementData ( source, "nearShapeLink" ) )
setElementData ( theElement, "nearTrap", true )
elseif getElementData ( source, "trap" ) then
if not getElementData ( source, "closed" ) and not getPedOccupiedVehicle ( theElement ) then
local object = getElementData ( source, "objectLink" )
if isElement ( object ) then
setElementData ( source, "closed", true )
setElementModel ( object, 1918 )
setElementData(theElement, "brokenbone", true)
setElementData(theElement, "bleeding", getElementData(theElement, "bleeding") + 10)
triggerClientEvent ( theElement, "playTrapSound", source )
end
end
end
end
end
addEventHandler("onColShapeHit",getRootElement(),checkTrapPlace)

function checkLootPlaceLeave( theElement, matchingDimension )
if ( getElementType ( theElement ) == 'player' ) then
if getElementData ( source, "trapFar" ) then
setElementData ( theElement, "nearTrap", false )
unbindKey ( theElement, "E", "down", checkTrapPlacePress )
end
end
end
addEventHandler("onColShapeLeave",getRootElement(),checkLootPlaceLeave)

function checkTrapPlacePress ( player, key, keyState, trapSphere )
if isElement(trapSphere) then
if not getElementData ( trapSphere, "inUse" ) then
setElementData ( trapSphere, "inUse", true )
unbindKey ( player, "E", "down", checkTrapPlacePress )
triggerClientEvent ( player, "showTrapMenuS", trapSphere )
end
end
end

takeTrapInServer = function( trap )
unbindKey ( source, "E", "down", checkTrapPlacePress )
setElementData ( source, "nearTrap", false )
local nearShapeLink = getElementData ( trap, "farShapeLink" )
local objectLink = getElementData ( trap, "objectLink" )
if isElement ( nearShapeLink ) then
destroyElement ( nearShapeLink )
end
if isElement ( objectLink ) then
destroyElement ( objectLink )
setElementData ( source, "TrapDeUrso", getElementData ( source, "TrapDeUrso" )+1 )
end
destroyElement ( trap )
end

addEvent("takeTrapFromClient", true)
addEventHandler("takeTrapFromClient", getRootElement(), takeTrapInServer)

openTrap = function( )
setElementData ( source, "inUse", false )
setElementData ( source, "closed", false )
setElementModel ( getElementData ( source, "objectLink" ), 1920 )
end

addEvent("openTrapC", true)
addEventHandler("openTrapC", getRootElement(), openTrap)

P.S. Эту часть я не отредактировал!Сорри если что...

Теперь осталось прописать в meta.xml.Заходим в него и пишем:

<file src="mods/trap_open.txd" />
<file src="mods/trap_open.dff" />
<file src="mods/trap_open.col" />
<file src="mods/trap_closed.dff" />
<file src="mods/trap_closed.col" />
<file src="sounds/trap.ogg" />
Прикрепления: 8579982.png (183.3 Kb)
 
  • Страница 1 из 1
  • 1
Поиск: