[Include] drop-money.inc (Make player drop cash on death)
#1

Drop Money

View code and download: https://gist.github.com/AmirSavand/e...23d4dce90a8439

Leave comments here or on the GitHub page if you have any questions/suggestions.


Installation


Define DROP_MONEY_PICKUPS

This is the amount of cash pickups to create.
Recommended value is 5.


Define DROP_MONEY_AMOUNT

This is the amount of cash player gains from picking up each pickup.


Define MAX_DROP_MONEY

This is the maximum amount of money pickups allowed by this include.
Recommended value is 500 (if you are using streammer plugin).


Usage

Make sure to checkout the stock functions in the GitHub.

Call DropMoney() when you want to create money drops (like OnPlayerDeath).
Call DestroyDropMoney() if you want to destroy all the pickups (like OnFilterScriptExit)
Call CheckPlayerMoneyDropPickup() in OnPlayerPickupDynamicPickup() or anywhere else like pickup up cash with keys should be used in OnPlayerKeyStateChange() if you store last pickup id).

To prevent player to pick the cash pickups up use this PreventPlayerDropMoneyOnDeath() event and return 1.
If you want to know if a player dropped money on death, watch this event OnPlayerDropMoneyOnDeath().
Reply
#2

Code:
new dropMoney[MAX_DROP_MONEY];
You need to define these things if the user has not defined them! Also your system is not fully contained it requires function calls from the user when it shouldn't do that. There should be standalone include function if possible with user interaction primarily from callbacks in which returning 0 disallows picking up a pickup. Don't rely on the user to make the determination of WHEN to check always give the user choice of WHAT to do WHEN something happens.

Code:
new index = Ran(0, MAX_DROP_MONEY);
That isn't the right way to select an index. Use an iterator then store the index of a free iterator index in the extraid of the pickup create an enum and variable. Then when you pick up a pickup check the extraid use that to reference the data stored from the iterator index. Now check that the pickup id is the same from your stored data if they are then the pickup belongs to this system. If not then the pickup might be used in another system. You have now eliminated most of the looping you will need to use.


Code:
dropMoney[index] = CreateDynamicPickup(1212, 1, x + Ran(-i/2, i/2), y + Ran(-i/2, i/2), z - 0.5);
Add ColAndreas support to check if there is a wall that way money will never spawn outside of the map and you can also find the z-height as well for even better control.
Reply
#3

Thanks for the feedback!

I use this in 3 different gamemodes that each have different values for the MAX_DROP_MONEY and DROP_MONEY_AMOUNT that's why I let/force the gamemode/filterscript to decide this.

For 2nd and last feedback, I can see how it's better but for my gamemodes, the current way seems enough.

Still, I agree with all of your inputs.

Also you made me realize the Ran function was not there, I added a comment the the GitHub page.
Reply
#4

But this is a release it isnt about your gamemode.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)