Jump to content
Sign in to follow this  
theavonlady

Bad consequences of negative player score/rating

Recommended Posts

try<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(_unit == player): exitor, even better:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _unit != player: exit

Share this post


Link to post
Share on other sites

Eh?

If I'm gettng this right, which I probably aint, you're using

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_this select 0

in your exec part.

Isn't that the person who is killed?

Try

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_this select 1

And in your script, put

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0

_points = _this select 1

? (_unit != aP) : exit

hint "player's score adjusted"

scoreadjust = scoreadjust + _points

exit

Share this post


Link to post
Share on other sites
or, even better:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _unit != player: exit

This works:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_points = _this select 1

hint format ["Name of killer is: %1", (_unit)]

? _unit != player: exit

scoreadjust = scoreadjust + _points

exit

The hint command reveals that _unit is indeed set to something crazy like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WEST Charlie Green:1 (Jane Doe)

crazy_o.gif

Share this post


Link to post
Share on other sites
Eh?

If I'm gettng this right, which I probably aint, you're using

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_this select 0

in your exec part.

Isn't that the person who is killed?

My mistake. I meant _this select 1 for ID'ing the killer.

Anyway, script works now. Just have to tackle this player naming business, which should be simple.

Share this post


Link to post
Share on other sites

mrZig is right: _this select 0 is the guy who was killed.

/edit: avon was too fast. wow_o.gif

Share this post


Link to post
Share on other sites
try<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(_unit == player): exit
or, even better:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _unit != player: exit

The code above will work.

Here's why the previous examples didn't work:

_unit is an OBJECT reference, and you tried to compare the object to a string. The script parser can't cast a object reference type to a string type.

However

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

? _unit == Player

will work, as player is an object reference in itself. The two types are compatible and the compare will work.

If you REALLY want to cast an object to a string, use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

? format["%1", _unit] == "aP": goto "itmatches"

Share this post


Link to post
Share on other sites

I bet raedor is going to post that mrZig was right and that I'm too fast. tounge_o.gif

And thanks Mr. Zombie. I got the idea now! wink_o.gif

Share this post


Link to post
Share on other sites

but <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? !_unit == Player won't work.

and mrs avon does not want to compare _unit with a string. she wants to check if it is the same unit like the player... wink_o.gif

/edit: @avon: you placed your bet too late tounge_o.gifblues.gif

Share this post


Link to post
Share on other sites
but <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? !_unit == Player
won't work.

and mrs avon does not want to compare _unit with a string. she wants to check if it is the same unit like the player...  wink_o.gif

/edit: @avon: you placed your bet too late  tounge_o.gif  blues.gif

You sure?

Cos Avon said this did work on the previous page...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

? _unit != player: exit

ghostface.gif

/mutters to self never to bother interfering in scripting threads again biggrin_o.gif

Share this post


Link to post
Share on other sites

avon, you dont really need to name your player unit for SP missions, he's always "PLAYER"

aP is just a tag that got used by early mission makers and it stuck.......

sorry about forgetting the () tounge_o.gif

You COULD get rid of that line by adding a condition to the eventhandler, to only run the sqs if the killer was the player, thats simple enough too.

Share this post


Link to post
Share on other sites
You COULD get rid of that line by adding a condition to the eventhandler, to only run the sqs if the killer was the player, thats simple enough too.

Now he tells me!

Woman%20Pulling%20Hair.gif

To summarize: I've chucked out a lot of code. All I need is a global variable, preset to zero in init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">scoreadjust = 0

Then whenever I need to give a negative score, I just code on the trigger itself:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">scoreadjust = scoreadjust - 1000

Whenever I need to add a positive score, I simply use:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player adRating 1000

This would include the addEventHandler, which now looks like this and will only adjust the score if the player killed the vehicle:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehicle addEventHandler ["killed",{? _this select 1 == player:player addRating 1000}]

And in my mission pre-end processing, I finalize the score with:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addRating scoreadjust

Thank you all for your time. You may go home now. crazy_o.gif

Share this post


Link to post
Share on other sites

That eventhandler won't work, you'll get an error.

Use this,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehicle addEventHandler ["killed",{IF ((_this select 1) == player) THEN {player addRating 1000}}]

And remember the _this select 1 !!!

Share this post


Link to post
Share on other sites
That eventhandler won't work, you'll get an error.

Use this,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehicle addEventHandler ["killed",{IF ((_this select 1) == player) THEN {player addRating 1000}}]

EDIT: Thanks. Will test.

Quote[/b] ]And remember the _this select 1 !!!

doh.jpg

Share this post


Link to post
Share on other sites
That eventhandler won't work, you'll get an error.

Use this,

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vehicle addEventHandler ["killed",{IF ((_this select 1) == player) THEN {player addRating 1000}}]

EDIT: Thanks. Will test.

Didn't work. That is, the script with the addEventHandler command ran without error messages but my score was not adjusted. rock.gif

Share this post


Link to post
Share on other sites

Being that I'm piloting a plane, I also tried:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_plane addEventHandler ["killed",{IF ((_this select 1) == vehicle player) THEN {player addRating 4000}}]

but <span style='color:red'>vehicle player</span> didn't help either. sad_o.gif

Share this post


Link to post
Share on other sites

the killer is the player, (usually driver) always.

Just to check for sure, you ARE putting the eventhandler in the INIT of the target units aren't you?

Hint: you dont need to put it into each single target in a group, rather in just one INIT field enter your line..... and add <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> foreach units group this

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler ["killed",{IF ((_this select 1) == vehicle player) THEN {player addRating 4000}}]} forEach units group thisshould work. or make a biig trigger activated by all (?) and wirte in the onAct line:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler ["killed",{IF ((_this select 1) == vehicle player) THEN {player addRating 4000}}]} forEach thislist

