Script, barely working

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Script, barely working

Post by kinetosimpetus »

What is supposed to happen is, if the player shoots a team 3 unit, team 3 turns enemy to player's team, if player causes friendly fire, his team goes FFA for 25 seconds, then returns to normal. (friendly fire durring those 25 sec. do not set off FFA, ignored)

what it actually does: chats the word [Null] everytime i shoot something with health, sometimes if i shoot a unit in my team, it starts the timer, but nothing happens
Hidden/Spoiler:
[code]teamChaos = 0
chaosOn = 0

timeoutTimer = CreateTimer("chaos_timer")
SetTimerValue(timeoutTimer, 25)


OnObjectDamage(function(object,attacker)
--cancel if there was no attacker (maybe fell off a tower...)
if attacker == nil then return end

if IsCharacterHuman(attacker) then

--do if the damaged object is on the 3rd team
if GetObjectTeam(object) == 3 then

--3rd team is now an enemy of the attacker's team
ShowMessageText(chaosOn, REP)
SetTeamAsEnemy(3,GetObjectTeam(attacker))
SetTeamAsEnemy(GetObjectTeam(attacker),3)
return
end

--cancel if the damaged object is not on the same team
if GetObjectTeam(object) ~= GetObjectTeam(attacker) then return end

--cancel if the damaged object is on the chaos team, same team, and chaos is on
if GetObjectTeam(object) == GetObjectTeam(attacker) then
if GetObjectTeam(object) == chaosTeam then
if chaosOn == 1 then
return
end
end
end

--chaos team is now an enemy of the chaos team
ShowMessageText(chaosOn, REP)
teamChaos = GetObjectTeam(attacker)
SetTeamAsEnemy(teamChaos,teamChaos)

timeoutTimer = CreateTimer("chaos_timer")
SetTimerValue(timeoutTimer, 25)
ShowTimer(timeoutTimer)
StartTimer(timeoutTimer)
chaosOn = 1
end --ifcharacterishuman

end)

OnTimerElapse(
function(timer)
ShowMessageText(chaosOn, REP)
SetTeamAsFriend(teamChaos,teamChaos)
chaosOn = 0
ShowTimer(nil)
DestroyTimer(timer)
end,
timeoutTimer
)

end[/code]
Any help would be appreciated.
Post Reply