• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Rush event the wrong team gets the reward

Lightonia

Lightonia.servegame.com
Joined
Jun 4, 2007
Messages
492
Reaction score
9
Solved by @@dchampag
Here is the fully working rush event/massive team battles for 0.4 series of TFS probably for other revisions too.
http://pastebin.com/wuLU0J9u

The title says it all..
Here is all the parts of the script that im guessing is the reward part, its a mod so i can't post it all.

Code:
t = {
a = 32145,
g = 32146,
l = 32147,
u = 32148,
h = 32149,
wv = 32150,
c = 0,
q = "The Massive Team Battle has now been started! Enjoy and have fight well!",
f = 5447,
f_1 = 5448,
f_2 = 5449,
d_1 = {x = 28387, y = 32337, z = 7}, -- red temple
d_2 = {x = 28386, y = 32355, z = 7}, -- blue temple
x = "The massive Team Battles won't start bacause too few people were willing to participate",
w =  {x=28435,y=32309,z=4},
lvl = 80,
v = 2,
mn = 1,
m = 200,
o = "The war has seized, the RED TEAM has won the massive Team Battle!",
y = "The war has seized, the BLUE TEAM has won the massive Team Battle!",
i_1 = 2143,
i_2 = 50,
t = 1,
r = 3

Code:
if blue >= t.v then
doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.h, 1)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_1) == 1) then
doPlayerAddItem(cid, 2143, 50)
end
end
elseif red >= t.v then
doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.h, 1)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_2) == 1) then
doPlayerAddItem(cid, 2143, 50)
end
end
end
if getGlobalStorageValue(t.h) == 1 then
setGlobalStorageValue(t.a, 0)
setGlobalStorageValue(t.h, 0)
setGlobalStorageValue(t.wv, -1)
setPlayerStorageValue(cid, t.f, -1)
setPlayerStorageValue(cid, t.g, 0)
setPlayerStorageValue(cid, t.l, 0)
setPlayerStorageValue(cid, t.u, 0)
setPlayerStorageValue(cid, t.f_1, -1)
setPlayerStorageValue(cid, t.f_2, -1)
setPlayerStorageValue(cid, t.h, -1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
doSendMagicEffect(getCreaturePosition(cid), 10)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doPlayerRemoveLethalConditions(cid)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(pid, t.f_1) == 1 or getPlayerStorageValue(pid, t.f_2) == 1) then
setPlayerStorageValue(pid, t.f, -1)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
setPlayerStorageValue(pid, t.g, 0)
setPlayerStorageValue(pid, t.l, 0)
setPlayerStorageValue(pid, t.u, 0)
setPlayerStorageValue(pid, t.f_1, -1)
setPlayerStorageValue(pid, t.f_2, -1)
setPlayerStorageValue(pid, t.h, -1)
doCreatureAddHealth(pid, getCreatureMaxHealth(pid), MAGIC_EFFECT_UNKNOWN, COLOR_UNKNOWN, true)
doCreatureAddMana(pid, getCreatureMaxMana(pid))
doPlayerRemoveLethalConditions(pid)
end
end
return false
end
return false
end
return true
end
 
Last edited:
You are correct, this is the script that gives reward, but the issues is not with that, I just went over it and it must be with the script that decides what team wins.
 
I got one that I have rewritten, but its not done yet when I replace the names of the variables, I must have fucked smth., since you never get tped back to blue/red temple, insted you actually die.
When I have fixed that ill post it.
 
I got one that I have rewritten, but its not done yet when I replace the names of the variables, I must have fucked smth., since you never get tped back to blue/red temple, insted you actually die.
When I have fixed that ill post it.
Hey WibbenZ, i fixed that issue myself, if you read on the top it says
Code:
Adicione isto em 050-function.lua:
-------------------------------------------------------------------------------------------------
function doPlayerRemoveLethalConditions(cid)
local tmp = {1, 2, 4, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 32768, 65536}
for i = 1, #tmp do
if(hasCondition(cid, tmp[i])) then doRemoveCondition(cid, tmp[i]) end
end
return true
end
-------------------------------------------------------------------------------------------------
Adicione isto em login.lua:
-------------------------------------------------------------------------------------------------
registerCreatureEvent(cid, "RushCombat")
registerCreatureEvent(cid, "RushAttack")
registerCreatureEvent(cid, "RushDead")
registerCreatureEvent(cid, "RushOutfit")
You have to add them manually to your login.lua and 050-functions.lua
I use tfs 0.4 though r3884

