Andrew_S90

Exile Player Rewards

24 posts in this topic

Exile Player Rewards

This is a system that allows admins to add rewards for players to go claim at any locker.

This system in no way will auto generate rewards for your players for doing missions, logging in, donating, playing, gaining respect or anything like that. You are free to use it to do any of those things but out of the box it just accepts rewards and items and allows the player to claim them.

 

 

As I explained in the above video

You need a players UID and an array of items to pass to the server to add items. It will also take the players UID and the name of a kit which is exactly like infistar spawn boxes, the format is almost 1:1 so you could copy paste them over.

It takes and will give players poptabs, respect, items, weapons, backpacks, uniforms, vests and vehicles. It will also allow you to set quantities for these items and the players can create their own pin# for the claimed vehicles.

 

Here is an example I used to test via admin menu to add items to my own character.

["addRewardsRequest", [getplayeruid player, [["ExileScore",1000],["ExileMoney",2000],"Exile_Item_Flag","Exile_Item_SafeKit",["Exile_Car_Lada_Green",3],"Exile_Chopper_Huey_Green"]]] call ExileClient_system_network_send;

["addKitRequest", [getplayeruid player, "BaseObjectsWood"]] call ExileClient_system_network_send;

The first one allows any array of items and set quantities to be based the other will take a predefined kit that is located server side for customization.

If any items are already in the players collection box it will stack items so that the space is controlled on the database.

 

There are some settings that can be changed in the config.cpp server side, right off the bat you will need to add your UID to the "AllowedRewardGivers" array or it will deny adding items from players from your UID. This security check for admins can be turned off if you want, its there to not allow people or names not in the list to not be able to give rewards to themselves or other players.

All these settings can be found in rewards_server\config.cpp

 

This uses EXTDB2, you can update for EXTDB3 if you wish.

IDD for infistar: 57347

 

