Server upload

RD Core / Commit #2

Commit Server upload

Alex Alex committed 18/10/2026 23:38 main Patch
1,106 files +223,404 -0
A data/creaturescripts/scripts/logout.lua +8-0 View file
@@ -0,0 +1,8 @@
1+function onLogout(player)
2+ player:sendCancelMessage("@timeLogin 05")
3+ if player:getStorageValue(_PLAYER_INFO.LOGOUT_DELAY) > 0 then
4+ player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Aguarde alguns segundos para poder deslogar novamente.")
5+ return false
6+ end
7+ return true
8+end
A data/creaturescripts/scripts/modalWindow.lua +155-0 View file
@@ -0,0 +1,155 @@
1+local TABLE_SKILLS = {
2+ 01, 02, 03, 04, 05, 06, 07, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
3+ 21, 22, 23, 24, 25, 29, 30, 32, 33, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45,
4+ 46, 47, 48, 49, 50, 51, 52, 53, 55, 56, 58, 59, 60, 61, 63, 65, 66, 68, 70,
5+}
6+function onModalWindow(player, modalWindowId, buttonId, choiceId)
7+ local RANDOM_POS_WARZONE = {
8+ [01] = {x=3944, y=1192, z=07};
9+ [02] = {x=3948, y=1196, z=07};
10+ [03] = {x=3941, y=1199, z=07};
11+ [04] = {x=3935, y=1201, z=07};
12+ [05] = {x=3953, y=1199, z=07};
13+ [06] = {x=3960, y=1200, z=07};
14+ [07] = {x=3945, y=1209, z=07};
15+ [08] = {x=3938, y=1212, z=07};
16+ [09] = {x=3932, y=1219, z=07};
17+ [10] = {x=3934, y=1213, z=07};
18+ [11] = {x=3956, y=1218, z=07};
19+ [12] = {x=3946, y=1221, z=07};
20+ [13] = {x=3944, y=1214, z=07};
21+ [14] = {x=3938, y=1225, z=07};
22+ [15] = {x=3932, y=1234, z=07};
23+ [16] = {x=3941, y=1237, z=07};
24+ [17] = {x=3948, y=1234, z=07};
25+ [18] = {x=3960, y=1220, z=07};
26+ }
27+ if modalWindowId == 1000 then
28+ if buttonId == 100 then
29+ if player:getStorageValue(_SYSTEM.INVENTARIO[04].UID_01) > 0 then
30+ if doBackpack(player, 00, 04, 00, 01) then
31+ -- Removendo o item equipado
32+ doInventario(player, 02, 04, 00) -- Removo do Invent�rio
33+ doInventario(player, 00, 04, 00) -- Organizo Invent�rio
34+ doBackpack(player, 00, 04, 00, 01) -- Organizo Backpack
35+
36+ player:sendCancelMessage("@RemoveItemInventario 04")
37+ player:sendCancelMessage("@StarCliente")
38+ player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua arma principal foi devolvida a sua backpack.\nPoder� equip�-la novamente ao sair da Warzone.")
39+ else
40+ player:popupFYI("Libere espa�o em sua Backpack de armas para poder continuar.")
41+ return false
42+ end
43+ end
44+
45+ player:setStorageValue(_SYSTEM.WARZONE, 01)
46+ player:setTown(Town(15))
47+ player:teleportTo({x=4024, y=1193, z=07})
48+ player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
49+
50+ player:setMaxHealth(3000)
51+ player:addHealth(player:getMaxHealth())
52+ player:sendCancelMessage("@NoTeleport 01")
53+ end
54+
55+ elseif modalWindowId == 1001 then
56+ if buttonId == 100 then
57+ player:setStorageValue(_SYSTEM.WARZONE, nil)
58+ player:setTown(Town(01))
59+ player:teleportTo({x=3999, y=991, z=07})
60+ player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
61+
62+ local lvl = player:getLevel()
63+ player:setMaxHealth((lvl * 10) + 140)
64+ player:addHealth(player:getMaxHealth())
65+ player:sendCancelMessage("@NoTeleport 00")
66+ end
67+
68+ elseif modalWindowId == 1002 then
69+ local GUN_CATEGORY = {
70+ [01] = {4024, 4030}; -- PISTOLAS
71+ [02] = {4010, 4014}; -- RIFLES
72+ [03] = {4040, 4049}; -- METRALHADORA
73+ [04] = {4002, 4004}; -- ESPINGARDA
74+ }
75+ if buttonId == 100 then
76+ local WEAPON_ID = math.random(GUN_CATEGORY[choiceId][01], GUN_CATEGORY[choiceId][02])
77+ local WEAPON_RARE = math.random(03, 04)
78+ local WEAPON_STAR = math.random(00, 03)
79+ local SKILL_01 = 01
80+ local SKILL_02 = 02
81+ local SKILL_03 = 03
82+ local TEMP_SKILLS = {}
83+
84+ if #TEMP_SKILLS > 0 then
85+ for k in pairs (TEMP_SKILLS) do
86+ TEMP_SKILLS [k] = nil
87+ end
88+ end
89+ for S = 01, #TABLE_SKILLS do
90+ table.insert(TEMP_SKILLS, TABLE_SKILLS[S])
91+ end
92+
93+ local SkillSort1 = math.random(01, #TEMP_SKILLS)
94+ SKILL_01 = TEMP_SKILLS[SkillSort1]
95+ table.remove(TEMP_SKILLS, SkillSort1)
96+
97+ SkillSort2 = math.random(01, #TEMP_SKILLS)
98+ SKILL_02 = TEMP_SKILLS[SkillSort2]
99+ table.remove(TEMP_SKILLS, SkillSort2)
100+
101+ SkillSort3 = math.random(01, #TEMP_SKILLS)
102+ SKILL_03 = TEMP_SKILLS[SkillSort3]
103+ table.remove(TEMP_SKILLS, SkillSort3)
104+
105+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_01, WEAPON_ID) -- ID
106+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_02, WEAPON_RARE) -- RARIDADE
107+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_03, WEAPON_STAR) -- STAR
108+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_04, SKILL_01) -- SKILL 01
109+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_05, SKILL_02) -- SKILL 02
110+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_06, SKILL_03) -- SKILL 03
111+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_07, math.random(00, 10)) -- LEVEL
112+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_08, 00)
113+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_09, 01) -- UNIQUE ITEM
114+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_10, 9999) -- AMMO
115+ player:setStorageValue(_GLOBAL_RANDOM.WARZONE.LOBBY_TIMER, nil)
116+ player:sendCancelMessage("@LootMSG " ..WEAPON_ID.. " " ..WEAPON_RARE.. " " ..WEAPON_STAR.. " 01")
117+
118+ doInventario(player, 00, 04, 00) -- Organizo Invent�rio
119+ player:setTown(Town(15))
120+
121+ player:teleportTo(RANDOM_POS_WARZONE[math.random(01, #RANDOM_POS_WARZONE)])
122+ player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
123+
124+ player:sendCancelMessage("@StarCliente")
125+ end
126+
127+ elseif modalWindowId == 1003 then
128+ if buttonId == 100 then
129+ player:teleportTo({x=3896, y=1769, z=06})
130+ player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
131+ player:sendCancelMessage("@NoTeleport 00")
132+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ COLISEU ]\nVoc� n�o concluiu o desafio do Coliseu")
133+
134+ player:setStorageValue(_SYSTEM.DANGEROUS[01][01].STORAGE, nil)
135+ player:setStorageValue(_SYSTEM.FIRST_DEAD_TUTOR, nil)
136+ player:setStorageValue(_SYSTEM.COLISEU[05], nil)
137+ player:setStorageValue(_SYSTEM.COLISEU[06], nil)
138+ player:setStorageValue(_SYSTEM.COLISEU[07], nil)
139+ player:setStorageValue(_SYSTEM.COLISEU[08], nil)
140+ local from = _GLOBAL_RANDOM.COLISEUM.ORDER[00][01].ARENA_X_POS
141+ local to = _GLOBAL_RANDOM.COLISEUM.ORDER[00][01].ARENA_Y_POS
142+ for A = from.x, to.x do
143+ for B = from.y, to.y do
144+ for C = from.z, to.z do
145+ local tile = Tile(A, B, C)
146+ local creature = tile:getTopCreature()
147+ if creature and creature:isMonster() then
148+ doRemoveCreature(creature:getId())
149+ end
150+ end
151+ end
152+ end
153+ end
154+ end
155+end
A data/creaturescripts/scripts/partyUpdate.lua +19-0 View file
@@ -0,0 +1,19 @@
1+local OPCODE_PARTY = 160
2+
3+function onThink(creature, interval)
4+ local _data = {name = creature:getName(), pos = creature:getPosition()}
5+ local leader = creature:getParty():getLeader()
6+ local party = creature:getParty()
7+
8+ if (#party:getMembers() > 0) then
9+ for _, member in ipairs(party:getMembers()) do
10+ member:sendExtendedOpcode(OPCODE_PARTY, json.encode({type = "update", player = _data}))
11+ end
12+ end
13+
14+ if (creature ~= leader) then
15+ leader:sendExtendedOpcode(OPCODE_PARTY, json.encode({type = "update", player = _data}))
16+ end
17+
18+ return true
19+end
A data/creaturescripts/scripts/preparedeath.lua +322-0 View file
@@ -0,0 +1,322 @@
1+local LIMITE_STORAGE = 999999999
2+local maxDeathRecords = 5
3+local WarzoneLobbyTimer = {}
4+local function getExpForLevel(level)
5+ level = level - 1
6+ return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
7+end
8+function onPrepareDeath(player, killer)
9+ local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PVPZONE)
10+ if tile then
11+ if killer then
12+ if killer:isPlayer() then
13+ -- FREELANCER
14+ local targetPlacar = killer:getStorageValue(_SISTEMA.TIME_WAR_STORAGE)
15+ Game.setStorageValue(_SISTEMA.FIGHT_PLACAR[targetPlacar].GLOBAL_PLACAR, (Game.getStorageValue(_SISTEMA.FIGHT_PLACAR[targetPlacar].GLOBAL_PLACAR) + 01))
16+ player:setStorageValue(_SISTEMA.INVITE_WAR_MAIN, nil)
17+
18+ if Game.getStorageValue(_SISTEMA.FIGHT_PLACAR[targetPlacar].GLOBAL_PLACAR) >= 03 then
19+ local WinnerTimeId = 00
20+ REMOVE_PLAYER_ARENA = addEvent(function()
21+ local from = _SISTEMA.ARENA[01]
22+ local to = _SISTEMA.ARENA[02]
23+ for A = from.x, to.x do
24+ for B = from.y, to.y do
25+ for C = from.z, to.z do
26+ local tile = Tile(A, B, C)
27+ local creature = tile:getTopCreature()
28+ if creature and creature:isPlayer() then
29+ creature:teleportTo(_SISTEMA.TEMPLE_POS)
30+ creature:getPosition():sendMagicEffect(03)
31+ if WinnerTimeId == 00 then
32+ WinnerTimeId = creature:getStorageValue(_SISTEMA.TIME_WAR_STORAGE)
33+ end
34+ creature:setStorageValue(_SISTEMA.INVITE_WAR_MAIN, nil)
35+ end
36+ end
37+ end
38+ end
39+
40+ local players = Game.getPlayers()
41+ for _, targetPlayer in ipairs(players) do
42+ if targetPlayer:getStorageValue(_SISTEMA.TIME_WAR_STORAGE) > 00 then
43+ if targetPlayer:getStorageValue(_SISTEMA.TIME_WAR_STORAGE) == WinnerTimeId then
44+ onSetPlayerVictory(targetPlayer:getGuid(), _SISTEMA.VICTORY_POINTS)
45+ -- RECOMPENSA
46+ local RewardId = math.random(01, #_SISTEMA.REWARDS)
47+ local VictoryPlayer = tonumber(onGetPlayerVictory(targetPlayer:getGuid()))
48+ local RankNamePlayer = ""
49+ local RankChancePlayer = 00
50+ for X = 01, #_SISTEMA.RANKS do
51+ if VictoryPlayer >= _SISTEMA.RANKS[X].VALUE then
52+ RankNamePlayer = _SISTEMA.RANKS[X].NAME
53+ RankChancePlayer = _SISTEMA.RANKS[X].CHANCE
54+ break
55+ end
56+ end
57+
58+ if math.random(000, 10) <= RankChancePlayer then
59+
60+ if _SISTEMA.REWARDS[RewardId].TYPE == 01 then
61+ targetPlayer:addItem(_SISTEMA.REWARDS[RewardId].IDD, _SISTEMA.REWARDS[RewardId].VALUE)
62+ elseif _SISTEMA.REWARDS[RewardId].TYPE == 02 then
63+ targetPlayer:setStorageValue(_SISTEMA.REWARDS[RewardId].IDD, _SISTEMA.REWARDS[RewardId].VALUE)
64+ end
65+
66+ targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Com RANK " ..RankNamePlayer.. " e tendo " ..RankChancePlayer.. "% de chance, voc� obteve:\n[ " .._SISTEMA.REWARDS[RewardId].DESC.. " ]")
67+ end
68+ else
69+ targetPlayer:setStorageValue(_SISTEMA.TIME_WAR_STORAGE, nil)
70+ end
71+ end
72+ end
73+ end, _SISTEMA.SEC_REMOVE_PLA_ARENA * 1000)
74+ end
75+
76+ if Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_START_WARZONE) == 01 then
77+ if player:getStorageValue(_SYSTEM.WARZONE) > 00 and killer:getStorageValue(_SYSTEM.WARZONE) > 00 then
78+
79+ if player:getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_BLUE_PLAYER) == 01 then
80+ local RED_TIME = Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_RED_TEAM)
81+ Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_RED_TEAM, (RED_TIME + 01))
82+
83+ elseif player:getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_RED_PLAYER) == 01 then
84+ local BLUE_TIME = Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_BLUE_TEAM)
85+ Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_BLUE_TEAM, (BLUE_TIME + 01))
86+ end
87+
88+ -- DESAFIO
89+ if killer:getStorageValue(_DESAFIOS[00].DESAFIO_ID) > 00 then
90+ onPlayerDesafios(killer, 79, 01)
91+ end
92+ end
93+
94+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_01, nil)
95+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_02, nil)
96+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_03, nil)
97+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_04, nil)
98+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_05, nil)
99+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_06, nil)
100+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_07, nil)
101+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_08, nil)
102+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_09, nil)
103+ player:setStorageValue(_SYSTEM.INVENTARIO[04].UID_10, nil)
104+
105+ player:setStorageValue(_GLOBAL_RANDOM.WARZONE.LOBBY_TIMER, 10)
106+ player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voc� tem 10 segundos para retornar a Arena")
107+
108+ doInventario(player, 00, 04, 00)
109+ player:sendCancelMessage("@StarCliente")
110+ end
111+ if killer:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) == 06 and player:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) == 06 then
112+ if killer:getIp() ~= player:getIp() then
113+ if killer:getStorageValue(_SYSTEM.PVP_POINTS) < 00 then
114+ killer:setStorageValue(_SYSTEM.PVP_POINTS, 01)
115+ else
116+ killer:setStorageValue(_SYSTEM.PVP_POINTS, (killer:getStorageValue(_SYSTEM.PVP_POINTS) + 01))
117+ end
118+
119+ -- DESAFIO
120+ if killer:getStorageValue(_DESAFIOS[00].DESAFIO_ID) > 00 then
121+ onPlayerDesafios(killer, 73, 01)
122+ end
123+ killer:sendCancelMessage("@LootMSG 3219 05 00 01")
124+ doBackpack(killer, 11)
125+ end
126+ end
127+ end
128+ end
129+ if player:getStorageValue(_SYSTEM.FIRST_DEAD_TUTOR) == 02 then
130+ player:setTown(Town(16))
131+ player:teleportTo({x=3893, y=1771, z=07})
132+ player:addHealth(player:getMaxHealth())
133+ player:setStorageValue(_SYSTEM.FIRST_DEAD_TUTOR, nil)
134+ player:setStorageValue(_SYSTEM.DANGEROUS[01][01].STORAGE, nil)
135+
136+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ COLISEU ]\nVoc� perdeu seu desafio no coliseu.")
137+ player:sendCancelMessage("@NoTeleport 00")
138+ return false
139+ end
140+ if player:teleportTo(player:getTown():getTemplePosition()) then
141+ player:addHealth(player:getMaxHealth())
142+ end
143+ else
144+ player:getPosition():sendMagicEffect(206)
145+ player:setSkull(SKULL_NONE)
146+ player:setSkullTime(0)
147+ if player:teleportTo(player:getTown():getTemplePosition()) then
148+ player:addHealth(player:getMaxHealth())
149+ end
150+ player:setStorageValue(_SYSTEM.CURSED_TREE, nil)
151+ if player:getStorageValue(_SYSTEM.WARZONE) > 00 then
152+ return true
153+ end
154+ if _DEBUG_MODE then
155+ print("[CREATURESCRIPT - PREPARE DEATH] " ..player:getName())
156+ end
157+ -- FALHANDO MISS�ES
158+ if player:getStorageValue(_QUESTLOG[166].UID_01) == 02 then
159+ player:setStorageValue(_QUESTLOG[166].UID_01, 01)
160+ player:setStorageValue(10993, 00)
161+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ MISS�O FRACASSADA ]\nVoc� morreu ou foi desconectado em combate.")
162+
163+ doBackpack(player, 12)
164+ player:sendCancelMessage("@LoadQuestWindows")
165+ end
166+ if player:getStorageValue(_QUESTLOG[169].UID_01) > 01 and player:getStorageValue(_QUESTLOG[169].UID_01) < 100 then
167+ player:setStorageValue(_QUESTLOG[169].UID_01, 01)
168+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ MISS�O FRACASSADA ]\nVoc� morreu ou foi desconectado em combate.")
169+
170+ doBackpack(player, 12)
171+ player:sendCancelMessage("@LoadQuestWindows")
172+ end
173+ if player:getStorageValue(_QUESTLOG[188].UID_01) == 02 or player:getStorageValue(_QUESTLOG[188].UID_01) == 03 then
174+ player:setStorageValue(_QUESTLOG[188].UID_01, 01)
175+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ MISS�O FRACASSADA ]\nVoc� foi desconectado durante o teste.")
176+
177+ doBackpack(player, 12)
178+ player:sendCancelMessage("@LoadQuestWindows")
179+ end
180+ if player:getStorageValue(_QUESTLOG[197].UID_01) == 03 then
181+ player:setStorageValue(_QUESTLOG[197].UID_01, 02)
182+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ MISS�O FRACASSADA ]\nVoc� foi desconectado durante o combate.")
183+
184+ doBackpack(player, 12)
185+ player:sendCancelMessage("@LoadQuestWindows")
186+ end
187+ if player:getStorageValue(_QUESTLOG[198].UID_01) == 02 then
188+ player:setStorageValue(_QUESTLOG[198].UID_01, 01)
189+ player:sendTextMessage(MESSAGE_STATUS_WARNING, "[ MISS�O FRACASSADA ]\nVoc� foi desconectado durante o combate.")
190+
191+ doBackpack(player, 12)
192+ player:sendCancelMessage("@LoadQuestWindows")
193+ end
194+
195+ player:setStorageValue(_SYSTEM.DANGEROUS[01][01].STORAGE, nil)
196+ player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
197+ player:setStorageValue(_SYSTEM.TASK[00].TIMER, nil)
198+ player:sendCancelMessage("@DGTime 0 0 0")
199+ player:sendCancelMessage("@ResetDG")
200+ player:setTown(Town(01))
201+ local PenOrigin = 30
202+ if player:getStorageValue(_SYSTEM.INVENTARIO[01].UID_01) == 1022 then
203+ PenOrigin = 00
204+ end
205+ if player:getStorageValue(_SYSTEM.PENALIDADES[02]) > 00 then
206+ if PenOrigin > 00 then
207+ PenOrigin = PenOrigin - player:getStorageValue(_SYSTEM.PENALIDADES[02])
208+ end
209+
210+ player:sendCancelMessage("@deadScreen 0 1")
211+ else
212+ local ExpTable = getExpForLevel((player:getLevel() + 1)) - getExpForLevel(player:getLevel())
213+ local PenPercent = PenOrigin * (ExpTable / 100)
214+
215+ if player:getStorageValue(_SYSTEM.PENALIDADES[01]) < 01 then
216+ player:setStorageValue(_SYSTEM.PENALIDADES[01], PenPercent)
217+ else
218+ local Penalidade_Total = (player:getStorageValue(_SYSTEM.PENALIDADES[01]) + PenPercent)
219+ if Penalidade_Total > LIMITE_STORAGE then
220+ player:setStorageValue(_SYSTEM.PENALIDADES[01], LIMITE_STORAGE)
221+ else
222+ player:setStorageValue(_SYSTEM.PENALIDADES[01], Penalidade_Total)
223+ end
224+ end
225+
226+ player:sendCancelMessage("@deadScreen " ..player:getStorageValue(_SYSTEM.PENALIDADES[01]).. " 0")
227+ end
228+ if player:getStorageValue(_SYSTEM.INVENTARIO[01].UID_01) == 1022 then
229+ else
230+ player:setStorageValue(_SYSTEM.PENALIDADES[02], nil)
231+ player:setStorageValue(_SYSTEM.DEATH_COUNT, 1)
232+ end
233+
234+ local playerGuid = player:getGuid()
235+ local byPlayer = 0
236+ local killerName
237+ local lastHitUnjustified = false
238+ if killer then
239+ if killer:isPlayer() then
240+ if not player:getSkull() then
241+ lastHitUnjustified = true
242+ end
243+ byPlayer = 1
244+ else
245+ local master = killer:getMaster()
246+ if master and master ~= killer and master:isPlayer() then
247+ killer = master
248+ if not player:getSkull() then
249+ lastHitUnjustified = true
250+ end
251+ byPlayer = 1
252+ end
253+ end
254+ killerName = killer:getName()
255+ else
256+ killerName = "field item"
257+ end
258+ local byPlayerMostDamage = 0
259+ local mostDamageKillerName
260+ for cid, damage in pairs(player:getDamageMap()) do
261+ local killer = Creature(cid)
262+ if killer and killer:isPlayer() then
263+ byPlayerMostDamage = 1
264+ mostDamageName = killer:getName()
265+ elseif killer and killer:isMonster() then
266+ mostDamageName = killer:getName()
267+ else
268+ mostDamageName = "field item"
269+ end
270+ break
271+ end
272+
273+ local FirstDead = db.storeQuery("SELECT * FROM `player_deaths` WHERE `player_id` = " .. playerGuid)
274+ if FirstDead then
275+ --DELETE FROM `player_deaths` WHERE `player_id` = 19
276+ else
277+ player:setStorageValue(_SYSTEM.FIRST_DEAD_TUTOR, 01)
278+ end
279+
280+ db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`, `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`) VALUES (" .. playerGuid .. ", " .. os.time() .. ", " .. player:getLevel() .. ", " .. db.escapeString(killerName) .. ", " .. byPlayer .. ", " .. db.escapeString(mostDamageName) .. ", " .. byPlayerMostDamage .. ", " .. (lastHitUnjustified and 1 or 0) .. ", " .. (mostDamageUnjustified and 1 or 0) .. ")")
281+ local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)
282+
283+ local deathRecords = 0
284+ local tmpResultId = resultId
285+ while tmpResultId ~= false do
286+ tmpResultId = result.next(resultId)
287+ deathRecords = deathRecords + 1
288+ end
289+
290+ if resultId ~= false then
291+ result.free(resultId)
292+ end
293+
294+ local limit = deathRecords - maxDeathRecords
295+ if limit > 0 then
296+ db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
297+ end
298+ if byPlayer == 1 then
299+ local targetGuild = player:getGuild()
300+ targetGuild = targetGuild and targetGuild:getId() or 0
301+ if targetGuild ~= 0 then
302+ local killerGuild = killer:getGuild()
303+ killerGuild = killerGuild and killerGuild:getId() or 0
304+ if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer:getId()) then
305+ local warId = false
306+ resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
307+ if resultId ~= false then
308+ warId = result.getNumber(resultId, "id")
309+ result.free(resultId)
310+ end
311+
312+ if warId ~= false then
313+ db.asyncQuery("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(player:getName()) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")")
314+ end
315+ end
316+ end
317+ end
318+ return false
319+ end
320+
321+ return false
322+end
Top