Anyhow, here is the code to the winning team script part (im guessing now)
Code:
<talkaction words="!start" event="script"><![CDATA[
domodlib('re')
function onSay(cid, words, param, channel)
if getPlayerGroupId(cid) > 3 then
setGlobalStorageValue(t.g, 1)
setGlobalStorageValue(t.u, 0)
setGlobalStorageValue(t.l, 0)
setGlobalStorageValue(t.a, 1)
setGlobalStorageValue(t.c, 0)
setGlobalStorageValue(t.wv, 0)
doBroadcastMessage("Attention! Immediately register to the Massive Team Battle, event will start in ".. t.t .." minutes. All players can join to event typing this command: !rush", MESSAGE_STATUS_WARNING)
addEvent(function()
doBroadcastMessage("The Massive Team Battle starts in in 2 minutes. If you want to join, type in !start", MESSAGE_STATUS_WARNING)
end, (t.t - 2) * 1000 * 60)
addEvent(function()
doBroadcastMessage("The Massive Team Battle starts in a minute. If you want to join, type in !start.", MESSAGE_STATUS_WARNING)
end, (t.t - 1) * 1000 * 60)
addEvent(start, t.t * 1000 * 60, cid)
return true
end
return true
end
function results()
if(getGlobalStorageValue(t.a) == 1) then
local red = getGlobalStorageValue(t.l)
local blue = getGlobalStorageValue(t.u)
doBroadcastMessage("Massive Team Battle, results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. t.v .." frags.", MESSAGE_STATUS_WARNING)
addEvent(results, t.r * 1000 * 60)
end
end
function start(cid)
if(getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.c) >= t.mn) then
doBroadcastMessage(t.q, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.wv, 1)
addEvent(results, t.r * 1000 * 60)
for _, pid in ipairs(getPlayersOnline()) do
local myOutfit = getCreatureOutfit(pid)
local red = {lookType = myOutfit.lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
local blue = {lookType = myOutfit.lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
if getPlayerStorageValue(pid, t.f) == 1 then
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, getCreatureMaxMana(pid))
if((getPlayerStorageValue(pid, t.g) % 2) == 1) then
doCreatureChangeOutfit(pid, red)
setPlayerStorageValue(pid, t.h, 0)
doTeleportThing(pid, t.d_1)
setPlayerStorageValue(pid, t.f, 1)
setPlayerStorageValue(pid, t.f_1, 0)
setPlayerStorageValue(pid, t.f_2, 1)
doSendMagicEffect(getCreaturePosition(pid), 10)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. t.v .." frags!")
else
doCreatureChangeOutfit(pid, blue)
doTeleportThing(pid, t.d_2)
setPlayerStorageValue(pid, t.h, 0)
setPlayerStorageValue(pid, t.f, 1)
setPlayerStorageValue(pid, t.f_1, 1)
setPlayerStorageValue(pid, t.f_2, 0)
doSendMagicEffect(getCreaturePosition(pid), 10)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. t.v .." frags!")
end
end
end
elseif(getGlobalStorageValue(t.c) < t.mn) then
doBroadcastMessage(t.x, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.a, 0)
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(pid, t.f) == 1 then
setPlayerStorageValue(pid, t.f, -1)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
end
end
end
end

and

Code:
<globalevent name="RushStart" time="00:09" event="script"><![CDATA[
domodlib('re')
function onTime(interval, lastExecution)
setGlobalStorageValue(t.g, 1)
setGlobalStorageValue(t.u, 0)
setGlobalStorageValue(t.l, 0)
setGlobalStorageValue(t.a, 1)
setGlobalStorageValue(t.c, 0)
setGlobalStorageValue(t.wv, 0)
doBroadcastMessage("Attention! Immediately register to Rush Event, event will start for ".. t.t .." minutes. All players can join to event typing this command: !join", MESSAGE_STATUS_WARNING)
addEvent(function()
doBroadcastMessage("Massive team battles starts in 2 minutes. If you want to join, type in the command: !join", MESSAGE_STATUS_WARNING)
end, (t.t - 2) * 1000 * 60)
addEvent(function()
doBroadcastMessage("Massive team battles starts in a minute. If you want to join, type in the command: !join", MESSAGE_STATUS_WARNING)
end, (t.t - 1) * 1000 * 60)
addEvent(start, t.t * 1000 * 60, cid)
end
function results()
if(getGlobalStorageValue(t.a) == 1) then
local red = getGlobalStorageValue(t.l)
local blue = getGlobalStorageValue(t.u)
doBroadcastMessage("Massive team battle, results:\nRed Team scored: ".. red .." frags.\nBlue Team scored: ".. blue .." frags.\nMatch is under way to ".. t.v .." frags.", MESSAGE_STATUS_WARNING)
addEvent(results, t.r * 1000 * 60)
end
end
function start(cid)
if(getGlobalStorageValue(t.a) == 1 and getGlobalStorageValue(t.c) >= t.mn) then
doBroadcastMessage(t.q, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.wv, 1)
addEvent(results, t.r * 1000 * 60)
for _, pid in ipairs(getPlayersOnline()) do
local myOutfit = getCreatureOutfit(pid)
local red = {lookType = myOutfit.lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
local blue = {lookType = myOutfit.lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = myOutfit.lookAddons}
if getPlayerStorageValue(pid, t.f) == 1 then
doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
doCreatureAddMana(pid, getCreatureMaxMana(pid))
if((getPlayerStorageValue(pid, t.g) % 2) == 1) then
doCreatureChangeOutfit(pid, red)
setPlayerStorageValue(pid, t.h, 0)
doTeleportThing(pid, t.d_1)
setPlayerStorageValue(pid, t.f, 1)
setPlayerStorageValue(pid, t.f_1, 0)
setPlayerStorageValue(pid, t.f_2, 1)
doSendMagicEffect(getCreaturePosition(pid), 10)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in RED TEAM!\nThis battle will continue up to ".. t.v .." frags!")
else
doCreatureChangeOutfit(pid, blue)
setPlayerStorageValue(pid, t.h, 0)
doTeleportThing(pid, t.d_2)
setPlayerStorageValue(pid, t.f, 1)
setPlayerStorageValue(pid, t.f_1, 1)
setPlayerStorageValue(pid, t.f_2, 0)
doSendMagicEffect(getCreaturePosition(pid), 10)
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, "You are in BLUE TEAM!\nThis battle will continue up to ".. t.v .." frags!")
end
end
end
elseif(getGlobalStorageValue(t.c) < t.mn) then
doBroadcastMessage(t.x, MESSAGE_STATUS_WARNING)
setGlobalStorageValue(t.a, 0)
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(pid, t.f) == 1 then
setPlayerStorageValue(pid, t.f, -1)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)))
doSendMagicEffect(getCreaturePosition(pid), CONST_ME_TELEPORT)
end
end
end
end
]]></globalevent>
 
