Jump to content
Sign in to follow this  
A-SUICIDAL

Adding score after destroying a "non-placed" island object?

Recommended Posts

I managed to addScore to a player that destroyed a radar tower that I placed in the editor, but I was trying to get it to work for another radar tower that I did not place, but is actually part of the map. I figured out that the problem that I was having was due to a hidden object ID number, but I fixed the problem. I edited this topic and posted my example for others that might want to use it.

First I'll explain how I have it working for a placed radar tower.

I placed a radar tower and named it "radar1" and then I added this to its init:

radar1 addEventHandler["killed", {[_this select 0, _this select 1] execVM "addScore.sqf"}];

(from Xeno) addScore.sqf:

_victim = _this select 0;
_killer = _this select 1;

if (isServer) then {
_killer addScore 10;
} else {
paddscore = [_killer, 10]; publicVariable "paddscore"; 
};

(from Xeno) init.sqf:

if (isServer) then {
"paddscore" addPublicVariableEventHandler 
{
((_this select 1) select 0) addScore ((_this select 1) select 1);
};
};

Now for a non-placed map object it works a little differently.

I clicked the "IDs" button in the editor to find out the ID number of the radar tower map object, which in this case was "15461". I placed a Game Logic in the editor as close to the position of the radar tower as possible. I want to make sure that the radar tower could only be destroyed by C4 and I also do not want players to be able to destroy the object with C4 until Task 5 is assigned, so I added those conditions.

Game Logic's init:

task5_tower2 = (position this nearestobject 15461);
task5_tower2 addEventHandler ["HandleDamage",{task5_started && (_this select 4 ) == "PipeBomb"}];
task5_tower2 addEventHandler["killed", {[_this select 0, _this select 1] execVM "addScore.sqf"}];

Sometimes map object ID numbers are not always visible in the editor, so I some times have to find the ID numbers using a script like this:

(from Deadfast) init.sqf:

while {true} do
{
    hintSilent str (nearestObjects [player, [], 3]);
    sleep 0.01;
}; 

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Just tested it with map object and Killed event handler fired up just fine, might be some problem with addScore.sqf

Either way you can delete this map object with deleteCollection function and create your own. Watch out though, you will have to call deleteCollection for each client.

Edited by SaMatra

Share this post


Link to post
Share on other sites

deleteCollection is depreciated/buggy in ArmA2. You should use hideObject instead. Or better yet, place things to be destroyed. :)

Share this post


Link to post
Share on other sites

Yeah, it's strange. I'm using the island Faysh Khabur and at the Abu Wajnam Airstrip there is a radar tower that shows an #ID 19302, but it's not working with that number. I used the script to show all ID's within a 3 meter distance and mostly flies and mosquito's are being returned. I'm having trouble getting that tower ID number. I originally thought that I had the correct number, but after applying the "destroy with C4 only" script, I thought everything was working correctly except for the addScore, but then it turned out that I was able to destroy the tower with a MAAW rocket. That's when I realized that the ID must be wrong.

There is a very long fence that goes all around that airstrip, I used a few markers to spawn explosions in a few spots at mission start just so the enemy AI could get through the fence in some places. I think I am going to spawn an explosion on that radar tower just to get rid of it - since out of the 30 or so objects that need to be destroyed in the mission, that radar tower is the only map object ID# that is giving me problems.

---------- Post added at 07:28 PM ---------- Previous post was at 07:15 PM ----------

Yeah, deleteCollection caused some severe lag in one of my missions. I couldn't figure out why the mission was so laggy, then I made a duplicate copy of the mission and started removing stuff and I kept testing the mission. When I removed the deleteCollection stuff from the mission, the lag disappeared. hideObject can be tricky too, especially when you hide and object that you want to show later. For instance, I have enemy bunkers that need to be captured, so I use hideObject true to hide the bunkers in my init.sqf, but then later when that specific task is assigned, I use hideObject false to show the bunkers, but I have to script it through my task scripts, otherwise a JIP player can't see the bunker, but mission start players can. If done correctly it works great. I can basically hide lots of stuff and show it when needed and delete it when it's not needed anymore. It saves a lot of extra work using long scripts to spawn everything.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×