Here's a useful stock I just wrote up:
PHP Code:
stock cs_take_user_money( id, amount )
{
new money = cs_get_user_money( id )
if ( money - amount < 0 )
return 0
cs_set_user_money( id, clamp( money - amount, 0, 16000 ) )
return 1
}
If the user had enough money, it will take it and return 1. If they don't, it won't do anything, and will return 0.
__________________