summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/atcommand_athena.conf4
-rw-r--r--src/map/atcommand.c33
-rw-r--r--src/map/pc.c47
3 files changed, 62 insertions, 22 deletions
diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf
index 69d9e3c71..933ac35bd 100644
--- a/conf/atcommand_athena.conf
+++ b/conf/atcommand_athena.conf
@@ -439,6 +439,10 @@ evilclone: 50
//----------------
// 60: GM commands
+// Add or Remove Cash/Kafra points to yourself
+cash: 60
+points: 60
+
// Starts Guild Wars
agitstart: 60
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 5c3fb80a3..f2947372b 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -7966,6 +7966,37 @@ int atcommand_reject(const int fd, struct map_session_data* sd, const char* comm
}
/*===================================
+ * Cash Points
+ *-----------------------------------*/
+int atcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
+{
+ int value;
+ nullpo_retr(-1, sd);
+
+ if( !message || !*message || (value = atoi(message)) == 0 ) {
+ clif_displaymessage(fd, "Please, enter an amount.");
+ return -1;
+ }
+
+ if( !strcmpi(command+1,"cash") )
+ {
+ if( value > 0 )
+ pc_getcash(sd, value, 0);
+ else
+ pc_paycash(sd, value, 0);
+ }
+ else
+ { // @points
+ if( value > 0 )
+ pc_getcash(sd, 0, value);
+ else
+ pc_paycash(sd, value, value);
+ }
+
+ return 0;
+}
+
+/*===================================
* Away message (@away, @aw) [LuzZza]
*-----------------------------------*/
int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
@@ -8481,6 +8512,8 @@ AtCommandInfo atcommand_info[] = {
{ "mail", 1, atcommand_mail },
{ "noks", 0, atcommand_ksprotection },
{ "allowks", 6, atcommand_allowks },
+ { "cash", 60, atcommand_cash },
+ { "points", 60, atcommand_cash },
};
diff --git a/src/map/pc.c b/src/map/pc.c
index 551fa9c55..3f1128e2a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -2708,21 +2708,25 @@ void pc_paycash(struct map_session_data *sd, int prize, int points)
int cash = prize - points;
nullpo_retv(sd);
- sd->cashPoints -= cash;
- sd->kafraPoints -= points;
+ if( cash > 0 )
+ {
+ if( (sd->cashPoints -= cash) < 0 )
+ sd->cashPoints = 0;
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
- if( points )
- {
- sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints);
+ sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
- if( cash )
+ if( points > 0 )
{
- sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints);
+ if( (sd->kafraPoints -= points) < 0 )
+ sd->kafraPoints = 0;
+
+ pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
+
+ sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
}
@@ -2732,27 +2736,26 @@ void pc_getcash(struct map_session_data *sd, int cash, int points)
char output[128];
nullpo_retv(sd);
- if( cash > MAX_ZENY - sd->cashPoints )
- cash = MAX_ZENY - sd->cashPoints;
-
- sd->cashPoints += cash;
-
- if( points > MAX_ZENY - sd->kafraPoints )
- points = MAX_ZENY - sd->kafraPoints;
-
- sd->kafraPoints += points;
-
- pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
- pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
-
if( cash > 0 )
{
+ if( cash > MAX_ZENY - sd->cashPoints )
+ cash = MAX_ZENY - sd->cashPoints;
+
+ sd->cashPoints += cash;
+ pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
+
sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints);
clif_disp_onlyself(sd, output, strlen(output));
}
if( points > 0 )
{
+ if( points > MAX_ZENY - sd->kafraPoints )
+ points = MAX_ZENY - sd->kafraPoints;
+
+ sd->kafraPoints += points;
+ pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
+
sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
clif_disp_onlyself(sd, output, strlen(output));
}