Forum Jump :

Author Message

piXel  



Posts: 67
Rank:


Level: Member

Country: nl
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2008-10-09 15:43        
     
A teamkill script
THe addEventHandler "killed" is triggered local on the victim side. It works perfect but, how do I punish the killer in case of a teamkill.

(_killer addScore -5; from my script unfortunately does not work) Does anyone have a solution?

eventhandler
nul = _player addEventHandler ["killed", {nul = [_this select 0, _this select 1] execVM "team_scripts\death.sqf"}];

eventhandlerscript: death.sqf
_victim = _this select 0;
_killer = _this select 1;

//teamkill
if ((_killer != _victim) && (isPlayer _killer) && (vehicle _killer == _killer)) then
{
_killer addScore -5;
hq globalchat format["%1 received -5 points for teamkill",name _killer];
};

//removebody
sleep 120;
hidebody _victim;
sleep 4;
deletevehicle _victim;


.


Author Message

nuxil  



Posts: 11
Rank:


Level: Member

Country: no
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2008-10-09 17:02        
     
this just looks wrong.
//teamkill
if ((_killer != _victim) && (isPlayer _killer) && (vehicle _killer == _killer)) then
{
_killer addScore -5;
hq globalchat format["%1 received -5 points for teamkill",name _killer];
};

the problem here. is that, in theory you would get -5 in score for any kill.

reason. you dont check the side of the victim and killer and compare them.
so if i shoot some enemy i'll still get -5


why its not working? i have no clue. in the mission editor no mp functions work, you have to export the mission to mp to test


correct me if im wrong :)


Advertisement


Author Message

piXel  



Posts: 67
Rank:


Level: Member

Country: nl
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2008-10-09 17:57        
     
Thx nuxil. It is a coopmap and only players (isPlayer _killer) can teamkill. side is no issue. And I already tested my scripts in MP and don't use the editor much.:)

My question remains how to punish a teamkiller. More or less, how to make "_killer addScore -5" global?

Cheers .


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 49
In-game name: Myke

 
#4 Posted at 2008-10-09 19:08        
     
addPublicVariableEventHandler might do the trick. First, edit your existing script:

if ((_killer != _victim) && (isPlayer _killer) && (vehicle _killer == _killer)) then
   {
   this_is_teamkiller = _killer;
   publicVariable "this_is_teamkiller";
   hq globalchat format["%1 received -5 points for teamkill",name _killer];
};

Then, in your init.sqf/sqs, add this:
this_is_teamkiller = objnull;
"this_is_teamkiller" addPublicVariableEventHandler {nul = this execVM "is_it_teamkiller.sqf"};

And finally you need a new script, the "is_it_teamkiller.sqf"
_killer = _this select 1;
if (_killer == local player) then {
   player addscore -5;
};

This is untested and out of the blue. I hope it does the job.


Author Message

piXel  



Posts: 67
Rank:


Level: Member

Country: nl
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2008-10-09 20:42        
     
Thx Myke. A very inspiring answer I'll test it and post the result.

It worked! With the following three scripts:
plrinit.sqf (is activated with a is: "local player" trigger; when a player joins the game)
death.sqf (is activated by the eventHandler "killed" )
teamkiller.sqf (is activated by the "teamkiller" PublicVariableEventHandler)

plrinit.sqf
nul = _player addEventHandler ["killed", {nul = [_this select 0, _this select 1] execVM "team_scripts\death.sqf"}];
"teamkiller" addPublicVariableEventHandler {nul = [_this select 1] execVM "team_scripts\teamkiller.sqf"};

death.sqf
_victim = _this select 0;
_killer = _this select 1;

//teamkill
if ((_killer != _victim) && (isPlayer _killer) && (vehicle _killer == _killer)) then
{
teamkiller = _killer;
publicVariable "teamkiller";
hq globalchat format["%1 received punishment for teamkilling",name _killer];
};

//removebody
sleep 120;
hidebody _victim;
sleep 4;
deletevehicle _victim;

teamkiller.sqf
_player = player;
_fool = _this select 0;

hq globalchat format["Don't shoot teammembers %1 !!",name _fool];

if (_fool == _player) then 
{
_player addscore -4;
};

cheers .

This post was edited by piXel (2008-10-10 22:15, ago)


Author Message


Posts: 57
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 58
In-game name:

 
#6 Posted at 2009-05-31 20:02        
     
"plrinit.sqf (is activated with a is: "local player" trigger; when a player joins the game)"

How do you set that trigger up in better detail?
thanks

Love Arma, 1000 Servers, 100 Players!

Author Message

piXel  



Posts: 67
Rank:


Level: Member

Country: nl
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2009-06-06 22:03        
     
Hi Cougar,

The goal is to activate some localscripts like markers etc in a script called "plrinit.sqf".

I did this by creating a trigger in the ARMA-editor
activation: once
condition: local player
on activation: plrinit.sqf

This will start the .sqf file. It will run once when you become a player in the game.
Hope it helps.



.


Author Message


Posts: 50
Rank:


Level: Member

Country: be
Location: Belgium
Occupation: Skurcey
Age: 39
In-game name:

 
#8 Posted at 2009-06-06 22:13        
     
edit* wrong thread sorry :(

*** Only the petals of Fire will give me peace ***:guitar:listenup:guitar:dj:joker:laugh:cheers

Author Message


Posts: 57
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 58
In-game name:

 
#9 Posted at 2009-06-11 19:51        
     
Thanks piXel!

Love Arma, 1000 Servers, 100 Players!

Author Message


Posts: 1
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2010-08-09 02:27        
     
# piXel : Hi Cougar,

The goal is to activate some localscripts like markers etc in a script called "plrinit.sqf".

I did this by creating a trigger in the ARMA-editor
activation: once
condition: local player
on activation: plrinit.sqf

This will start the .sqf file. It will run once when you become a player in the game.
Hope it helps.



.


Ok im quite new at this so I tried multiple ways to right this in a trigger present by blufor my starting units etc. Can anyone please specify this? Also is there a way to just add a counter? like if score is negative 3 then "kill" "removeallweapons" etc?