Share this post


Link to post
Share on other sites
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler ["killed",{IF ((_this select 1) == vehicle player) THEN {player addRating 4000}}]} forEach units group this
should work. or make a biig trigger activated by all (?) and wirte in the onAct line:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler ["killed",{IF ((_this select 1) == vehicle player) THEN {player addRating 4000}}]} forEach thislist

No go! sad_o.gif Neither of these worked.

Here's the script that issues that addEventHandler command:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_apos = [getmarkerpos "VplaneStart" select 0,getmarkerpos "VplaneStart" select 1,(getmarkerpos "VplaneStart" select 2) + 1500]

_aSpd = 600

_aDir = 220

_aVel = [sin(_aDir)*_aSpd, cos(_aDir)*_aSpd,0]

vpilot = []

"SoldierEPilot" createUnit [getmarkerpos "VplaneStart",groupAlpha,"vpilot=this",1]

_plane = "Su27" createVehicle [0,0]

_plane setPos _apos

vpilot moveInDriver _plane

_plane engineOn true

_plane setSkill 1

_plane setDir _aDir

_plane setVelocity _aVel

while {(speed _plane)<_aSpd} do {_aVel=velocity _plane; _plane setVelocity [1.05*_aVel select 0, 1.05*_aVel select 1, 0]}

_plane setBehaviour "Combat"

_plane setCombatMode "RED"

{_plane addEventHandler ["killed",{IF ((_this select 1) == player) THEN {player addRating 4000}}]} forEach thisList

#target1

? not (canMove h1) : goto "target2"

_plane domove (getpos h1)

_plane dotarget h1

_plane dofire h1

~1

goto "target1"

#target2

? not (canMove h2) : goto "exit"

_plane domove (getpos h2)

_plane dotarget h2

_plane dofire h2

~1

goto "target2"

#exit

exit

I discussed this script here a few weeks ago. It spawns an enemy aircraft in flight.

Life is never simple. crazy_o.gif

UPDATE: Also tried specifying vehicle player instead of just player. No difference.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">...

{_plane addEventHandler ["killed",{IF ((_this select 1) == player) THEN {player addRating 4000}}]} forEach thisList

...

Whats the "forEach thisList" part for?

That basically means "Exec this line of code once for every unit in this trigger list". But this is not a trigger and there is no list so that is useless.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_plane addEventHandler ["killed",{IF (vehicle (_this select 1) == vehicle player) THEN {player addRating 4000;Hint "Player rating adjusted"}}]

This should work (Note the check to see if the vehicle of the killer is equal to the vehicle of the player)

Edit: Added a hint in the EH so you can see if it really did adjust

And if this doesnt work then I'm not sure whats going on, unless somehow you arent killing the plane afterall

Share this post


Link to post
Share on other sites
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">...

{_plane addEventHandler ["killed",{IF ((_this select 1) == player) THEN {player addRating 4000}}]} forEach thisList

...

Whats the "forEach thisList" part for?

Indeed, when specifying "forEach thisList" or "foreach units group this", things were extremly fickle.

But I've discovered where the problem lies: the SFM SU27 addon.

Backing up a bit: specifying "vehicle player" in the "IF" statement does the job. Here's my working addEventHanlder line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_plane addEventHandler ["killed",{hint format ["Name of killer is: %1", (_this select 1)];IF ((_this select 1) == vehicle player) THEN {player addRating 4000}}]

When the script runs to create the SU27, sometimes the event handler doesn't trigger, even though the SU27 is shot to bits (thanks to FootMunch's F16 MIGCAP biggrin_o.gif ). At other times, it tells me that the killer is something like "12bcc500H NOID, SFM_SU27", which is completely wacky, considering that I'm displaying the value of "_this select 1". crazy_o.gif

When I change the script to vCreateVehicle a standard BIS SU25, it works perfectly.

Now, I'm curious as to how an addon, no matter what code it contains, can mess up returned values from this "killed" addEventHandler command. The value of "_this select 1" should be totally in OFP's control.

OFP bug? Evil Russian addon? Hmmm..........................

Share this post


Link to post
Share on other sites
When the script runs to create the SU27, sometimes the event handler doesn't trigger, even though the SU27 is shot to bits (thanks to FootMunch's F16 MIGCAP biggrin_o.gif ). At other times, it tells me that the killer is something like "12bcc500H NOID, SFM_SU27", which is completely wacky, considering that I'm displaying the value of "_this select 1". crazy_o.gif

Argh! crazy_o.gif

Same problem with FootMunch's SU-27 Flanker! crazy_o.gif

Share this post


Link to post
Share on other sites

It _could_ be a 'timing' issue. The init scripts on 3rd party

planes usually take a few 'beats' to run, unlike the BIS planes.

Maybe insert a half-second delay after creation before

addeventhandler (or check on alive _plane)?

Share this post


Link to post
Share on other sites
It _could_ be a 'timing' issue. The init scripts on 3rd party

planes usually take a few 'beats' to run, unlike the BIS planes.

Maybe insert a half-second delay after creation before

addeventhandler (or check on alive _plane)?

I tried a 1 second delay. Same problem.

Share this post


Link to post
Share on other sites

It could also be a consequence of the proximity detonation

scripting. In that case, a large 'target' box is created in the

path of the missile: the missile hits it and explodes, hopefully

catching the OPFOR plane in the blast. In that case,

the firing-plane only 'kills' the proximity target, rather than

the 'dead' plane itself.

Does it happen when a particular weapon is used? If it's guns

only (via removeweapon), there _shouldn't_ be a problem.

I'm not sure if the SFM Flanker uses proximity detonation, but

both the F-16 and Su-27 from me do.

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  

×