Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Weedburner

Make Players to a Pig when they Teamkill

Recommended Posts

Hello

I need 2 Scripts for my Missions.

1.Script

the 1 Script i need should do following:

If a Player teamkills more than 1 Teammate he shall get Pig.

Since ArmaII have many Animals,it should be possible or?Perhaps with

the Code that is used for the Spectator Bird.

2.Script

The other Script i need is a Script that removes all Weapons from a Player,when he uses his Weapon in Main Base.

it should execute the "remove allWeapons this" command,when the Player uses his Weapon in Base,but i dont know how to do this.

I hope someone can help me.

Share this post


Link to post
Share on other sites

Well if it's help you're asking for, then here are the basics you need:

1. http://www.arma2.com/comref/full.html#selectPlayerObject <-- lets you transfer an player into a pig.

2. http://community.bistudio.com/wiki/addEventHandler "fired" eventhandlers <-- look these up

You'll also need the "killed" eventhandler for 1. to recognize if teamkilling is taking place.

On the other hand if by "help" you mean "someone please write this script for me" then, no sorry ain't got time for that.

Share this post


Link to post
Share on other sites

No,i dont want someone to write it for me,i wanna learn how to do by myself.I learned already much in the last week as i build my first map (50 Player Coop,Operation Icebreaker)

but i dont know much about the scripting work yet.Till now i mostly used scripts from other Peoples,studied them,and edited them for my Mission.That worked good,and i learned already some stuff.But i dont know all the posible commands,like "fired".

The Page you linked is a great Help!! I searched something like this for longer,with this "commands list" im able to build more own scripts,thx :)

Edit: Do you know a Page where the Commands and Eventhandlers for ArmaII are listed? or they are the same as in Arma I?? I couldnt find such a page in the Bis Wiki Page.

Edited by Weedburner

Share this post


Link to post
Share on other sites

Kudos for that idea.:rthumb:

That`s how it should be out of the box.

Share this post


Link to post
Share on other sites

Ah ok, sorry I misunderstood you then.

Still, the commands I mentioned should be everything you need. Holler if anything goes wrong with that. ;)

Share this post


Link to post
Share on other sites
Kudos for that idea.:rthumb:

That`s how it should be out of the box.

Hehe,thx to the Links im already working on it.It should be possible,but atm im not sure if i need to add 1 trigger for every player,that would mean 50 triggers.

Cause if i add all the Player Names (soldier1,soldiers2 and so on) into 1 trigger,all Players would get to Pigs or unarmed if 1 Player would trigger the trigger.

Need to test that

Edit: I dont understand what they mean with "muzzle" in the Eventhandler "killed".When i translate Muzzle to German it means "Mündung",and this is the "hole" at the end of a gun barrel.So i dont understand what i have to enter for "muzzle"

Anyone can help me with that??

Edited by Weedburner

Share this post


Link to post
Share on other sites

No need for triggers at all. Only use the eventhandlers.

"fired" event:

detect if the player who fired is closer than a predefined distance to the center of the base. If so punish him by removing all his weapons. (you could even try to catch the shot he just fired and delete it, possibly avoiding any damage to be caused)

"killed" event:

check if the player that has just been killed was killed by an other player on the same side, if so spawn a pig somewhere and use selectplayer on the other player to make him take control of the pig.

Basically that is all you need, though I expect it to be atleast a little bit more complicated in practice since multiplayer-locality comes to play.

Share this post


Link to post
Share on other sites

hmm,thx for this Info,but do you mean the "fired" or "firednear" event,cause you speaking from distance to something.

And,do you know what they mean with "muzzle" in the fired event? In German its the "hole at the end of a weapon barrel",so i dont know what to use for "muzzle"

Share this post


Link to post
Share on other sites

Oh interesting, never noticed the "FiredNear" event. However it is not what we need, "fired" will do.

Also there is nothing you have to "use" in these events. The values like "muzzle" are not parameters you have to set, those are variables passed to your script by the eventhandler.

So if the fired-event is activated, it tells your script what happens. In case of the "fired" event it'll tell the following things:

