Jump to content
bong oh

Trying make custom point& store system...

Recommended Posts

I'm trying to create a system that gets the local score by kill count and capture point and uses it in the store.

This is the referenced youtube...
https://www.youtube.com/watch?v=8ARJ_Ap_AaQ&list=PLnHeglBaPYu_uYy_VAov71-Y3_Aonff0i&index=13&ab_channel=SneakyKittyGaming
My mission flow is
1. Get points through kill or capture.
2. Use this score to get personal weapons from the store.
3. When out of the trigger range, the equipment mounted is stored, and even if the player dies equipped with other equipment, he will be revived to the previously stored equipment.

4. player can check his money by groupchat

but problem is...

 

1. how sqf file access to initplyaerlocal's variable?

2. That is too hard saved equipment when out of trigger range

 

 

So..Briefly summarized

    initPlayerLocal

                |

    _x addEventHandler["Killed",
    {
        _unit = (_this select 0);
        _killer = (_this select 1);
        pKilled = [_unit, _killer];
        publicVariableServer "pKilled";
    }];

          |

    initServer



_distance = _unit distance _killer;
    if(_distance<100) then
    {
        _score=100;
    };
    if(_distance>=100) then{
    _score=100+(_distance % 100)*10
    };
    
    pClient = _score;
    _cID publicVariableClient "pClient";

         |

 initPlayerLocal

        |

  _TotalScore=_TotalScore+_score



and, addAction[(("Wallet")),"showScore.sqf"

       |

 showScore.sqf

groupChat (format["%1 Points", _TotalScore]);]; <- here is not work

How can I do?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
4 minutes ago, Spriterfight said:

You will need profilenamespace to store information 

 

Then if I create a multiplayer with 64 players, should I make 64 player variables?

Share this post


Link to post
Share on other sites
59 minutes ago, Spriterfight said:

I would advice a database like 

 

 

Wow, that's a great program!
But it's always painful to learn something interesting but new. In fact, I can't find example code.

Server

   |     

Joel[ClientID, Account, killCount, StoredGear], addie[TotalScore,killCount,StoredGear], wallcot[TotalScore,killCount,StoredGear].....

 

 

This is what I understood.

1. _inidbi = ["ClientID"," Account"," killCount"," StoredGear"] call OO_INIDBI;    ->  where I declare? initPlayerLocal?

and when player killed, send to server  publicVariableServer "pKilled"->(_user,_killer)

 

2. In initServer, bring _inidBi and query and read _inidbi 

     1) _Totalscore =  ["read", ["_killer's ClientID", "Account -(example : 100)", 0]] call _inidbi;

and Server start calculate Bonus 

_distance = _unit distance _killer;     if(_distance<100) then     {         _Totalscore =_Totalscore +100;     };     if(_distance>=100) then{     _Totalscore =_Totalscore +100+(_distance % 100)*10     };   

3.  overwritten to DB

     1) ["write", ["_killer's ClientID", "Account", newAccount(example : 140)]] call _inidbi;

 

finish?

Wow...I know that is awesome mod. but I don't know I understood

And there's a long way to go before I store the equipped..

 

 

 

 

Share this post


Link to post
Share on other sites

 

In the end, we decided to change the project goal due to technical problems. From personal to team score system

 

 

Share this post


Link to post
Share on other sites
5 minutes ago, bong oh said:

 

In the end, we decided to change the project goal due to technical problems. From personal to team score system

 

 

Yeah its easier but why dont you try something like a money system and you will gain money from kills and stuff

Share this post


Link to post
Share on other sites
22 minutes ago, Spriterfight said:

Yeah its easier but why dont you try something like a money system and you will gain money from kills and stuff

Is there something mod to support money system?

oh if that is exist... I waste my time 

 

+ and Is score system can buy or sell to shop? I didn't know that function. 

  

Share this post


Link to post
Share on other sites

Yes write this in the init.sqf

money = profileNamespace getVariable ["playerMoney", 0]; //this will give the variable a default value of 0, if the variable isnt found in the profilenamespace.

then write a new sqf with the name of money.sqf 

money = money + 1000; //in this 1000 is the starting money

hint format["Yay! I have now %1 %2", money, "$"];

profileNamespace setVariable ["playerMoney", money];// 
saveProfileNamespace;

make a trigger that is not repeatable
Activation: Blufor
On Activation:

[[], "money.sqf"] call BIS_fnc_execVM


Start the mission, move into the trigger until message shows up. Exit the mission and move again in the trigger, you will see that the value is now different.

 

inside the debug console use this before you exit the scenario

 

