diff options
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 624 |
1 files changed, 237 insertions, 387 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 213f864d5..dec6131a6 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8,12 +8,13 @@ #include <math.h>
#include <limits.h>
-#include "../common/socket.h"
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/mmo.h"
#include "../common/core.h"
#include "../common/showmsg.h"
+#include "../common/malloc.h"
+#include "../common/socket.h"
#include "atcommand.h"
#include "log.h"
@@ -1069,48 +1070,30 @@ int atcommand_send( const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- int i,type=0;
+ int type=0;
int info[20];
-
- if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
+
+ malloc_tsetdword(info,0,sizeof(info));
+
+ if (!message || !*message || sscanf(message,
+ "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
+ &type,
+ &info[0], &info[1], &info[2], &info[3], &info[4],
+ &info[5], &info[6], &info[7], &info[8], &info[9],
+ &info[10], &info[11], &info[12], &info[13], &info[14],
+ &info[15], &info[16], &info[17], &info[18], &info[19]) < 1)
+ {
clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
return -1;
}
- if (type > 0 && type < MAX_PACKET_DB) {
-
- switch (type)
- {
- case 0x209: {
- WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
- WFIFOW(fd,0) = 0x209;
- WFIFOW(fd,2) = 2;
- memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
- WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
- break;
- }
- case 0x1b1:
- case 0x1c2:
- //case xxx:
- // add others here
- // break;
- default: {
- WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
- WFIFOW(fd,0) = type;
- for(i=1;i<=sizeof(info);i++)
- if(info[i])
- WFIFOW(fd,i) = info[i];
- WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
- break;
- }
- }
-
- sprintf (atcmd_output, msg_txt(258), type, type);
- clif_displaymessage(fd, atcmd_output);
- } else {
+ if (!clif_send_debug(sd, type, info, sizeof(info)/sizeof(int)))
+ {
clif_displaymessage(fd, msg_txt(259));
+ return -1;
}
-
+ sprintf (atcmd_output, msg_txt(258), type, type);
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8819,27 +8802,6 @@ int atcommand_misceffect( return 0;
}
-int charid2sessionid(int charid)
-{
- struct map_session_data *pl_sd = NULL;
-
- pl_sd = map_charid2sd(charid);
- if (pl_sd) return pl_sd->fd;
-
- return 0;
-}
-
-int accountid2sessionid(int accountid)
-{
- struct map_session_data *pl_sd = NULL;
-
- pl_sd = map_id2sd(accountid);
- if (pl_sd) return pl_sd->fd;
-
- return 0;
-}
-
-
/*==========================================
* Jump to a player by PID number
* Original by Dino9021
@@ -8852,44 +8814,36 @@ int atcommand_jumptoid( const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
- sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
-
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+
+ pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
+ sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8905,44 +8859,36 @@ int atcommand_jumptoid2( const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
- sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+ pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
+ sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -8957,49 +8903,43 @@ int atcommand_recallid( const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -9014,49 +8954,42 @@ int atcommand_recallid2( const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
+ malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
return -1;
}
- aid=atoi(message);
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(154)); // Character not found.
+ return -1;
+ }
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can recall only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
- if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(247));
- return -1;
- }
- if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
- clif_displaymessage(fd, msg_txt(248));
- return -1;
- }
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
- sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
- clif_displaymessage(fd, atcmd_output);
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(154)); // Character not found.
- return -1;
- }
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ if (map[pl_sd->bl.m].flag.nowarpto &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(247));
+ return -1;
+ }
+ if (map[sd->bl.m].flag.nowarp &&
+ battle_config.any_warp_GM_min_level > pc_isGM(sd))
+ {
+ clif_displaymessage(fd, msg_txt(248));
+ return -1;
+ }
+ pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
+ sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
+ clif_displaymessage(fd, atcmd_output);
return 0;
}
@@ -9072,38 +9005,25 @@ int atcommand_kickid( {
struct map_session_data *pl_sd;
int cid=0;
- int session_id=0;
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
return -1;
}
+
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
- clif_GM_kick(sd, pl_sd, 1);
- else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kick only lower or same gm level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ clif_GM_kick(sd, pl_sd, 1);
return 0;
}
@@ -9119,38 +9039,23 @@ int atcommand_kickid2( {
struct map_session_data *pl_sd;
int aid=0;
- int session_id=0;
-
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
- clif_GM_kick(sd, pl_sd, 1);
- else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
-
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kick only lower or same gm level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ clif_GM_kick(sd, pl_sd, 1);
return 0;
}
@@ -9165,42 +9070,23 @@ int atcommand_reviveid( const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- pl_sd->status.hp = pl_sd->status.max_hp;
- pc_setstand(pl_sd);
- if (battle_config.pc_invincible_time > 0)
- pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
- clif_updatestatus(pl_sd, SP_HP);
- clif_updatestatus(pl_sd, SP_SP);
- clif_resurrection(&pl_sd->bl, 1);
- clif_displaymessage(fd, msg_txt(51)); // Character revived.
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
-
+ pl_sd = map_charid2sd(cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if(!status_revive(&pl_sd->bl, 100, 100))
+ return -1;
+ clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(fd, msg_txt(51)); // Character revived.
return 0;
}
@@ -9215,42 +9101,25 @@ int atcommand_reviveid2( const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- pl_sd->status.hp = pl_sd->status.max_hp;
- pc_setstand(pl_sd);
- if (battle_config.pc_invincible_time > 0)
- pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
- clif_updatestatus(pl_sd, SP_HP);
- clif_updatestatus(pl_sd, SP_SP);
- clif_resurrection(&pl_sd->bl, 1);
- clif_displaymessage(fd, msg_txt(51)); // Character revived.
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
+ pl_sd = map_id2sd(aid);
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ if(!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if(!status_revive(&pl_sd->bl, 100, 100))
+ return -1;
+ clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
+ clif_displaymessage(fd, msg_txt(51)); // Character revived.
return 0;
}
@@ -9265,40 +9134,28 @@ int atcommand_killid( const char* command, const char* message)
{
int cid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (cid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
return -1;
}
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
- status_kill(&pl_sd->bl);
- clif_displaymessage(fd, msg_txt(14)); // Character killed.
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
+ pl_sd = map_charid2sd(cid);
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kill only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ status_kill(&pl_sd->bl);
+ clif_displaymessage(fd, msg_txt(14)); // Character killed.
return 0;
}
@@ -9313,40 +9170,27 @@ int atcommand_killid2( const char* command, const char* message)
{
int aid=0;
- int session_id=0;
struct map_session_data *pl_sd;
- malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
-
- if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
+ if (!message || (aid = atoi(message)) == 0) {
clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
return -1;
}
- aid=atoi(message);
-
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
- if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
- status_kill(&pl_sd->bl);
- clif_displaymessage(fd, msg_txt(14)); // Character killed.
- } else {
- clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
- return -1;
- }
- } else {
- clif_displaymessage(fd, msg_txt(3)); // Character not found.
- return -1;
- }
-
- }
- else
- {
- clif_displaymessage(fd,msg_txt(3));
- }
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
+ pl_sd = map_id2sd(aid);
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ { // you can kill only lower or same level
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+
+ status_kill(&pl_sd->bl);
+ clif_displaymessage(fd, msg_txt(14)); // Character killed.
return 0;
}
@@ -9363,28 +9207,30 @@ atcommand_charkillableid( {
struct map_session_data *pl_sd = NULL;
int cid=0;
- int session_id=0;
- if (!message || (cid = atoi(message)) == 0 || !*message)
+ if (!message || (cid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player CID.");
return -1;
+ }
- cid=atoi(message);
-
- if ((session_id=charid2sessionid(cid))!=0)
- {
- if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
- return -1;
+ pl_sd = map_charid2sd(cid);
+
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
- pl_sd->state.killable = !pl_sd->state.killable;
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
- if(pl_sd->state.killable)
- clif_displaymessage(fd, msg_txt(289));
- else
- clif_displaymessage(fd, msg_txt(290));
- }
- else
- clif_displaymessage(fd,msg_txt(3));
- //printf("Session_id = %d, cid = %d\n",session_id,cid);
+ pl_sd->state.killable = !pl_sd->state.killable;
+ if(pl_sd->state.killable)
+ clif_displaymessage(fd, msg_txt(289));
+ else
+ clif_displaymessage(fd, msg_txt(290));
return 0;
}
@@ -9402,28 +9248,32 @@ atcommand_charkillableid2( {
struct map_session_data *pl_sd = NULL;
int aid=0;
- int session_id=0;
- if (!message || (aid = atoi(message)) == 0 || !*message)
+ if (!message || (aid = atoi(message)) == 0) {
+ clif_displaymessage(fd, "Please, enter a player AID.");
return -1;
+ }
- aid=atoi(message);
+ pl_sd = map_id2sd(aid);
- if ((session_id=accountid2sessionid(aid))!=0)
- {
- if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
- return -1;
+ if (!pl_sd) {
+ clif_displaymessage(fd, msg_txt(3)); // Character not found.
+ return -1;
+ }
+
+ if (pc_isGM(sd) < pc_isGM(pl_sd))
+ {
+ clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
- pl_sd->state.killable = !pl_sd->state.killable;
+ pl_sd->state.killable = !pl_sd->state.killable;
+
+ if(pl_sd->state.killable)
+ clif_displaymessage(fd, msg_txt(289));
+ else
+ clif_displaymessage(fd, msg_txt(290));
- if(pl_sd->state.killable)
- clif_displaymessage(fd, msg_txt(289));
- else
- clif_displaymessage(fd, msg_txt(290));
- }
- else
- clif_displaymessage(fd,msg_txt(3));
- //printf("Session_id = %d, aid = %d\n",session_id,aid);
return 0;
}
@@ -9646,13 +9496,13 @@ int atcommand_mobinfo( */
int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
{
- struct map_session_data *sd;
+ struct map_session_data *sd;
- if (!session[id] || (sd = session[id]->session_data) == NULL)
- return 0;
+ if (!session[id] || (sd = session[id]->session_data) == NULL)
+ return 0;
- clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
- return 1;
+ clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
+ return 1;
}
static int atshowmobs_sub(struct block_list *bl,va_list ap)
{
|