who fired?

what weapon did he use?

what sort of muzzle on that weapon did he use (this is relevant for weapons like an M16A4 with m203)

what kind of ammo was fired ?

You can than use this information in your script. However in this very case we don't need any of it except for the unit that fired. We just want to know if someone fired and how far away from the base it happend.

So the script for the eventhandler could look like this:

if ((_this select 0) distance basecenter < 100) then {
 removeAllWeapons (_this select 0);
};

basecenter for example could be an invisible H placed in the middle of the base.

Share this post


Link to post
Share on other sites

One thing you could also consider, would be to prevent units from dying and even sustaining damage in the base with the "HandleDamage" event.

Share this post


Link to post
Share on other sites
Oh interesting, never noticed the "FiredNear" event. However it is not what we need, "fired" will do.

Also there is nothing you have to "use" in these events. The values like "muzzle" are not parameters you have to set, those are variables passed to your script by the eventhandler.

So if the fired-event is activated, it tells your script what happens. In case of the "fired" event it'll tell the following things:

who fired?

what weapon did he use?

what sort of muzzle on that weapon did he use (this is relevant for weapons like an M16A4 with m203)

what kind of ammo was fired ?

You can than use this information in your script. However in this very case we don't need any of it except for the unit that fired. We just want to know if someone fired and how far away from the base it happend.

So the script for the eventhandler could look like this:

if ((_this select 0) distance basecenter < 100) then {
 removeAllWeapons (_this select 0);
};

basecenter for example could be an invisible H placed in the middle of the base.

THX :) The Disarm Script is working already,i put what you have written above in a script called "disarm",then i added to the Units:

this addEventHandler ["Fired", {_this exec "Disarm.sqs"}]

and it works,now i work at the pig Transform

Share this post


Link to post
Share on other sites

One more thing, since you're already learning to script. Learn SQF, not SQS ! And know the difference ;)

you can also add this to the script:

		_shot = nearestObject [_this select 0, _this select 4];
	deleteVehicle _shot;

It wont catch every bullet, since sometimes they're too fast for the script to detect them (especially sniper rifles) but if it does it'll prevent damage. Also it works extremely well for all kinds of launchers and grenades.

Oh and you might consider adding an similar eventhandler to the vehicles available at the base, maybe utilizing the "moveOut" command to throw people out that mess around.

ps.: wenn du xfire hast kannst du mich da auch unter dem nick darkscout erreichen, dann brauch ich auch nicht englisch zu reden im Gegensatz zu hier im Forum.

Edited by Tajin

Share this post


Link to post
Share on other sites

Oh,i just noticed that it dont works,the weapon gets removed,doesnt matter player is far or close to basecenter,i tried a flag,an invisible Helipad and a Marker named "basecenter" but it dont work.

Share this post


Link to post
Share on other sites
Oh interesting, never noticed the "FiredNear" event. However it is not what we need, "fired" will do.

Nice. Apparently there are a few new event handlers we get to play with.

Share this post


Link to post
Share on other sites

Yup, I'll give them a try as soon as I can. :D

Hmm. Use this

this addEventHandler ["Fired", {nul = _this execVM "Disarm.sqf"}

and rename the disarm.sqs to sqf.

Since you ran my .sqf code in an .sqs file I assume the "IF"-statement was ignored. ;)

Heed my words: Ignore sqs and stick to sqf scripts.

Share this post


Link to post
Share on other sites
Yup, I'll give them a try as soon as I can. :D

Hmm. Use this

this addEventHandler ["Fired", {nul = _this execVM "Disarm.sqf"}

and rename the disarm.sqs to sqf.

Since you ran my .sqf code in an .sqs file I assume the "IF"-statement was ignored. ;)

Heed my words: Ignore sqs and stick to sqf scripts.

Hmm,no doesnt work.

Its says a ] is missing at the end,i added the] but it doesnt work.When i remove the VM from the execVM it works again,but it takes the weapon away in any distance,so the distance < 100 doesnt work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×