- Added @cash and @points command to manage your cash/kafra points.
- Optimized code. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12266 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
993e7cc415
commit
43425e88de
@ -439,6 +439,10 @@ evilclone: 50
|
|||||||
//----------------
|
//----------------
|
||||||
// 60: GM commands
|
// 60: GM commands
|
||||||
|
|
||||||
|
// Add or Remove Cash/Kafra points to yourself
|
||||||
|
cash: 60
|
||||||
|
points: 60
|
||||||
|
|
||||||
// Starts Guild Wars
|
// Starts Guild Wars
|
||||||
agitstart: 60
|
agitstart: 60
|
||||||
|
|
||||||
|
@ -7965,6 +7965,37 @@ int atcommand_reject(const int fd, struct map_session_data* sd, const char* comm
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*===================================
|
||||||
|
* 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]
|
* Away message (@away, @aw) [LuzZza]
|
||||||
*-----------------------------------*/
|
*-----------------------------------*/
|
||||||
@ -8481,6 +8512,8 @@ AtCommandInfo atcommand_info[] = {
|
|||||||
{ "mail", 1, atcommand_mail },
|
{ "mail", 1, atcommand_mail },
|
||||||
{ "noks", 0, atcommand_ksprotection },
|
{ "noks", 0, atcommand_ksprotection },
|
||||||
{ "allowks", 6, atcommand_allowks },
|
{ "allowks", 6, atcommand_allowks },
|
||||||
|
{ "cash", 60, atcommand_cash },
|
||||||
|
{ "points", 60, atcommand_cash },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
37
src/map/pc.c
37
src/map/pc.c
@ -2708,21 +2708,25 @@ void pc_paycash(struct map_session_data *sd, int prize, int points)
|
|||||||
int cash = prize - points;
|
int cash = prize - points;
|
||||||
nullpo_retv(sd);
|
nullpo_retv(sd);
|
||||||
|
|
||||||
sd->cashPoints -= cash;
|
if( cash > 0 )
|
||||||
sd->kafraPoints -= points;
|
{
|
||||||
|
if( (sd->cashPoints -= cash) < 0 )
|
||||||
|
sd->cashPoints = 0;
|
||||||
|
|
||||||
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
|
pc_setaccountreg(sd,"#CASHPOINTS",sd->cashPoints);
|
||||||
pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
|
|
||||||
|
|
||||||
if( points )
|
sprintf(output, "Used %d cash points. %d points remaining.", cash, sd->cashPoints);
|
||||||
{
|
|
||||||
sprintf(output, "Used %d kafra points. %d points remaining.", points, sd->kafraPoints);
|
|
||||||
clif_disp_onlyself(sd, output, strlen(output));
|
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));
|
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];
|
char output[128];
|
||||||
nullpo_retv(sd);
|
nullpo_retv(sd);
|
||||||
|
|
||||||
|
if( cash > 0 )
|
||||||
|
{
|
||||||
if( cash > MAX_ZENY - sd->cashPoints )
|
if( cash > MAX_ZENY - sd->cashPoints )
|
||||||
cash = MAX_ZENY - sd->cashPoints;
|
cash = MAX_ZENY - sd->cashPoints;
|
||||||
|
|
||||||
sd->cashPoints += cash;
|
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,"#CASHPOINTS",sd->cashPoints);
|
||||||
pc_setaccountreg(sd,"#KAFRAPOINTS",sd->kafraPoints);
|
|
||||||
|
|
||||||
if( cash > 0 )
|
|
||||||
{
|
|
||||||
sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints);
|
sprintf(output, "Gained %d cash points. Total %d points", points, sd->cashPoints);
|
||||||
clif_disp_onlyself(sd, output, strlen(output));
|
clif_disp_onlyself(sd, output, strlen(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( points > 0 )
|
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);
|
sprintf(output, "Gained %d kafra points. Total %d points", points, sd->kafraPoints);
|
||||||
clif_disp_onlyself(sd, output, strlen(output));
|
clif_disp_onlyself(sd, output, strlen(output));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user