Home   Help Search Login Register  

Author Topic: Pilot Reward Script  (Read 2093 times)

0 Members and 1 Guest are viewing this topic.

Offline trooper543

  • Members
  • *
Pilot Reward Script
« on: 24 Jan 2009, 03:14:53 »
Hi there again all

Again i am need of some help regarding a pilot reward script that i would very much like to make a bulk standard reward script for our clan pilots

This script was orginally done by Pixel and is as follows

1. In the initLine of the choppers you need a "getin" eventhandler (it is triggered when you enter the vehicle

Code: [Select]
this addEventHandler ["GetIn", {nul = [_this select 0,_this select 1] execVM "scorepilot
2. You need some GLOBAL variables that are evaluated in the script
currentMission = "name current objective"; // when you get in the chopper it tells you where to go
pilotlist = []; // to make sure players don't cheat and get points getting in and out airplane/ make an array in the init.sqf or playerinit.sqf
missionpos = [x,y,z]; //coordinate to calculate the distance to the objective you have to fly to land and get points as a pilot

Code: [Select]

if (!local player) exitwith {};

private ["_player","_vehicle","_isPilot","_i","_q","_passengers"];

_player = player;
_vehicle = _this select 0;
_isPilot = _this select 1;

// only run if player is pilot
if (_player != driver _vehicle) exitWith {};

If (_isPilot == "driver") then
{
hint format["Get passengers and\nfly them to %1",currentMission];
sleep 3;
hint "";

_i = round (getPos _vehicle select 2);
while {_i != -100} do
{

// make a delay of 2 minutes to make sure player is getting score once
if (name _player in pilotlist) then {sleep 120; pilotlist = pilotlist - [name _player]};

// flight to missionobjective
if (800 > _vehicle distance missionpos) then
{
hint format ["%1 area",currentMission];
sleep 0.5;
hint "";
sleep 0.5;
hint format ["%1 area",currentMission];
sleep 3;
hint "";

_q = round (getPos _vehicle select 2);
while {_q != -100} do
{
//landing
if (round (getPos _vehicle select 2) < 3) then
{
if ((!(name _player in pilotlist))) then
{
//count passengers
_vehicle = _this select 0;
_passengers = crew _vehicle;
{
if ((!isplayer _x) or (_x == driver _vehicle)) then {
_passengers = _passengers - [_x];
};
} foreach _passengers;

sleep 2;
hint "";

//add pilotscore
_player addscore count _passengers;

// pospone pilotscore reoccurance
pilotlist = pilotlist + [name _player];
};
};
_q = if (_player == vehicle _player || 800 < _vehicle distance missionpos || !alive _player) then {-100} else {round (getPos _vehicle select 2)};
sleep 1;
};
};
_i = if (_player == vehicle _player || !alive _player) then {-100} else {round (getPos _vehicle select 2)};
sleep 1;
};

};

The changes i would very much like to have within this reward script is that it could also be used on an airplane dropping paratroopers and cargo

However i am not a scripter at all,

Could someone be kind enough to help me change this (Naturally all credits will to be the Person that helped and Pixel as this is his script originally)

The part i would like to have changed is that Mission Pos and current Mission Name be changed to have the passenger (player ) to mapclick where he wants to be dropped off

I need this to work for both airplanes and choppers

As this will allow that the pilot gets score

again many thanks in advance for any help given

Offline fallujahmedic

  • Members
  • *
Re: Pilot Reward Script
« Reply #1 on: 28 Jan 2009, 22:31:18 »
Would that go for successful vehicle lifts and and wreck lifts?

Offline trooper543

  • Members
  • *
Re: Pilot Reward Script
« Reply #2 on: 01 Feb 2009, 18:09:48 »
@fallujahmedic

Mate i wouldnt know but i suspose you could get it to work for your needs

I am not a scripter unfortunatley, i was hoping that someone from opec would be able to help wih this script


Offline Rommel92

  • Members
  • *
Re: Pilot Reward Script
« Reply #3 on: 01 Feb 2009, 21:17:10 »
Your requested changes are not very clear/concise in manner, perhaps you could elaborate on what exactly it is that you want.

In any case, heres an optimized version of your script.
<SEE NEWER POST>

UNTESTED

After reading your post again, you mentioned you wanted an onmapclick event to record where the passenger wants to go? This would be bit bigger task as you would need to transfer that across the network, it wouldn't take too long for me to make, but I'll do it tonight, as I'm eating breakfast while I wrote the above. (Added in comments where your requests would go)
« Last Edit: 05 Feb 2009, 06:15:39 by Rommel92 »

Offline trooper543

  • Members
  • *
Re: Pilot Reward Script
« Reply #4 on: 02 Feb 2009, 06:04:01 »
@Rommel

Many Many thanks for looking at this again mate.

Just clarify what i am trying to do,

1. The aim of the script is to have a reward system for our clan airforce pilots. Particulary for our taxi and logistics pilots.

2.  The idea is that when we ask a pilot to pick us up we want him to earn points for every passenger picked up and dropped off, the same would apply when the pilots drops cargo (Parachutes the cargo out )


3. Would very much like to extend this to our (Ground) logistics section, using the same concept as above if possible.

I am extremely grateful for your intrest and help in acheiving this

Again many thanks in advance


Offline fallujahmedic

  • Members
  • *
Re: Pilot Reward Script
« Reply #5 on: 04 Feb 2009, 22:11:44 »
 Trooper, that's an interesting concept. I had always wondered about a scoring/reward system for those not actively involved in combat operations. You know, for the guy who drives the repair truck across the island to successfully repair a vehicle or a Wrecker pilot who lifts 5 wrecks to the repair point, hell, even the medic that heals 5 teammates. Just because someone is not an Uber Specop doesn't mean he should get penalized with a low ranking. Another thought is the guy that decides to hang back and defend the base from the Enemy. Not everyone can be on the front lines, someone has to guard the home front.  :good:

Offline Rommel92

  • Members
  • *
Re: Pilot Reward Script
« Reply #6 on: 05 Feb 2009, 07:06:39 »
... check below ...

Optimised to exact specifications as specified below, I can add a onmapclickeventhandler later, but for now this will work much nicer then the last, and allows for the bugs such as:

players getting into a cargo, then switching to pilot.
Helicopter to be damaged, repaired, and it will still run the script.

Known bugs are:
In blackhawks, secondary gunners will not get the points per person airlifted.

Any others just post them here, and I'll fix it, including any other errors cause I am unable to test this.
« Last Edit: 07 Feb 2009, 02:26:07 by Rommel92 »

Offline trooper543

  • Members
  • *
Re: Pilot Reward Script
« Reply #7 on: 07 Feb 2009, 00:39:51 »
@Rommel

Thanks ever so much

Just tried the script in a test mission and then hosted it over MP (ran a test between myself and mate)

Noticed the following:

1. When placing the

this addeventhandler ["getin", {_this call compile preprocessFile "ROMM_fAirAuth.sqf"}];

in the init of the chopper (BWC PUMA) it gives and error

2. When placing the same addeventhandler within the Pilot Init, there was no error and in the MP Test there was no score apearing

Have i set this up like an Idiot ? If i may ask that you enlighten the idiot  :whistle: :-[

Many thanks in advance


Offline Rommel92

  • Members
  • *
Re: Pilot Reward Script
« Reply #8 on: 07 Feb 2009, 02:25:41 »
You've set it up fine, it was a stupid error on my behalf. I had the chance to test it ingame, and found that SP testing doesn't work because the player doesn't have score. But in MP it works now.

Sorry for the inconvience.  :whistle:

Code: (ROMM_fAirAuth.sqf) [Select]
//Place the code below into the Airvehicles initialisation line in the editor
//this addeventhandler ["getin", {_this call compile preprocessFile "ROMM_fAirAuth.sqf"}];

private["_v","_p"];
_v = _this select 0;
_p = _this select 2;

scopename "init";

if (local player) then {
if (isplayer _p) then {
if (_v iskindof "air") then {
if NOT (gunner _v == _p || driver _v == _p || commander _v == _p) then {
while {_p in crew _v} do
{
if (commander _v == _p) then {breakto "init"};
if (driver _v == _p) then {breakto "init"};
if (gunner _v == _p) then {breakto "init"};
sleep 1;
};
} else {
while {_p in crew _v} do {
while {alive _v AND isengineon _v} do {
private"_c";
_c = crew _v;
sleep 10;
{
if NOT (gunner _v == _x OR driver _v == _x OR commander _v == _x) then {
if NOT (_x in crew _v) then {
player addscore 1;
};
};
} foreach _c;
};
sleep 1;
};
};
};
};
};
« Last Edit: 07 Feb 2009, 02:30:58 by Rommel92 »

Offline trooper543

  • Members
  • *
Re: Pilot Reward Script
« Reply #9 on: 13 Feb 2009, 18:36:59 »
@Rommel

Sorry for the late response !

Many Many Thanks for this will test and let you know how it goes

again many thanks for this mate