function onStatsChange(cid, attacker, type, combat, value)
if not isPlayer(attacker) then
return true
end
if teamConfig.damageToSameTeam == false then
if getPlayerTeam(cid) == getPlayerTeam(attacker) then
if type ~= STATSCHANGE_HEALTHGAIN then
return false
end
end
end
return true
end
function onTarget(cid, target)
if teamConfig.damageToSameTeam == false then
if getPlayerTeam(cid) == getPlayerTeam(target) then
return false
end
end
return true
end
function onLogin(cid)
if getPlayerGroupId(cid) < 4 and getCreatureName(cid) ~= "Account Manager" then
executeEvents(cid)
if getPlayerPromotionLevel(cid) < 1 then
setPlayerPromotionLevel(cid, 1)
end
if getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).itemid == 1987 then
doPlayerRemoveItem(cid, 1987, 1)
end
startEquipment(cid)
updateStats(cid)
if getPlayerKills(cid, 2) < 0 then
for a = 1,#teamConfig.playerKills do
resetPlayerKills(cid, a)
end
end
if getPlayerStorageValue(cid, 6666) == -1 then
setPlayerStorageValue(cid, 6666, os.time())
end
if (os.time() - getPlayerStorageValue(cid, 6666)) >= (teamConfig.mapTime * 1000) then
resetPlayerKills(cid, 3)
setPlayerStorageValue(cid, 6666, os.time())
end
if getPlayerDeaths(cid) < 0 then
resetPlayerDeaths(cid)
end
resetPlayerKills(cid, 1)
setPlayerTeam(cid, getNewTeam())
addTeamCount(getPlayerTeam(cid))
if getTeamKills(getPlayerTeam(cid)) < getPlayerKills(cid, 3) then
resetPlayerKills(cid, 3)
end
if teamConfig.outfit.changeOutfit == true then
doCreatureChangeOutfit(cid, teams[getPlayerTeam(cid)].outfit[getPlayerSex(cid)])
end
doPlayerSendTextMessage(cid,22,"You have joined the ".. teams[getPlayerTeam(cid)].name .." team.")
doTeleportThing(cid, teams[getPlayerTeam(cid)].maps[getCurrentMap()], false)
else
doTeleportThing(cid, teams[1].maps[getCurrentMap()], false)
end
return true
end
function onLogout(cid)
if getPlayerGroupId(cid) < 4 and getCreatureName(cid) ~= "Account Manager" then
if getPlayerTeam(cid) ~= nil then
resetPlayerKills(cid, 1)
if hasFirstTimeOutfit(cid) then
setFirstTimeOutfit(cid, false)
end
removeTeamCount(getPlayerTeam(cid))
removePlayerFromTeam(cid)
end
end
return true
end
function onOutfit(cid, old, current)
if getPlayerGroupId(cid) < 4 and getCreatureName(cid) ~= "Account Manager" then
if not hasFirstTimeOutfit(cid) then
setFirstTimeOutfit(cid, true)
return true
elseif teamConfig.outfit.changeOutfit == true then
if teamConfig.outfit.canChangeOutfit == false then
if teamConfig.outfit.canChangeLookTypeOnly == false then
doPlayerSendCancel(cid,"You are not allowed to change your outfit.")
current.lookType, current.lookHead, current.lookBody, current.lookLegs, current.lookFeet = old.lookType, old.lookHead, old.lookBody, old.lookLegs, old.lookFeet
return false
elseif teamConfig.outfit.canChangeLookTypeOnly == true then
if old.lookHead ~= current.lookHead or old.lookBody ~= current.lookBody or old.lookLegs ~= current.lookLegs or old.lookFeet ~= current.lookFeet then
doPlayerSendCancel(cid,"You cannot change anything else then your looktype.")
current.lookHead, current.lookBody, current.lookLegs, current.lookFeet = old.lookHead, old.lookBody, old.lookLegs, old.lookFeet
return false
end
end
end
end
end
return true
end
function onDeath(cid, corpse, deathList)
if isPlayer(cid) then
for a = 1,#deathList do
if isPlayer(deathList[a]) then
if getPlayerIp(cid) ~= getPlayerIp(deathList[a]) then
DoPlayerAddItem(deathList[a], 2152, math.random(10,25))
doPlayerSendTextMessage(deathList[a],22,"You have killed ".. getCreatureName(cid) ..".")
addPlayerKills(deathList[a], 1)
addTeamKills(getPlayerTeam(deathList[a]), 1)
end
end
end
addPlayerDeaths(cid, 1)
end
return true
end
function onLook(cid, thing, position, lookDistance)
local player = getThingFromPos(position).uid
if isPlayer(getThingfromPos(position).uid) and getCreatureName(player) ~= "Account Manager" and getPlayerGroupId(player) < 4 then
doPlayerSendTextMessage(cid,22,"\nPlayer: ".. getCreatureName(player) .."\nTeam: ".. teams[getPlayerTeam(player)].name .."\nKills since login: ".. getPlayerKills(player, 1) .."\nKills on this Map: ".. getPlayerKills(player, 3) .."\nKills overall: ".. getPlayerKills(player, 2) .."\nDeaths overall: ".. getPlayerDeaths(player) .."\nKDR: ".. round((getPlayerKills(player, 2) == 0 and 1 or getPlayerKills(player, 2)) / (getPlayerDeaths(player) == 0 and 1 or getPlayerDeaths(player)), 2) .."")
end
return true
end