Installation 

  1. Download the files from here: https://github.com/Andrew-S90/ExilePlayerRewards/
  2. Client: Place "custom" folder inside of your root Exile.Altis folder
  3. Client: Paste #include "custom\rewards\rewardsDialog.hpp" in the description.ext (also available via github in the config.cpp file)
  4. Client: Modify your class CfgNetworkMessages and paste the following (also available via github in the config.cpp file)
    Spoiler
    
    /* ~~ Rewards Claim Vendor by Andrew_S90 CfgNetworkMessages Start ~~ */
    	class claimItemRequest
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"STRING",
    			"SCALAR",
    			"STRING"
    		};
    	};
    	class claimItemResponse
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"SCALAR",
    			"STRING",
    			"SCALAR",
    			"STRING",
    			"ARRAY"
    		};
    	};
    	class claimVehicleRequest
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"STRING",
    			"STRING"
    		};
    	};
    	class claimVehicleResponse
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"SCALAR",
    			"STRING",
    			"ARRAY"
    		};
    	};
    	class claimTabsRequest
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"STRING",
    			"SCALAR"
    		};
    	};
    	class claimTabsResponse
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"SCALAR",
    			"STRING",
    			"SCALAR",
    			"ARRAY"
    		};
    	};
    	class hasRewardsRequest
    	{
    		module="system_rewards";
    		parameters[]={};
    	};
    	class hasRewardsResponse
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"SCALAR",
    			"ARRAY"
    		};
    	};
    	class addRewardsRequest
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"STRING",
    			"ARRAY"
    		};
    	};
    	class addKitRequest
    	{
    		module="system_rewards";
    		parameters[]=
    		{
    			"STRING",
    			"STRING"
    		};
    	};
    	/* ~~ Rewards Claim Vendor by Andrew_S90 CfgNetworkMessages End ~~ */

     

     

  5. Client: In your init.sqf please paste the following (also available via github in the init.sqf file)
    Spoiler
    
    /* ~~ Rewards Claim Vendor by Andrew_S90 Script Start ~~ */
    {
        _x params [['_function',''],['_file','']];
        _code = compileFinal (preprocessFileLineNumbers _file);
        missionNamespace setVariable [_function,_code];
    } 
    forEach
    [
       ['ExileClient_gui_rewardsDialog_event_onClaimButtonClick','custom\rewards\ExileClient_gui_rewardsDialog_event_onClaimButtonClick.sqf'],
       ['ExileClient_gui_rewardsDialog_event_onClaimVehicle','custom\rewards\ExileClient_gui_rewardsDialog_event_onClaimVehicle.sqf'],
       ['ExileClient_gui_rewardsDialog_event_onClaimVehicleButtonClick','custom\rewards\ExileClient_gui_rewardsDialog_event_onClaimVehicleButtonClick.sqf'],
       ['ExileClient_gui_rewardsDialog_event_onDropDownSelectionChanged','custom\rewards\ExileClient_gui_rewardsDialog_event_onDropDownSelectionChanged.sqf'],
       ['ExileClient_gui_rewardsDialog_event_onInputBoxChars','custom\rewards\ExileClient_gui_rewardsDialog_event_onInputBoxChars.sqf'],
       ['ExileClient_gui_rewardsDialog_event_onListBoxSelectionChanged','custom\rewards\ExileClient_gui_rewardsDialog_event_onListBoxSelectionChanged.sqf'],
       ['ExileClient_gui_rewardsDialog_show','custom\rewards\ExileClient_gui_rewardsDialog_show.sqf'],
       ['ExileClient_gui_rewardsDialog_updateListBox','custom\rewards\ExileClient_gui_rewardsDialog_updateListBox.sqf'],
       ['ExileClient_gui_rewardsDialog_updateSelection','custom\rewards\ExileClient_gui_rewardsDialog_updateSelection.sqf'],
       ['ExileClient_system_rewards_network_claimItemResponse','custom\rewards\ExileClient_system_rewards_network_claimItemResponse.sqf'],
       ['ExileClient_system_rewards_network_claimTabsResponse','custom\rewards\ExileClient_system_rewards_network_claimTabsResponse.sqf'],
       ['ExileClient_system_rewards_network_claimVehicleResponse','custom\rewards\ExileClient_system_rewards_network_claimVehicleResponse.sqf'],
       ['ExileClient_system_rewards_network_hasRewardsResponse','custom\rewards\ExileClient_system_rewards_network_hasRewardsResponse.sqf']
    ];
    
    
    _position = worldSize/2;
    _center = [_position,_position,0];
    
    _lockers = nearestObjects [_center, ["Exile_Locker"], worldSize];
    
    {
    	_x addAction ["<t color='#FF0000'>Rewards</t>", {[] call ExileClient_gui_rewardsDialog_show;},"",-4,true ,true ,"","true",3];
    } forEach _lockers;
    
    /* ~~ Rewards Claim Vendor by Andrew_S90 Script End ~~ */

     

     

  6. Server: Open the rewards_server folder and open config.cpp and then either add your desired admin UIDs to the "AllowedRewardsGivers" array OR change checkRewards to a 0 this is a security function which will check if a legit sender is trying to reward your players.
  7. Server: In config.cpp feel free to change logging to a 0 if you do not want extdb2 logs to be created. As well you can add any custom kits, I have included some examples for you.
  8. Server: Run the following rewards.sql on your database to add a rewards table for your players (also available via github in Server\database_additions folder in the rewards.sql file)
    Spoiler
    
    CREATE TABLE IF NOT EXISTS `rewards` (
      `uid` varchar(32) NOT NULL,
      `rewards_player` varchar(1024) NOT NULL DEFAULT '[]',
      PRIMARY KEY (`uid`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

     

     

  9. Server: Paste the following additions to your exile.ini file at the bottom (also available via github in Server\database_additions in the exile_additions.ini file)
    Spoiler
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;	PLAYER REWARDS
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    [hasRewardsPlayer]
    SQL1_1 = SELECT CASE WHEN EXISTS(SELECT uid FROM rewards WHERE uid = ?) THEN 'true' ELSE 'false' END
    Number of Inputs = 1
    SQL1_INPUTS = 1
    OUTPUT = 1
    
    [loadRewards]
    SQL1_1 = SELECT rewards_player FROM rewards WHERE uid = ?
    Number Of Inputs = 1
    SQL1_INPUTS = 1
    OUTPUT = 1
    
    [createRewards]
    SQL1_1 = INSERT INTO rewards SET uid = ?, rewards_player = ?
    Number Of Inputs = 2
    SQL1_INPUTS = 1,2
    
    [setPlayerRewards]
    SQL1_1 = UPDATE rewards SET rewards_player = ? WHERE uid = ?
    Number of Inputs = 2
    SQL1_INPUTS = 1,2 

     

     

 

Example code snippets to call files to add items to players.

Spoiler

ExileServer_system_rewards_network_addKitRequest Example calls

From infistar to player ["addKitRequest", ["UID_OF_PLAYER_TARGET", "BaseObjectsWood"]] call ExileClient_system_network_send;

From server mission(i.e dms) to server ["dms_mission", ["UID_OF_PLAYER_TARGET", "BaseObjectsWood"]] call ExileServer_system_rewards_network_addRewardsRequest;

ExileServer_system_rewards_network_addRewardsRequest Example calls

From infistar to player ["addRewardsRequest", ["UID_OF_PLAYER_TARGET", [["ExileScore",1000],["ExileMoney",2000],"Exile_Item_Flag","Exile_Item_SafeKit"]]] call ExileClient_system_network_send;

From server mission(i.e dms) to server ["dms_mission", ["UID_OF_PLAYER_TARGET", [["ExileScore",1000],["ExileMoney",2000],"Exile_Item_Flag","Exile_Item_SafeKit"]]] call ExileServer_system_rewards_network_addRewardsRequest;


ExileServer_system_rewards_updatePlayer Example usage
Example Usage: - This is only used to update the player that they have new rewards - if you add to their rewards via DB you could call this with their UID
It would then notify and update their client rewards.
From server to server "UID OF PLAYER" call ExileServer_system_rewards_updatePlayer;
The last function could be called from a DLL when someone joins your website or someone has rewards added manually via db - could be called via MARMA etc. Mainly just to notify and update players if they are online.

 

 

11 people like this

Share this post


Link to post
Share on other sites
Advertisement

Very good. And you can do it so that it would work on the whole map. It would be great if you would admit it was necessary to urgently have a helicopter and you could use this reward.

Share this post


Link to post
Share on other sites

Thanks for that script.

It works with x64 and extDB3, you only have comment out the number of input in exile.ini with ';' or delete this lines:

Spoiler

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;	PLAYER REWARDS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[hasRewardsPlayer]
SQL1_1 = SELECT CASE WHEN EXISTS(SELECT uid FROM rewards WHERE uid = ?) THEN 'true' ELSE 'false' END
;Number of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1

[loadRewards]
SQL1_1 = SELECT rewards_player FROM rewards WHERE uid = ?
;Number Of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1

[createRewards]
SQL1_1 = INSERT INTO rewards SET uid = ?, rewards_player = ?
;Number Of Inputs = 2
SQL1_INPUTS = 1,2

[setPlayerRewards]
SQL1_1 = UPDATE rewards SET rewards_player = ? WHERE uid = ?
;Number of Inputs = 2
SQL1_INPUTS = 1,2 

 

You can write the rewards in the infistar Custom_Functions.hpp to select the player to give him the reward.

Example Custom_Functions.hpp:

Spoiler

class CfgCustomFunctions {
    class custom1 {
        type = 2;    // just execute
        name = "Reward";
        code = "['addRewardsRequest', [getplayeruid _this, [['ExileScore',1000],['ExileMoney',2000],'Exile_Item_Flag','Exile_Item_SafeKit',['Exile_Car_Lada_Green',3],'Exile_Chopper_Huey_Green']]] call ExileClient_system_network_send;";
    };
    class custom2 {
        //type = 1;    // toggle on/off
        type = 2;
        name = "BaseObjectsWood";
        code = "['addKitRequest', [getplayeruid _this, 'BaseObjectsWood']] call ExileClient_system_network_send;";
    };

};

 

Now i want a xm8 App to give rewards to offline players :-)

Edited by Sir_Joker
1 person likes this

Share this post


Link to post
Share on other sites
19 hours ago, 厉害救济 said:

how to move the rewards from locker to a trader 

 

it's not so difficult, 

comment out these lines in init.sqf:

Spoiler

_position = worldSize/2;
_center = [_position,_position,0];

//_lockers = nearestObjects [_center, ["Exile_Locker"], worldSize];
/*
{
	_x addAction ["<t color='#FF0000'>Rewards</t>", {[] call ExileClient_gui_rewardsDialog_show;},"",-4,true ,true ,"","true",3];
} forEach _lockers;
*/
/* ~~ Rewards Claim Vendor by Andrew_S90 Script End ~~ */

Add to initPlayerLocal:

Spoiler


{
    private _logic = "Logic" createVehicleLocal [0, 0, 0];
    private _trader = (_x select 0) createVehicleLocal [0, 0, 0];
    private _animations = _x select 1;
    
    _logic setPosWorld (_x select 5);
    _logic setVectorDirAndUp [_x select 6, _x select 7];
    
    _trader setVariable ["BIS_enableRandomization", false];
    _trader setVariable ["BIS_fnc_animalBehaviour_disable", true];
    _trader setVariable ["ExileAnimations", _animations];
    _trader setVariable ["ExileTraderType", _x select 2];
    _trader setVariable ["ExileTraderId", _x select 8,true];
    _trader disableAI "ANIM";
    _trader disableAI "MOVE";
    _trader disableAI "FSM";
    _trader disableAI "AUTOTARGET";
    _trader disableAI "TARGET";
    _trader disableAI "CHECKVISIBLE";
    _trader allowDamage false;
    _trader setFace (_x select 3);
    _trader setUnitLoadOut (_x select 4);
    _trader setPosWorld (_x select 5);
    _trader setVectorDirAndUp [_x select 6, _x select 7];
    _trader reveal _logic;
    _trader attachTo [_logic, [0, 0, 0]];
    _trader switchMove (_animations select 0);
    _trader addEventHandler ["AnimDone", {_this call ExileClient_object_trader_event_onAnimationDone}];
}
forEach _npcs;

 

 

Or put it in the xm8 Apps (i use infistar xm8Apps)

Spoiler

 

trader_reward.JPGxm8.jpg

 

 

Edited by Sir_Joker

Share this post


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

it's not so difficult, 

comment out these lines in init.sqf:

  Reveal hidden contents


_position = worldSize/2;
_center = [_position,_position,0];

//_lockers = nearestObjects [_center, ["Exile_Locker"], worldSize];
/*
{
	_x addAction ["<t color='#FF0000'>Rewards</t>", {[] call ExileClient_gui_rewardsDialog_show;},"",-4,true ,true ,"","true",3];
} forEach _lockers;
*/
/* ~~ Rewards Claim Vendor by Andrew_S90 Script End ~~ */

Add to initPlayerLocal:

  Reveal hidden contents



{
    private _logic = "Logic" createVehicleLocal [0, 0, 0];
    private _trader = (_x select 0) createVehicleLocal [0, 0, 0];
    private _animations = _x select 1;
    
    _logic setPosWorld (_x select 5);
    _logic setVectorDirAndUp [_x select 6, _x select 7];
    
    _trader setVariable ["BIS_enableRandomization", false];
    _trader setVariable ["BIS_fnc_animalBehaviour_disable", true];
    _trader setVariable ["ExileAnimations", _animations];
    _trader setVariable ["ExileTraderType", _x select 2];
    _trader setVariable ["ExileTraderId", _x select 8,true];
    _trader disableAI "ANIM";
    _trader disableAI "MOVE";
    _trader disableAI "FSM";
    _trader disableAI "AUTOTARGET";
    _trader disableAI "TARGET";
    _trader disableAI "CHECKVISIBLE";
    _trader allowDamage false;
    _trader setFace (_x select 3);
    _trader setUnitLoadOut (_x select 4);
    _trader setPosWorld (_x select 5);
    _trader setVectorDirAndUp [_x select 6, _x select 7];
    _trader reveal _logic;
    _trader attachTo [_logic, [0, 0, 0]];
    _trader switchMove (_animations select 0);
    _trader addEventHandler ["AnimDone", {_this call ExileClient_object_trader_event_onAnimationDone}];
}
forEach _npcs;

 

 

Or put it in the xm8 Apps (i use infistar xm8Apps)

  Reveal hidden contents

 

trader_reward.JPGxm8.jpg

 

 

thank you for your timely reply .i also use infistar xm8apps ,so i want to know how to move it to the apps .van you give me some instructions ?

Share this post


Link to post
Share on other sites
2 hours ago, 厉害救济 said:

thank you for your timely reply .i also use infistar xm8apps ,so i want to know how to move it to the apps .van you give me some instructions ?

no problem

Spoiler

class customapp_8 {
	submenu = 0;
	toggleable = 0;
	text = "Reward";
	tooltip = "Open your Reward";
	fnc = "call ExileClient_gui_rewardsDialog_show;";
	pic = "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa";
};

 

 

Share this post


Link to post
Share on other sites
8 minutes ago, Sir_Joker said:

no problem

  Hide contents


class customapp_8 {
	submenu = 0;
	toggleable = 0;
	text = "Reward";
	tooltip = "Open your Reward";
	fnc = "call ExileClient_gui_rewardsDialog_show;";
	pic = "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa";
};

 

 

thank you fast reply ,

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.