PDA

View Full Version : CommandItems Weapon Spawning


anthonyjr
06-06-2013, 22:19
I've been trying to use commanditems to enable people in my server to purchase flashbangs for credits, however I cannot seem to be able to figure out exactly how to do it. At the moment, I am using a modified simple weapon giver plugin that will give anyone a flashbang with the command "sm_flash," but I don't want people to be able to use the command outside of being able to buy it from the store. Setting it as admin only removes the ability of people to simply type the command, but store doesn't seem to react after buying the item.

This is most likely a problem with my plugin, but could anyone tell me what I would need to code into the plugin to make it so that people cannot simply type the command "sm_flash" to get a flashbang but would instead need to use the store to buy a flashbang but using the same command. Let me know if this is possible, and thanks.

Arrow768
06-07-2013, 16:47
the best way is to write a store module that gives players flashbangs

anthonyjr
06-07-2013, 18:29
the best way is to write a store module that gives players flashbangs

I could try that, is there a link to documentation of some sort or a getting started point for coding plugins for store?

EDIT: Nevermind, I have some of the basics figured out.

Arrow768
06-08-2013, 00:30
https://github.com/alongubkin/store/wiki/Creating-items-for-Store is a good tutorial.
The rest you might need (json to select what weapons should be spawned) can be found in other store modules, for example the skins module.

anthonyjr
06-13-2013, 15:53
https://github.com/alongubkin/store/wiki/Creating-items-for-Store is a good tutorial.
The rest you might need (json to select what weapons should be spawned) can be found in other store modules, for example the skins module.

This has helped me for creating the basic plugin, but I still have no idea how to give the user the item right away without putting it into the inventory. I don't want to use the inventory at all with this weapon giver.

Arrow768
06-15-2013, 06:13
You want to drop it at his position ?

anthonyjr
06-15-2013, 19:55
You want to drop it at his position ?

Exactly, or even better just replace what is already in his grenade slot and give it directly to him, but dropping it is fine.

anthonyjr
06-30-2013, 17:38
Could I bump this? I never got an answer.

alongub
07-01-2013, 12:15
This has helped me for creating the basic plugin, but I still have no idea how to give the user the item right away without putting it into the inventory. I don't want to use the inventory at all with this weapon giver.

You mean the game inventory or the store inventory?

anthonyjr
07-01-2013, 12:18
You mean the game inventory or the store inventory?

The store inventory. I want to basically add the item to the shop but instead of putting the item into their "store inventory" I want them to directly get a flashbang once they buy it. Basically bypassing the entire store-inventory part of the plugin.

alongub
07-01-2013, 12:31
So assuming you have an item module that supports buying weapons and using them, you'll just need to remove the item from the player inventory and simulate using it.

Code snippet:


public Store_OnShopBuyItem(client, itemId, bool:success)
{
if (!success)
return;

decl String:type[STORE_MAX_TYPE_LENGTH];
Store_GetItemType(itemId, type, sizeof(type));

// Change "weapon" to the item type you've registered
if (StrEquals(type, "weapon"))
{
// Change OnWeaponUse to your callback.
OnWeaponUse(client, itemId, false);

// This method doesn't support optional callbacks, so we'll need to specify an empty callback.
Store_RemoveUserItem(Store_GetClientAccountID (client), itemId, EmptyCallback);
}
}

public EmptyCallback(accountId, itemId, any:data) {}