Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rg_drop_item #264

Closed
cwhitelytning opened this issue Jan 10, 2023 · 5 comments
Closed

rg_drop_item #264

cwhitelytning opened this issue Jan 10, 2023 · 5 comments

Comments

@cwhitelytning
Copy link

cwhitelytning commented Jan 10, 2023

Function returns true in any case, whether there is a gun or not.

Hello, I am concerned about the operation of this function.

  if (!user_has_weapon(id, CSW_DEAGLE)) {
    static const pistols[2][] = {"weapon_usp", "weapon_glock18"};
    for (new index = 0; index < 2; ++index) {
      log_amx("%d", rg_remove_item(id, pistols[index]));
    }
    rg_give_item(id, "weapon_deagle");
  }

Let me remind you about her description:

  • Forces the player to drop the specified item classname.
  • @param index Client index
  • @param item_name Item classname
  • @return 1 on success, 0 otherwise

Version

[14] ReAPI RUN - reapi_amxx.dll v5.22.0.254-dev pl5 ANY Never

Thank you in advance for the answer if I misunderstood something.

Additional

  if (!user_has_weapon(id, CSW_DEAGLE)) {
    static const pistols[2][] = {"weapon_usp", "weapon_glock18"};
    for (new index = 0; index < sizeof(pistols); ++index) {
      if (rg_remove_item(id, pistols[index], true)) break;
    }
    rg_give_item(id, "weapon_deagle");
  }

I replaced it with the remove_item function, it works perfectly, but the problem with rg_drop_item still remains.

@SmileYzn
Copy link

You used rg_remove_item, anyway rg_drop_item always return TRUE (1) here:

cell AMX_NATIVE_CALL rg_drop_item(AMX *amx, cell *params)

Engine of ReGameDLL_CS do not care if player has item or not, just force the entity to drop it.
You need to check by youself to see if player has item or not.

Same bug on rg_remove_all_items

@cwhitelytning
Copy link
Author

You used rg_remove_item, anyway rg_drop_item always return TRUE (1) here:

cell AMX_NATIVE_CALL rg_drop_item(AMX *amx, cell *params)

Engine of ReGameDLL_CS do not care if player has item or not, just force the entity to drop it. You need to check by youself to see if player has item or not.

Same bug on rg_remove_all_items

Thank you very much for the answer, if the function still returns true for rg_drop_item and as you say the engine doesn't care, then the return value is not needed for this function, it really throws into confusion. Especially the description. I am satisfied with the answer, thanks again!

@SmileYzn
Copy link

SmileYzn commented Jan 19, 2023

What exactly you need to do? If it is a type of item restriction, you can reach same result with PlayerHasRestrictItem. It check when player buy, touch or be equipped by an item.

{
	ITEM_TYPE_BUYING,	// when a player buying items
	ITEM_TYPE_TOUCHED,	// when the player touches with a weaponbox or armoury_entity
	ITEM_TYPE_EQUIPPED	// when an entity game_player_equip gives item to player or default item's on player spawn
};


PlayerHasRestrictItem(CBasePlayer* Player, ItemID item, ItemRestType type)

@Javekson
Copy link
Contributor

Javekson commented Oct 4, 2023

After merging PR: #289, the returned values will be correct

@s1lentq
Copy link
Collaborator

s1lentq commented Oct 7, 2023

Closed as fixed #289

@s1lentq s1lentq closed this as completed Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants