+void Server_Cmd_REFUND(tClient *Client, char *Args)
+{
+ tItem *item;
+ int uid, price_override = 0;
+ char *username, *itemname, *price_str;
+
+ if( Server_int_ParseArgs(0, Args, &username, &itemname, &price_str, NULL) ) {
+ if( !itemname || price_str ) {
+ sendf(Client->Socket, "407 REFUND takes 2 or 3 arguments\n");
+ return ;
+ }
+ }
+
+ if( !Client->bIsAuthed ) {
+ sendf(Client->Socket, "401 Not Authenticated\n");
+ return ;
+ }
+
+ // Check user permissions
+ if( !(Bank_GetFlags(Client->UID) & (USER_FLAG_COKE|USER_FLAG_ADMIN)) ) {
+ sendf(Client->Socket, "403 Not in coke\n");
+ return ;
+ }
+
+ uid = Bank_GetAcctByName(username, 0);
+ if( uid == -1 ) {
+ sendf(Client->Socket, "404 Unknown user\n");
+ return ;
+ }
+
+ item = _GetItemFromString(itemname);
+ if( !item ) {
+ sendf(Client->Socket, "406 Bad Item ID\n");
+ return ;
+ }
+
+ if( price_str )
+ price_override = atoi(price_str);
+
+ switch( DispenseRefund( Client->UID, uid, item, price_override ) )
+ {
+ case 0: sendf(Client->Socket, "200 Item Refunded\n"); return ;
+ default:
+ sendf(Client->Socket, "500 Dispense Error\n");
+ return;
+ }
+}
+