Jump to content
doomnet

[SOLVED] How to end mission based on a player number of kills reached ?

Recommended Posts

Hi,

 

Could someone help with my PvP mission ?

I need to check if player reach 100 kills then the mission ends for everyone and it shows the player name with his stats in a message to everyone just before the mission ends

 

I really don't know how to do this

 

thanks in advance for helping me

Share this post


Link to post
Share on other sites

You can count player kills in "Killed" event handler, and call endMission or failMission commands

 

Ok thank you but could you give me an example because i don't know how to write it

Share this post


Link to post
Share on other sites

Something like

PLAYERKILLS = 0;
PLAYERDEATHS = 0;

addMissionEventHandler ["EntityKilled", {
	private _victim = _this select 0;
	private _killer = _this select 1;

	if (isPlayer _killer) then {
		PLAYERKILLS = PLAYERKILLS + 1};

	if (isPlayer _victim) then {
		PLAYERDEATHS = PLAYERDEATHS + 1};

	if (PLAYERKILLS >= 10) then {
		endMission "END1"};

	if (PLAYERDEATHS >= 10) then {
		endMission "LOSER"};
}];
  • Like 1

Share this post


Link to post
Share on other sites

Ok i see thank you Serena i go try this right now !

Share this post


Link to post
Share on other sites

Note that endMission has a local effect only. To end globally use remoteExec.

Share this post


Link to post
Share on other sites

Note that endMission has a local effect only. To end globally use remoteExec.

 

Yes i think i will use endMissionServer instead to end missions on all clients !

Share this post


Link to post
Share on other sites

Yes i think i will use endMissionServer instead to end missions on all clients !

 

I don't believe there's any endMissionServer command?  Instead try this for the ArmA 3 style mission end:

"end1" remoteExec ["BIS_fnc_endMission"];

That will run the end1 mission end function on all clients.

  • Like 1

Share this post


Link to post
Share on other sites

Yes there is that command it says its better to use this to end properly a mission for all clients according to the wiki

 

"BIS_fnc_endMissionServer"

 

and i already use that to end mission and works good very good

 

because as mrcurry says endMission is local

 

remoteExec i never used before and i don't know how it works but its not needed

 

because of the command BIS_fnc_endMissionServer

 

But anyway thanks for your reply but that was not the question of the topic,

also it has already been answered ! ;)

Share this post


Link to post
Share on other sites

Ahh, that would be a function rather than a command.  If you wanted to use that instead you'd do:

["Won"] remoteExec ["BIS_fnc_endMissionServer", 2];

(The 2 means "only run on the server").

 

Actually, reading this thread makes it sound like BIS_fnc_endMissionServer is mostly used to end the mission on a dedicated server, basically just turning everything off instead of the nice exit graphics and music that a client run BIS_fnc_endMission would generate for players.

 

So, maybe something like:

// Run on all clients but not server.
"end1" remoteExec ["BIS_fnc_endMission", -2];

// Code from special ed - https://goo.gl/5cYjNV
if (isDedicated) then
    {
        sleep 25;
        // Only run on server.
        ["Won"] remoteExec ["BIS_fnc_endMissionServer", 2];
    };

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

×