Jump to content
Sign in to follow this  
XSOF - Toxx

Running a script on the server

Recommended Posts

Hello,

I know there are various posts about similar issues and I've looked through tons of them but that made me even more confused. So, sorry if asked before, but I'm afraid I will only understand it, if it's about my own script.

I'm currently working on porting over my singleplayer scripts to multiplayer. From the file "onPlayerKilled.sqf" I want to pass the parameters 0 and 1 to a script executed on the server.

_dead = _this select 0;
_killer = _this select 1;

Now, when I pass these two parameters to the server-side script, I want to benefit the killer for the script there and "punish" the dead guy.

Two questions:

1. Running my script with a local .sqf works perfectly but how do I have it run on the server?

2. And how would I go about notifying the individuals with a hint? Like telling the killer whom he killed and telling the dead guy who killed him (no vice-versa. individual messages for each).

If you need more info please let me know.

Thanks a lot in advance

Toxx

Share this post


Link to post
Share on other sites

im very sorry but i cant take u seriously..

u should probably try something easier to do...

anyway because i respect that everyone had to start once.... i will try to answer...

u will have to do a lot of things.. this what u re talking about is just very very beginning of what have to be done..

1. functionReportPlayer (client side)

in this function u have to publicVariableServer the killer, this function will be executed in onPlayerKilled.sqf

2. eventHandler (server side)

this event handler should execute functionPunishPlayer

3. functionPunishPlayer (server side)

in this function u have to publicVariableClient to the killer

4. eventHandler (client side)

this event handler should execute functionPunish

5. functionPunish (client side)

this function punish the killer

if u really want to do this look at scripts that re already done...............

Edited by LoonyWarrior

Share this post


Link to post
Share on other sites

Thank you for your reply LoonyWarrior, you have pointed me into the right direction. Note, I studied software development, when I get a few hints I might be able to find out what to do, but yeah, I'm ambitious. :o

What I really wanted to do is count a player's kills and reward him for kill streaks.

For now my onPlayerKilled.sqf looks like this:

killer = _this select 1;
publicVariableServer "killer";

The init of the server looks like this:

"killer" addPublicVariableEventHandler
{
_killer = _this select 1; // now I know who got the kill and I can increase the killers kill streak
kill = "kill"; // this is just a placeholder as I don't have to transfer a value - I just want to notify the killer

//hint format ["Killer: %1", _killer];
owner (_killer) publicVariableClient kill;	
};

The init of the client looks like this:

killstreakScope 	= 3;
killstreakRPG 		= 5;
killstreakAI		= 7;

killstreak = 0;

"kill" addPublicVariableEventHandler
{
killstreak = killstreak + 1;	

switch (killstreak) do
{
	case (killstreakScope) :
	{
		hint format ["%1: %2-Kill-Streak: Scope Unlocked!", player, killstreakScope];
		player removeItemFromPrimaryWeapon "optic_holosight";
		player addprimaryweaponitem "optic_Hamr";		
	};
	case (killstreakRPG) :
	{
		hint format ["%1: %2-Kill-Streak: RPG Unlocked!", player, killstreakRPG];
		player addMagazine "RPG32_F";
		player addWeapon "launch_RPG32_F";
	};		
	case (killstreakAI) :
	{
		hint format ["%1: %2-Kill-Streak: AI Unlocked!", player, killstreakAI];
		group player createUnit [typeOf player, getPos player, [], 0, "FORM"];
	};
	default
	{

	};
};
};

The solution is a little different from yours but it works perfectly! Thank you so much!

Once it's all finished I'll release it to the community, which will lynch me for COD-alike content.

Edited by Toxx

Share this post


Link to post
Share on other sites

Don't give a shit about people saying COD is shit and this is arma and blah blah blah... if you want to make a COD like mission, then go do it. If you want to make a Peggle Extreme like mission, go do it. Because that is Arma. Freedom to play like you want.

Share this post


Link to post
Share on other sites
Don't give a shit about people saying COD is shit and this is arma and blah blah blah... if you want to make a COD like mission, then go do it. If you want to make a Peggle Extreme like mission, go do it. Because that is Arma. Freedom to play like you want.

Hehe yeah thanks for encouraging me :) I play Arma for quite a few years now, long before Dayz came out. And I love it for its realism but sometimes I just want some nice deathmatch fun :)

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  

×