Jump to content

Recommended Posts

Posted (edited)

I'm trying to figure out a way where a Coalition can be punished for shooting a MEDEVAC helicopter.

 

I'm using the following code to create player points.

--Adds 5000 Tickets to the Red Team
--Takes 5000 Tickets from Blue Team
do
local RedTickets = trigger.misc.getUserFlag(1000)
local BlueTickets = trigger.misc.getUserFlag(2000)
RedTickets = RedTickets + 5000
BlueTickets = BlueTickets - 5000
trigger.action.setUserFlag("1000", RedTickets)
trigger.action.setUserFlag("2000", BlueTickets)
end

 

I'm not sure how to script, If PLAYER REDFOR/BLUFOR kills a unit named MEDEVAC, subtract points from them?

 

Sorry, still new to this. Researched, didn't find any info. I'll keep searching but any help would be greatly appreciated!

Edited by maverickturner
added info
Posted

Something like this should work for you:

local unit = Unit.getByName("myUnitName")
if unit and unit:getLife() < 1 then
   trigger.action.setUserFlag("123", true)
end

Posted
Something like this should work for you:

local unit = Unit.getByName("myUnitName")
if unit and unit:getLife() < 1 then
   trigger.action.setUserFlag("123", true)
end

 

Would this script only work if the opposite team were to kill that unit? I'm looking to set a flag if the opposing side (RED/BLUE) kills the other side's designated MEDEVAC helo.

Posted

You will need to make use of events in the beginning of your mission. In this case S_EVENT_HIT. Basically, you will need to create a short script and running it in the beginning of the mission. You will have to provide a list of all MEDEVAC in that script. I haven't wrote a script in months but your script should look like that:

 

function MedevacHit:onEvent(event)

if event.id == 2 then

local coalition = event.initiator.getCoallition()

local medevac = event.target.name - this will be passed to get the medevac unit

if coalition== "RED" and medevac.coalition == "BLUE then

trigger.action.setUserFlag(111, true)

end

end

end

world.addEventHandler(MedevacHit)

 

Apologies for the sloppy script, I am at work and I can't spend lot of time on this. I will try to come later with something better but if you know programming then you will pick this up very fast and make your own script.

  • Like 1

[sIGPIC]OK[/sIGPIC]

Posted (edited)
Apologies for the sloppy script, I am at work and I can't spend lot of time on this. I will try to come later with something better but if you know programming then you will pick this up very fast and make your own script.

Zayets this is awesome. Thanks for the help. That does appear to be exactly what I'm looking for. For the sake of teaching myself, I'm going to try to learn how to write the script that initiates the S_EVENT_HIT.

 

However, if you find a chance to supply an initiate script I would be grateful. I'm good at getting the gist of it, I just always seem to leave out something tiny and important.

Edited by maverickturner
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...