profileNamespace setVariable ["playerMoney", nil];
saveProfileNamespace;

 

Share this post


Link to post
Share on other sites
32 minutes ago, Spriterfight said:

Yes write this in the init.sqf


money = profileNamespace getVariable ["playerMoney", 0]; //this will give the variable a default value of 0, if the variable isnt found in the profilenamespace.

then write a new sqf with the name of money.sqf 


money = money + 1000; //in this 1000 is the starting money

hint format["Yay! I have now %1 %2", money, "$"];

profileNamespace setVariable ["playerMoney", money];// 
saveProfileNamespace;

make a trigger that is not repeatable
Activation: Blufor
On Activation:


[[], "money.sqf"] call BIS_fnc_execVM


Start the mission, move into the trigger until message shows up. Exit the mission and move again in the trigger, you will see that the value is now different.

 

inside the debug console use this before you exit the scenario

 


profileNamespace setVariable ["playerMoney", nil];
saveProfileNamespace;

 

Wow thanks to quick reply then I try this...

In init make pofile wallet like John[100], meril[200], addie[500]....

 

init.sqf

TL_killCount = profileNamespace getVariable ["playerMoney", 0];

 

In initPlayerLocal, when Killed, bring [_unit, _killer] to Server

 

initPlayerLocal.sqf


{
	_x addEventHandler["Killed",
	{
		_unit = (_this select 0);
		_killer = (_this select 1);
		pKilled = [_unit, _killer];		
		publicVariableServer "pKilled";
	}];
}forEach allUnits;

//"pClient" addPublicVariableEventHandler{
	
//	_money=(_this select 1);
//	hint str ["+RangeBonus : %1!"+_money];

 

In initServer, 

1. get [_user,_killer] info, and calculate distance between them.

if <100 : no bonus

  >=100 : each 100m, increase 10 bonus( 110: +10 bonus/ 350 : +30 bonus)

 

and _TotalScore = 100+_bonus

2. setVariable unit's playerMoney 

 

initServer.sqf

"pKilled" addPublicVariableEventhandler
{
	private ["_data"];
	private _bonus =0;
	private _TotalScore = 100+_bonus;
	_data = (_this select 1);
	_unit = (_data select 0);
	_killer = (_data select 1);
	_cID = owner _killer;
	_distance = _unit distance _killer;
	
//	hint str _distance;
	if(_distance<100) then
	{
		_bonus=0;
	};
// each kill range over 100m bouns will increase 10
	if(_distance>=100) then{
		_bonus=(_distance%100)*10;
		hint str ["+Range Bonus : ,%1!", _bonus];
	};
	_unit setVariable ["playerMoney",_TotalScore];
	
//	pClient = _score;
//	_cID publicVariableClient "pClient";
};

and in player character's init   /for see my wallet anytime

 

this addAction[("<t color=""#00FFCD"">"+("Wallet")+"</t>"),"money.sqf"];

 

money.sqf 


player groupChat (format["%1 Points", TL_killCount]);

but , still eror so I just finding point

 

Share this post


Link to post
Share on other sites

@bong oh,
Check this out,

Spoiler

Here's an account function,


YOU_fnc_account =
{	params [["_caller", objNull, [objNull]], ["_amount", 0, [0]]];

	private	_account = _caller getvariable "YOU_account";
	
	_caller setvariable ["YOU_account", _account + _amount];
if (_amount < 0) then {
			systemChat format ["You spend $%1", _amount] 
		} else {
			if (_amount > 0) then {
			systemChat format ["You earned $%1", _amount]
			};
		};
	systemChat format ["Balance $%1", _account+ _amount];
};

call with:


[player, 10] call you_fnc_account; // add 10
[player, -10] call you_fnc_account; // subtract 10
[player] call you_fnc_account;	//display balance only

Here's an event handler for scoring on kill (call on enemy group),


	{
	_x addEventHandler ["Killed", {
		params ["_unit", "_killer", "_instigator", "_useEffects"];
		[_killer, 100] call YOU_fnc_account
	}];
	} forEach units _grp;

and an addaction for NPC shop (paste in NPC init dialog or add via script),


	this addAction ["Buy Weapon $1200", "if (((_this select 1) getVariable ""YOU_account"")>1200) then {systemChat "you bought a gun!"; [_this select 1, -1200] call YOU_fnc_account;} else {systemChat ""Not Enough Money""};"];

Just some ideas to get you started.

Have fun!

Edited by wogz187

Share this post


Link to post
Share on other sites
4 hours ago, wogz187 said:

@bong oh,
Check this out,

  Reveal hidden contents

