mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-14 14:44:55 +02:00
Full Distribution
This commit is contained in:
30
data/creaturescripts/scripts/firstitems.lua
Normal file
30
data/creaturescripts/scripts/firstitems.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
function onLogin(player)
|
||||
if player:getLastLoginSaved() <= 0 then
|
||||
-- Items
|
||||
if player:getSex() == PLAYERSEX_FEMALE then
|
||||
player:addItem(3562, 1, true, -1, CONST_SLOT_ARMOR)
|
||||
else
|
||||
player:addItem(3561, 1, true, -1, CONST_SLOT_ARMOR)
|
||||
end
|
||||
player:addItem(3270, 1, true, -1, CONST_SLOT_LEFT)
|
||||
player:addItem(2920, 1, true, -1, CONST_SLOT_RIGHT)
|
||||
|
||||
local container = Game.createItem(2853, 1)
|
||||
container:addItem(3585, 1)
|
||||
|
||||
player:addItemEx(container, true, CONST_SLOT_BACKPACK)
|
||||
|
||||
-- Default Outfit
|
||||
if player:getSex() == PLAYERSEX_FEMALE then
|
||||
player:setOutfit({lookType = 136, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
|
||||
else
|
||||
player:setOutfit({lookType = 128, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
|
||||
end
|
||||
|
||||
local town = Town("Rookgaard")
|
||||
player:teleportTo(town:getTemplePosition())
|
||||
player:setTown(town)
|
||||
player:setDirection(DIRECTION_SOUTH)
|
||||
end
|
||||
return true
|
||||
end
|
54
data/creaturescripts/scripts/login.lua
Normal file
54
data/creaturescripts/scripts/login.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
function onLogin(player)
|
||||
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
|
||||
if player:getLastLoginSaved() <= 0 then
|
||||
loginStr = loginStr .. " Please choose your outfit."
|
||||
player:sendOutfitWindow()
|
||||
else
|
||||
if loginStr ~= "" then
|
||||
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
|
||||
end
|
||||
|
||||
loginStr = string.format("Your last visit on Nostalrius: %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
|
||||
end
|
||||
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
|
||||
|
||||
-- Promotion
|
||||
if player:isPremium() then
|
||||
if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
|
||||
player:setVocation(player:getVocation():getId() + 4)
|
||||
end
|
||||
else
|
||||
if player:getVocation():getId() ~= 0 and player:getVocation():getId() > 4 then
|
||||
player:setVocation(player:getVocation():getId() - 4)
|
||||
end
|
||||
end
|
||||
|
||||
-- Outfits
|
||||
if not player:isPremium() then
|
||||
if player:getSex() == PLAYERSEX_FEMALE then
|
||||
local outfit = player:getOutfit()
|
||||
if outfit.lookType > 139 then
|
||||
player:setOutfit({lookType = 136, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
|
||||
end
|
||||
else
|
||||
local outfit = player:getOutfit()
|
||||
if outfit.lookType > 131 then
|
||||
player:setOutfit({lookType = 128, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Premium system
|
||||
if player:isPremium() then
|
||||
player:setStorageValue(43434, 1)
|
||||
elseif player:getStorageValue(43434) == 1 then
|
||||
player:setStorageValue(43434, 0)
|
||||
player:teleportTo({x = 32369, y = 32241, z = 7})
|
||||
player:setTown(Town("Thais"))
|
||||
end
|
||||
|
||||
-- Events
|
||||
player:registerEvent("PlayerDeath")
|
||||
player:registerEvent("kills")
|
||||
return true
|
||||
end
|
94
data/creaturescripts/scripts/playerdeath.lua
Normal file
94
data/creaturescripts/scripts/playerdeath.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
local deathListEnabled = true
|
||||
local maxDeathRecords = 50
|
||||
|
||||
function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
|
||||
local playerId = player:getId()
|
||||
|
||||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
|
||||
|
||||
-- restart blessings values
|
||||
player:setStorageValue(101,0)
|
||||
player:setStorageValue(102,0)
|
||||
player:setStorageValue(103,0)
|
||||
player:setStorageValue(104,0)
|
||||
player:setStorageValue(105,0)
|
||||
|
||||
if not deathListEnabled then
|
||||
return
|
||||
end
|
||||
|
||||
local byPlayer = 0
|
||||
local killerName
|
||||
if killer ~= nil then
|
||||
if killer:isPlayer() then
|
||||
byPlayer = 1
|
||||
else
|
||||
local master = killer:getMaster()
|
||||
if master and master ~= killer and master:isPlayer() then
|
||||
killer = master
|
||||
byPlayer = 1
|
||||
end
|
||||
end
|
||||
killerName = killer:getName()
|
||||
else
|
||||
killerName = "field item"
|
||||
end
|
||||
|
||||
local byPlayerMostDamage = 0
|
||||
local mostDamageKillerName
|
||||
if mostDamageKiller ~= nil then
|
||||
if mostDamageKiller:isPlayer() then
|
||||
byPlayerMostDamage = 1
|
||||
else
|
||||
local master = mostDamageKiller:getMaster()
|
||||
if master and master ~= mostDamageKiller and master:isPlayer() then
|
||||
mostDamageKiller = master
|
||||
byPlayerMostDamage = 1
|
||||
end
|
||||
end
|
||||
mostDamageName = mostDamageKiller:getName()
|
||||
else
|
||||
mostDamageName = "field item"
|
||||
end
|
||||
|
||||
local playerGuid = player:getGuid()
|
||||
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 .. ", " .. (unjustified and 1 or 0) .. ", " .. (mostDamageUnjustified and 1 or 0) .. ")")
|
||||
local resultId = db.storeQuery("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. playerGuid)
|
||||
|
||||
local deathRecords = 0
|
||||
local tmpResultId = resultId
|
||||
while tmpResultId ~= false do
|
||||
tmpResultId = result.next(resultId)
|
||||
deathRecords = deathRecords + 1
|
||||
end
|
||||
|
||||
if resultId ~= false then
|
||||
result.free(resultId)
|
||||
end
|
||||
|
||||
local limit = deathRecords - maxDeathRecords
|
||||
if limit > 0 then
|
||||
db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
|
||||
end
|
||||
|
||||
if byPlayer == 1 then
|
||||
local targetGuild = player:getGuild()
|
||||
targetGuild = targetGuild and targetGuild:getId() or 0
|
||||
if targetGuild ~= 0 then
|
||||
local killerGuild = killer:getGuild()
|
||||
killerGuild = killerGuild and killerGuild:getId() or 0
|
||||
if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer:getId()) then
|
||||
local warId = false
|
||||
resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
|
||||
if resultId ~= false then
|
||||
warId = result.getDataInt(resultId, "id")
|
||||
result.free(resultId)
|
||||
end
|
||||
|
||||
if warId ~= false then
|
||||
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 .. ")")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user