Chava
New Member
- Joined
- Jul 6, 2009
- Messages
- 280
- Reaction score
- 0
LUA:
function onThink(interval, lastExecution, thinkInterval)
local maps = {
[1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
[2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
[3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
}
local teams = {
blueName = "Blue Bangbabies",
redName = "Red Rageboys",
blueScore = 101,
redScore = 102,
bluePlayerScore = 1004,
redPlayerScore = 1006,
}
local map = maps[getGlobalStorageValue(100)]
if getGlobalStorageValue(100) <= 0 then
setGlobalStorageValue(100, 1)
elseif getGlobalStorageValue(100) >= math.max(1, #maps) then
setGlobalStorageValue(100, 1)
elseif getGlobalStorageValue(100) >= 1 then
setGlobalStorageValue(100, getGlobalStorageValue(100)+1)
end
if map then
for _, cid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, 1002) == 1 then
doTeleportThing(cid, map.blueTemple)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
elseif getPlayerStorageValue(cid, 1003) == 1 then
doTeleportThing(cid, map.redTemple)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
end
if getGlobalStorageValue(teams.blueScore) > getGlobalStorageValue(teams.redScore) then
str = "\n\nThe " .. teams.blueName .. " won!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
elseif getGlobalStorageValue(teams.redScore) > getGlobalStorageValue(teams.blueScore) then
str = "\n\nThe " .. teams.redName .. " won!\n\nScores:\n" .. teams.blueName .. " " .. getGlobalStorageValue(blueScore) .. " - " .. getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
end
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Map has been changed to " .. map.mapName .. "! Next map in 30 minutes!" .. str)
end
setGlobalStorageValue(teams.blueScore, 0)
setGlobalStorageValue(teams.redScore, 0)
end
return true
end
LUA:
local maps = {
[1] = {mapName = "Ignitos", redTemple = {x = 1153, y = 1069, z = 6}, blueTemple = {x = 1146, y = 1120, z = 6}},
[2] = {mapName = "Dust2", redTemple = {x = 1169, y = 1192, z = 7}, blueTemple = {x = 1107, y = 1176, z = 6}},
[3] = {mapName = "Fridge", redTemple = {x = 1277, y = 1035, z = 3}, blueTemple = {x = 1225, y = 1035, z = 3}},
}
local teams = {
blueName = "Blue Bangbabies",
redName = "Red Rageboys",
blueScore = 101,
redScore = 102,
bluePlayerScore = 1004,
redPlayerScore = 1006,
}
local blueScore = 101
local redScore = 102
local conditionBlue = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})
function onLogin(cid)
setPlayerStorageValue(cid, 1002, 0)
setPlayerStorageValue(cid, 1003, 0)
local map = maps[getGlobalStorageValue(100)]
if map then
if getGlobalStorageValue(1000) > getGlobalStorageValue(1001) then
setPlayerStorageValue(cid, 1003, 1)
doAddCondition(cid, conditionRed)
doTeleportThing(cid, map.redTemple)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
setGlobalStorageValue(1001, getGlobalStorageValue(1001)+1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You were sent to fight for the " .. teams.redName .. "!\nYour team have scored " .. getGlobalStorageValue(redScore) .. " kills.\nCurrent map is " .. map.mapName .. ".")
else
setPlayerStorageValue(cid, 1002, 1)
doAddCondition(cid, conditionBlue)
doTeleportThing(cid, map.blueTemple)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
setGlobalStorageValue(1000, getGlobalStorageValue(1000)+1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You were sent to fight for the " .. teams.blueName .. "!\nYour team have scored " .. getGlobalStorageValue(blueScore) .. " kills.\nCurrent map is " .. map.mapName .. ".")
end
end
if getPlayerStorageValue(cid, 10000) == 1 then
doPlayerAddExperience(cid, -getPlayerExperience(cid) + getExperienceForLevel(130))
elseif getPlayerStorageValue(cid, 10000) ~= 1 then
doPlayerAddExperience(cid, -getPlayerExperience(cid) + getExperienceForLevel(100))
end
if isSorcerer(cid) or isDruid(cid) then
if getPlayerStorageValue(cid, 10000) == 1 then
setCreatureMaxHealth(cid, 795)
setCreatureMaxMana(cid, 3695)
for i = 1, -getPlayerMagLevel(cid)+60 do doPlayerAddMagLevel(cid, 1) end
else
setCreatureMaxHealth(cid, 645)
setCreatureMaxMana(cid, 2795)
for i = 1, -getPlayerMagLevel(cid)+50 do doPlayerAddMagLevel(cid, 1) end
end
elseif isPaladin(cid) then
if getPlayerStorageValue(cid, 10000) == 1 then
setCreatureMaxHealth(cid, 1405)
setCreatureMaxMana(cid, 1865)
for i = 1, -getPlayerMagLevel(cid)+16 do doPlayerAddMagLevel(cid, 1) end
for i = 1, -getPlayerSkillLevel(cid, SKILL_DIST)+80 do addEvent(delayDist, 0.2 * 1000, cid) end
else
setCreatureMaxHealth(cid, 1105)
setCreaureMaxMana(cid, 1415)
for i = 1, -getPlayerMagLevel(cid)+14 do doPlayerAddMagLevel(cid, 1) end
for i = 1, -getPlayerSkillLevel(cid, SKILL_DIST)+70 do addEvent(delayDist, 0.2 * 1000, cid) end
end
elseif isKnight(cid) then
if getPlayerStorageValue(cid, 10000) == 1 then
setCreatureMaxHealth(cid, 2015)
setCreatureMaxMana(cid, 645)
for i = 1, -getPlayerMagLevel(cid)+9 do doPlayerAddMagLevel(cid, 1) end
for i = 1, -getPlayerMeleeSkill(cid)+75 do addEvent(delaySkill, 0.2 * 1000, cid) end
for i = 1, -getPlayerSkillLevel(cid, SKILL_SHIELD)+75 do addEvent(delayShield, 0.2 * 1000, cid) end
else
setCreatureMaxHealth(cid, 1565)
setCreatureMaxMana(cid, 495)
for i = 1, -getPlayerMagLevel(cid)+8 do doPlayerAddMagLevel(cid, 1) end
for i = 1, -getPlayerMeleeSkill(cid)+65 do addEvent(delaySkill, 0.2 * 1000, cid) end
for i = 1, -getPlayerSkillLevel(cid, SKILL_SHIELD)+65 do addEvent(delayShield, 0.2 * 1000, cid) end
end
doCreatureAddHealth(cid, -getCreatureHealth(cid)+getCreatureMaxHealth(cid))
doCreatureAddMana(cid, -getCreatureMana(cid)+getCreatureMaxMana(cid))
end
return true
end
function delaySkill(cid)
doPlayerAddMeleeSkill(cid, 1)
end
function delayShield(cid)
doPlayerAddSkill(cid, SKILL_SHIELD, 1)
end
function delayDist(cid)
doPlayerAddSkill(cid, SKILL_DIST, 1)
end
These two scripts, they are working BUT, there is one problem, it changes the map and everything but, let's say the map is 1 right now, players who logg in will get to the next town, 2.
So that's the problem the map change and everything is working but when players logg in they get to the next town right away. I believe that can be fixed somewhere in one of these two scripts, does anybody know how?