Here's an account function,



YOU_fnc_account =
{	params [["_caller", objNull, [objNull]], ["_amount", 0, [0]]];

	private	_account = _caller getvariable "YOU_account";
	
	_caller setvariable ["YOU_account", _account + _amount];
if (_amount < 0) then {
			systemChat format ["You spend $%1", _amount] 
		} else {
			if (_amount > 0) then {
			systemChat format ["You earned $%1", _amount]
			};
		};
	systemChat format ["Balance $%1", _account+ _amount];
};

call with:



[player, 10] call you_fnc_account; // add 10
[player, -10] call you_fnc_account; // subtract 10
[player] call you_fnc_account;	//display balance only

Here's an event handler for scoring on kill (call on enemy group),



	{
	_x addEventHandler ["Killed", {
		params ["_unit", "_killer", "_instigator", "_useEffects"];
		[_killer, 100] call YOU_fnc_account
	}];
	} forEach units _grp;

and an addaction for NPC shop (paste in NPC init dialog or add via script),



	this addAction ["Buy Weapon $1200", "if (((_this select 1) getVariable ""YOU_account"")>1200) then {systemChat "you bought a gun!"; [_this select 1, -1200] call YOU_fnc_account;} else {systemChat ""Not Enough Money""};"];

Just some ideas to get you started.

Have fun!

damm...I know that is very summary and nice code!

 

.Briefly ...

I put You_fnc_account{} code in init.sqf

initLocalPlayer.sqf  : when killed, _killer and _unit(victim) to Server

initServer.sqf : calculate Distance bonus, and set _killer's account+=bonus

In character's init :  this addAction[("<t color=""#00FFCD"">"+("Wallet")+"</t>"),"money.sqf"];

money.sqf : player groupChat format([player] call you_fnc_account);

shop's init : just copy -> this addAction ["Buy Weapon $1200", "if (((_this select 1) getVariable ""YOU_account"")>1200) then {systemChat "you bought a gun!"; [_this select 1, -1200] call YOU_fnc_account;} else {systemChat ""Not Enough Money""};"];

 but..

error 1 is, When call [player] call you_fnc_account, display 'balance $ scalar NaN'

error 2 is, shop's init error  ....._this #select 1)getVariable........             

 

init.sqf

YOU_fnc_account =
{	params [["_caller", objNull, [objNull]], ["_amount", 0, [0]]];
			
	private	_account = _caller getvariable "YOU_account";
	
	_caller setvariable ["YOU_account", _account + _amount];
if (_amount < 0) then {
			systemChat format ["%1 POINT LOOSE!", _amount] 
		} else {
			if (_amount > 0) then {
			systemChat format ["%1 POINT GAIN!", _amount]
			};
		};
	systemChat format ["Balance $%1", _account+ _amount];
};

initPlayerLocal.sqf

// When killed, bring _unit,_killer to Server
{
	_x addEventHandler["Killed",
	{
		_unit = (_this select 0);
		_killer = (_this select 1);
		pKilled = [_unit, _killer];		
		publicVariableServer "pKilled";
	}];
}forEach allUnits;

initServer.sqf

//calculate Distance bonus and increase _killer's account

"pKilled" addPublicVariableEventhandler
{
	private ["_data"];
	private _bonus =0;

	_data = (_this select 1);
	_unit = (_data select 0);
	_killer = (_data select 1);
	_cID = owner _killer;
	_distance = _unit distance _killer;
	
//	hint str _distance;
	if(_distance<100) then
	{
		_bonus=0;
	};
// each kill range over 100m bouns will increase 10
	if(_distance>=100) then{
		_bonus=(_distance/100)*10;
		_bonus=[_bonus,0] call BIS_fnc_cutDecimals;
		hint format ["+Range Bonus : %1", _bonus];
	};
	_bonus=_bonus+100;
	[_killer,_bonus] call You_fnc_account;
};

In character's init:

this addAction[("<t color=""#00FFCD"">"+("Wallet")+"</t>"),"money.sqf"];

