}
// And log that it happened
- Log_Info("Dispensed %s (%s:%i) for %s [cost %i, balance %i cents]",
+ Log_Info("dispense %s (%s:%i) by %s [cost %i, balance %i cents]",
Item->Name, handler->Name, Item->ID,
username, Item->Price, GetBalance(User)
);
free( username );
return 0; // 0: EOK
}
+
+/**
+ * \brief Give money from one user to another
+ */
+int DispenseGive(int SrcUser, int DestUser, int Ammount, const char *ReasonGiven)
+{
+ int ret;
+ if( Ammount < 0 ) return 1; // Um... negative give? Not on my watch!
+
+ ret = Transfer( SrcUser, DestUser, Ammount, ReasonGiven );
+ if(ret) return 2; // No Balance
+
+ Log_Info("give %i to %s from %s (%s)",
+ Ammount, GetUserName(DestUser), GetUserName(SrcUser), ReasonGiven
+ );
+
+ return 0;
+}
+
+int DispenseAdd(int User, int ByUser, int Ammount, const char *ReasonGiven)
+{
+ int ret;
+
+ ret = Transfer( GetUserID(">liability"), User, Ammount, ReasonGiven );
+
+ if(ret) return 2;
+
+ Log_Info("add %i to %s by %s (%s)",
+ Ammount, GetUserName(User), GetUserName(ByUser), ReasonGiven
+ );
+
+ return 0;
+}