Jump to content
Sign in to follow this  
braincrush

addscore working in host not working on dedicated

Recommended Posts

im trying to make it work on dedicated server , could someone point me in the right direction please ?

if (!local player) exitwith {};

private ["_player","_playeruid"];

_playeruid = getPlayerUID player;
_player = player;

switch (_playeruid) do
{
	case "xxxxxx":
 	  	{
	givemoney = hint "Hello xxxxxx here's your money !";
	_player addscore 400; 
	   	};
 		case "xxxxxx":
 	  	{
	givemoney =  hint "Hello xxxxxx here's your money !";
	_player addscore 400;;
	   	};
 	  	case "xxxxxx":
 	  	{
	givemoney = hint "Hello xxxxxx here's your money !";
	_player addscore 400; 
	   	};
  	  	case "xxxxxx":
 	  	{
	givemoney = hint "Hello xxxxxx here's your money !";
	_player addscore 400;
	   	}; 
 	   	case "xxxxxx":
 	  	{
	givemoney = hint "Hello xxxxxx here's your money !";
	_player addscore 400;
	   	};	
  	   	case "xxxxxx";
 	  	{
  	givemoney = hint "Hello xxxxxx theres your change !";
  	_player addscore 5;
	   	};	
  	   	default
 	  	{
	givemoney = hint "You're not a member of xxxxxx !";
	   	};

Share this post


Link to post
Share on other sites

Not quite sure how that's supposed to work since you've xxx'd out a lot, but this might be one way of rewriting it to avoid all the case statements:

// Call by _nil = ["MONEY"] execVM "givemoney.sqf";
// or _nil = ["CHANGE"] execVM "givemoney.sqf";

private ["_score","_paid","_msg","_type","_playeruid","_moneyList","_changeList"];
if (!local player) exitwith {};

_type = _this select 0;
_type = toLower(_type);
_playeruid = getPlayerUID player;
_paid = false;

_moneyList = ["xxx1","xxx2","xxx3","xxx4"];
_changeList = ["yyy1"];

if (_playeruid in _moneyList && _type == "money" && !_paid) then {_score = 400; _paid = true};
if (_playeruid in _changeList && _type == "change" && !_paid) then {_score = 5; _paid = true};

if (!_paid) then {
_msg = format["Sorry, %1, but you're not due any money.", name player];	
} else {
_msg = format["Hello %1, here's your %2!", name player, _type];
     player addScore _score;
};

hint _msg;

Share this post


Link to post
Share on other sites

sorry i thought that might be a problem it was supposed to look like this :

_player = player;

switch (_playeruid) do
{
	case "[b]plaierUID[/b]":
 	  	{
	givemoney = hint "Hello [b]playername [/b]here's your money !";
	_player addscore 400; 
	   	};

thanks for rewriting the code for me , only one thing , could you tell me how to call it from the action menu ? my one was assign to satellite phone and you could choose option "transfer money" than the script was adding points if the player id was correct.

Share this post


Link to post
Share on other sites
_player = player;

switch (_playeruid) do
{
	case "plaierUID":
 	  	{
	givemoney = hint format["Hello %1 here's your money !", name player];
	_player addscore 400; 
	   	};

Share this post


Link to post
Share on other sites

it still does'nt work on dedicated server (works fine on selfhosted)

the script is called by:

this addAction ["transfer money","atm.sqf"];

and it looks like that now :

if (!local player) exitwith {};

private ["_player","_playeruid"];

_playeruid = getPlayerUID player;
_player = player;

switch (_playeruid) do
{
	case "000001":
 	  	{
	givemoney = hint format["Hello %1 here's your money !", name player];
	_player addscore 400; 
	   	};   	   	
		case "000002":
 	  	{
	givemoney = hint format["Hello %1 here's your money !", name player];
	_player addscore 400; 
	   	};
		default
 	  	{
	givemoney = hint "You're not a member of the team !";
	   	};
};

Share this post


Link to post
Share on other sites

oh , thanks , if its not a problem could you please tell me where can i find an explanation how to run commands on the server , i know its probably silly question but i've only started my work with arma editor.

Share this post


Link to post
Share on other sites

For now use something like the following (not tested but should work):

Put the following into init.sqf:

if (isServer) then {
"paddscore" addPublicVariableEventHandler {
	((_this select 1) select 0) addScore ((_this select 1) select 1);
};
};

And on the client:

if (isServer) then {
player addScore _score_to_add; // for hosted environment
} else {
paddscore = [player, _score_to_add]; publicVariable "paddscore";
};

It sends a publicVariable to the server and fires the publicVariable EH only on the server and adds the score.

Maybe the Multiplayer Framework can help too (though I've never used it as it is not flexible enough so I'm not sure).

Xeno

Share this post


Link to post
Share on other sites
Maybe the Multiplayer Framework can help too (though I've never used it as it is not flexible enough so I'm not sure).

Thanks a lot for the publicVariable example, very helpful! I'd always wondered about a good way to "get the server to run something".

As for the MPFramework, I've been having a horrible time getting it to work... Seems it's ideal for HOSTED games, but it's failing miserably in dedicated servers.

Share this post


Link to post
Share on other sites
Thanks a lot for the publicVariable example, very helpful! I'd always wondered about a good way to "get the server to run something".

Yet one problem remains, the publicVariable is not only transfered to the server but also to all other clients too (and JIP clients also receive the latest state of it). But as the PV EH is only registered on the server it will only fire there.

Xeno

Share this post


Link to post
Share on other sites

It sends a publicVariable to the server and fires the publicVariable EH only on the server and adds the score.

Maybe the Multiplayer Framework can help too (though I've never used it as it is not flexible enough so I'm not sure).

Xeno

thanks a lot, and the final question : does this mean that everytime i want to use public variable i have to use : addPublicVariableEventHandler in my mission init ?

Share this post


Link to post
Share on other sites

Nope, you can have triggers respond to publicVariables without the eventhandler being required.

Share this post


Link to post
Share on other sites

ok thanks , and ive tried Xeno's example but still no luck on dedicated server :( it works on the hosted game , ive found similiar script in domination (aircraft factory) it deducts points using addscore -x and it looks exactly like mine script with one difference , the domination one works :)

Edited by braincrush

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  

×