money.sqf <--error    ............ _caller setvariable ["YOU_account", #_account + _amount];......................

player groupChat format ([player]call you_fnc_account);

In store addaction error too

this addAction ["Buy Weapon $1200",
 "if (((_this select 1) getVariable ""YOU_account"")>1200)then 
  {systemChat ""you bought a gun!""; [_this select 1, -1200] call YOU_fnc_account;} 
 else {systemChat ""Not Enough Money""};" 
 ];this setObjectTexture[0,"pic\vest.jpg"];

Oh, I've spent too much of my brain to understand this system today.

I think I'll have to sleep now and do it again tomorrow.

Thank you very much, experts. I think I understood the money system for the first time a little bit.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

wow That is work. god damm miracle...

 

It's amazing how one VR box make all things works. I really feel like there's a long way to go to master arma3 editing.

 

+ when I put in this script in shop object, Error in ["#FirstAidKit",....... 

why this is error?

this addAction ["Buy FirstAidKit $50", "if (((_this select 1) getVariable ""YOU_account"")>50) then 
	{systemChat ""you bought a firstaidkit!""; 
	[_this select 1, -50] call YOU_fnc_account,;
	Itembox addItemCargoGlobal ["FirstAidKit",1];
	}
	else {systemChat ""Not Enough Money""};"];

 

 

 

 

 

Share this post


Link to post
Share on other sites

@bong oh,

this addAction ["Buy FirstAidKit $50", "if (((_this select 1) getVariable ""YOU_account"")>50) then 
	{systemChat ""you bought a firstaidkit!""; 
	[_this select 1, -50] call YOU_fnc_account,; // there's an extra comma here
	Itembox addItemCargoGlobal ["FirstAidKit",1];// strings need 2x quotation marks in AddAction
	}
	else {systemChat ""Not Enough Money""};"];

You can change where the FAK is added,

this addAction ["Buy FirstAidKit $50", "if (((_this select 1) getVariable ""YOU_account"")>50) then 
	{systemChat ""you bought a first aid kit!""; 
	[_this select 1, -50] call YOU_fnc_account;
	player addItem ""FirstAidKit"";
	}
	else {systemChat ""Not Enough Money""};"];

Have fun!

Share this post


Link to post
Share on other sites
28 minutes ago, wogz187 said:

@bong oh,


this addAction ["Buy FirstAidKit $50", "if (((_this select 1) getVariable ""YOU_account"")>50) then 
	{systemChat ""you bought a firstaidkit!""; 
	[_this select 1, -50] call YOU_fnc_account,; // there's an extra comma here
	Itembox addItemCargoGlobal ["FirstAidKit",1];// strings need 2x quotation marks in AddAction
	}
	else {systemChat ""Not Enough Money""};"];

You can change where the FAK is added,


this addAction ["Buy FirstAidKit $50", "if (((_this select 1) getVariable ""YOU_account"")>50) then 
	{systemChat ""you bought a first aid kit!""; 
	[_this select 1, -50] call YOU_fnc_account;
	player addItem ""FirstAidKit"";
	}
	else {systemChat ""Not Enough Money""};"];

Have fun!

Wow..It work

 

Thank you again for spending your time on this matter .

 

I want to help other people's work someday just like you.

Share this post


Link to post
Share on other sites

+ When I respawn, start with equipment when I died.

scripts

onPlayerKilled.sqf

_unit = _this select 0;
[_unit, [_unit, "SavedInventory"]] call BIS_fnc_saveInventory;

onPlayerRespawn.sqf

_unit = _this select 0;
[_unit, [_unit, "SavedInventory"]] call BIS_fnc_loadInventory;

and add trophies (ex. watch, compass, gps) 

bluefor have watch, gps(leader), OPFOR have compass, gps(leader)

It can sell to shop -> gps/watch : 100point  gps : 500 point

 

so I tried shop addAction bub Error

shop object init

_items = items player;
this addAction ["Sell Watch", "if (""ItemWatch"" in _items) then   
 {systemChat ""you sell Watch!"";   
 [_this select 1, +100] call YOU_fnc_account,;   
  _this removeItem ""ItemWatch""; 
 }  
 else {systemChat ""Don't have Watch""};"]; 

How Can I load player's ItemArray in add Action? or just process by sqf?

 

 

 

Vehicleshop Object's init

  
this addAction ["Buy transport truck", "if (((_this select 1) getVariable ""YOU_account"")>1500) then    
 {systemChat ""you bought transport truck!"";    
 [_this select 1, -1500] call YOU_fnc_account,;    
createVehicle [""rhsusf_m1078A1P2_B_D_fmtv_usarmy"",getMarkerPos ""Truck"",[], 0, ""NONE""] ;  
 }   
 else {systemChat ""Not Enough Money""};"];   

another Problem is ... when I respawn that truck, that trunk is full of items and weapons. Can I remove all that item in addAction ?

So I tried find way from this nice discussion

 start - custom loadout When I set eden editor 

 buy weapon and die - save gear

respawn - gear equipped with buying weapon

 

 

 

Share this post


Link to post
Share on other sites

Yes, try clearWeaponCargo Global yourtruckname for your weapons in your vehicle and clearItemCargoGlobal for your items in your vehicle

Ex: _spawnedvehicle = createVehicle [""rhsusf_m1078A1P2_B_D_fmtv_usarmy"",getMarkerPos ""Truck"",[], 0, ""NONE""] ;

 

clearWeaponCargoGlobal _spawnedvehicle;

clearItemCargoGlobal _spawnedvehicle;

Sorry, i am from phone and dont know how to past code on mobile.

 

Best regards!

Share this post


Link to post
Share on other sites
6 hours ago, Spriterfight said:

Yes, try clearWeaponCargo Global yourtruckname for your weapons in your vehicle and clearItemCargoGlobal for your items in your vehicle

Ex: _spawnedvehicle = createVehicle [""rhsusf_m1078A1P2_B_D_fmtv_usarmy"",getMarkerPos ""Truck"",[], 0, ""NONE""] ;

 

clearWeaponCargoGlobal _spawnedvehicle;

clearItemCargoGlobal _spawnedvehicle;

Sorry, i am from phone and dont know how to past code on mobile.

 

Best regards!

Sorry to late reply!

When finish work, Let that code check out!

thanks!

Share this post


Link to post
Share on other sites

3rd problem solved. just respawn to 'respawn_west' marker not respawn module.

 

Share this post


Link to post
Share on other sites
43 minutes ago, bong oh said:

3rd problem solved. just respawn to 'respawn_west' marker not respawn module.

 

I am glad to hear that.

Share this post


Link to post
Share on other sites
this addAction ["Buy Truck", "if (((_this select 1) getVariable ""YOU_account"")>1500) then    
 {systemChat ""you bought Truck!"";    
 [_this select 1, -1500] call YOU_fnc_account,;    
_spawnedvehicle = createVehicle[""rhsusf_m1078A1P2_B_D_fmtv_usarmy"",getMarkerPos""Truck"",[], 0, ""NONE""];
clearBackpackCargoGlobal _spawnedvehicle;
clearWeaponCargoGlobal _spawnedvehicle;
clearMagazineCargoGlobal _spawnedvehicle;
clearItemCargoGlobal _spawnedvehicle;
 }   
 else {systemChat ""Not Enough Money""};"]; 

This code make error createVehicle#[""rhsusf........  

error                             . 

but when spawn vehicle, this code actually work.

I don't understand why this code works correctly in error.

for delete error code...

#2 try 

put out spawn vehicle code to sqf file

this addAction ["Buy Truck", "if (((_this select 1) getVariable ""YOU_account"")>1500) then    
 {systemChat ""you bought Truck!"";    
 [_this select 1, -1500] call Truck,;    
 ""store\Vehicle_truck.sqf"";
 }   
 else {systemChat ""Not Enough Money""};"]; 

Vehicle_truck.sqf

_spawnedvehicle = createVehicle[""rhsusf_m1078A1P2_B_D_fmtv_usarmy"",getMarkerPos""Truck"",[], 0, ""NONE""];
clearBackpackCargoGlobal _spawnedvehicle;
clearWeaponCargoGlobal _spawnedvehicle;
clearMagazineCargoGlobal _spawnedvehicle;
clearItemCargoGlobal _spawnedvehicle;

but this code not work...

---------------------------------------------

below code is sell watch if player have watch in inventory(not assigned) 

Can I ask This code work in Multiplayer? 

The other user's watch doesn't go all out too, does it?

this addAction ["Sell Watch $100", "if (""ItemWatch"" in items (_this select 1)) then  
{systemChat ""you sell Watch!"";  
[_this select 1, 100] call YOU_fnc_account,; 
_this removeItem ""ItemWatch""; 
 } 
 else {systemChat ""No more Watch in your inventory""};"];

 

Share this post


Link to post
Share on other sites

_spawnedvehicle = createVehicle["rhsusf_m1078A1P2_B_D_fmtv_usarmy",getMarkerPos""Truck"",[], 0, ""NONE""];try this you should have two ",between the truck name

Share this post


Link to post
Share on other sites
6 minutes ago, Spriterfight said:

_spawnedvehicle = createVehicle["rhsusf_m1078A1P2_B_D_fmtv_usarmy",getMarkerPos""Truck"",[], 0, ""NONE""];try this you should have two ",between the truck name

I know that.. but i "" needed  when call name in addAction. and  that makes error.

Share this post


Link to post
Share on other sites
1 minute ago, bong oh said:

I know that.. but i "" needed  when call name in addAction. and  that makes error.

let me check this in my game

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

×