[Tutorial] UnloadClip for DNC

Newbie Spellweaver
Joined
Nov 11, 2004
Messages
15
Reaction score
8
in src\EclipseStudio\Sources\UI\HUDPause.cpp]

Search for
Code:
void HUDPause::eventBackpackDrop(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount)
{
	r3d_assert(argCount==1);
	int slotID = args[0].GetInt();

	obj_Player* plr = gClientLogic().localPlayer_;
	r3d_assert(plr);

	plr->DropItem(slotID);

	updateSurvivorTotalWeight();

	gfxMovie.Invoke("_root.api.backpackGridSwapSuccess", "");
}

add above

Code:
void HUDPause::eventBackpackUnloadClip(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount)
{			   
	obj_Player* plr = gClientLogic().localPlayer_;
	
	int slotID = args[0].GetInt();
	uint32_t itemID = args[0].GetUInt();
	
	wiInventoryItem& wi = plr->CurLoadout.Items[slotID];	
	const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig(itemID);
	r3d_assert(argCount==1);
	r3d_assert(plr);
	r3d_assert(wi.itemID && wi.quantity > 0);
	{
	const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig(wi.itemID);
		if(wc)
		{
			// UNLOAD CLIP
			if(wc->category >= storecat_ASR && wc->category <= storecat_SMG)
			{
					if(wi.Var1 > 0)
					{
						PKT_C2S_UnloadClipReq_s n;
						n.slotID = slotID;
						p2pSendToHost(gClientLogic().localPlayer_, &n, sizeof(n), true);
						wi.Var1 = 0;
						plr->CurLoadout.Items[slotID] = wi;
						
						plr->OnBackpackChanged(slotID);
						updateSurvivorTotalWeight();		
					}
					Scaleform::GFx::Value var[2];
					var[0].SetString("Erro ao descarregar");
					var[1].SetInt(2);
					gfxMovie.Invoke("_root.api.Main.Inventory.addContextMenuOption", var, 2);
					return;
			}	
		}
	}
}

search for
Code:
gfxMovie.RegisterEventHandler("eventBackpackDrop", MAKE_CALLBACK(eventBackpackDrop));

add above
Code:
gfxMovie.RegisterEventHandler("eventBackpackUnloadClip", MAKE_CALLBACK(eventBackpackUnloadClip));

in src\EclipseStudio\Sources\UI\HUDPause.h
seach for
Code:
void	eventBackpackDrop(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount);

add above
Code:
void	eventBackpackUnloadClip(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount);

in src\EclipseStudio\Sources\multiplayer\P2PMessages.h

search for
Code:
PKT_C2S_DisconnectReq,

add above
Code:
PKT_C2S_UnloadClipReq,

search for
Code:
struct PKT_C2S_DisconnectReq_s : public DefaultPacketMixin<PKT_C2S_DisconnectReq>
{
};

add above
Code:
struct PKT_C2S_UnloadClipReq_s : public DefaultPacketMixin<PKT_C2S_UnloadClipReq>
{
	int slotID;
};

in server\WO_GameServer\Sources\ObjectsCode\obj_ServerPlayer.cpp
search for
Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_InventoryOp_s& n)
{
}

add above
Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_UnloadClipReq_s& n)
{
	if(loadout_->Alive == 0)
		return;

	wiInventoryItem item = loadout_->Items[n.slotID];

	const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig(item.itemID);
	//m_WeaponArray[n.slotID]
	if(wc)
	{
		if(wc->category >= storecat_ASR && wc->category <= storecat_SMG)
		{
			if(item.Var1 > 0 && item.Var2 > 0)
			{
				wiInventoryItem wi;
				wi.itemID   = item.Var2;
				wi.quantity = 1;
				wi.Var1 = item.Var1;

				item.Var1 = 0;
				item.Var2 = wi.itemID;
				
				if(BackpackAddItem(wi))
					loadout_->Items[n.slotID] = item;
				
				OnBackpackChanged(n.slotID);

			}else{
				gServerLogic.LogCheat(peerId_, PKT_S2C_CheatWarning_s::CHEAT_Protocol, false, "Clip is serverside empty",
				"slot%d %d - %d", n.slotID, item.itemID, item.Var1);
			}
		}
	}
}

search for
Code:
DEFINE_GAMEOBJ_PACKET_HANDLER(PKT_C2C_PlayerUseItem);

add above
Code:
DEFINE_GAMEOBJ_PACKET_HANDLER(PKT_C2S_UnloadClipReq);

in server\WO_GameServer\Sources\ObjectsCode\obj_ServerPlayer.h
search for
Code:
void		OnNetPacket(const PKT_C2S_DisconnectReq_s& n);

add above
Code:
void		OnNetPacket(const PKT_C2S_UnloadClipReq_s& n);

Recompile the Server and Client..
 
Last edited:
{
public:
MovieClipLoaderProto(ASStringContext *psc, Object* pprototype, const FunctionRef& constructor);

static void GetProgress(const FnCall& fn);
static void LoadClip(const FnCall& fn);
static void UnloadClip(const FnCall& fn);
};

You know that "LoadClip" doesn't mean here that is the right function.. With clip the functions means a MOVIE CLIP not a Weapon clip...
So this is completly wrong..
 
really !?

all of this code for unload_clip ?

are you serious man ?

Do you know unload_clip take something like 10 lines ?
 
I guess there is no need to put this



static void UnloadClip(const FnCall& fn);

@edit she is already added
 
Last edited:
I got this ... ERROR: bad event 146 sent from non registered object 1

From r3dlog:

000082.320| World loaded
000082.320| Total load time: 24.83
000084.898| !!! ERROR: bad event 146 sent from non registered object 1

000084.898| ... exiting
 
Last edited:
PLS read the post!! its for DNC version.. use the correct HUD_menu.swf of original DNC version....




HUD - [Tutorial] UnloadClip for DNC - RaGEZONE Forums
 
Last edited:
Back