You will still have problems with either "onDeath" or reward, I have those things already, ive rewritten most of the files.
 
You're not providing all of the scripts, but from what you provided, everything is as it should be facing the right directions, so the only other factors are, are the points going to the correct teams on kill? Or for this code below
Code:
if blue >= t.v then -- t.u
    doBroadcastMessage(t.y, MESSAGE_STATUS_WARNING)
    setGlobalStorageValue(t.h, 1)
    for _, pid in ipairs(getPlayersOnline()) do
        if(getPlayerStorageValue(pid, t.f_1) == 1) then
            doPlayerAddItem(cid, 2143, 50)
        end
    end
elseif red >= t.v then -- t.l
    doBroadcastMessage(t.o, MESSAGE_STATUS_WARNING)
    setGlobalStorageValue(t.h, 1)
    for _, pid in ipairs(getPlayersOnline()) do
        if(getPlayerStorageValue(pid, t.f_2) == 1) then
            doPlayerAddItem(cid, 2143, 50)
        end
    end
end
the values blue and red are mixed up in whatever script you took that from.

or the script for ending the event and setting the winner is removing score for the wrong team.

if you provided all of the scripts it would make this much easier.
 
I believe I found the issue.

Located in onPrepareDeath idk how you have yours set up, mod or creaturescript.

Change
Code:
if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
setGlobalStorageValue(t.u, getGlobalStorageValue(t.u)+1)
else
setGlobalStorageValue(t.l, getGlobalStorageValue(t.l)+1)
end
to
Code:
if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
   setGlobalStorageValue(t.l, getGlobalStorageValue(t.l)+1)
else
   setGlobalStorageValue(t.u, getGlobalStorageValue(t.u)+1)
end
 
Last edited:
I tried it and without any errors, i can keep on killing my opponent without any progress, even thought the winning frag for test purposes is 2, i just keep killing the test opponent and nothing happens. And when i switch back to the messy one giving loot to the wrong team, it start to work again.
 
Wow I'm stupid sorry I didn't change code correct here, try this.

Also changed in previous post.

Code:
if((getPlayerStorageValue(cid, t.g) % 2) == 1) then
    setGlobalStorageValue(t.l, getGlobalStorageValue(t.l)+1)
else
    setGlobalStorageValue(t.u, getGlobalStorageValue(t.u)+1)
end
 
The wrong team still recieves the reward with the new edited code
If you add me on skype: Twanaa2
then i can send you my full script.
 
Last edited:
Im not gonna go thru a code like that again, since ive already done it with mine.. (Even I have problems still with the config)
But look for the !rush command, what once the player joines what variable does player get?
Thats the variable of the red / blue team.

Also you can look at the "BLUE TEAM" or "RED TEAM" text that comes after some time over the player, check the variable name there.
 
The wrong team still recieves the reward with the new edited code
If you add me on skype: Twanaa2
then i can send you my full script.
Added, I looked it over so many times now I don't get what I'm over looking xD, unless it's not the wrong team, it's always one team or something?
 
Back
Top