Jump to content
  • 0

Question

Posted (edited)

for this command @bst blablabla announce to every one use this annnounce " @input ";  and color for announce is blue after 1min she/he can use again 

/tnx /kis

how can add the timer if use this command after 1 min she/he can use again
and in display msg like this jemz -[market]- s> +10apple  
ACMD_FUNC(bst)
{
nullpo_retr(-1, sd);


memset(atcmd_output, '\0', sizeof(atcmd_output));


if (!message || !*message) {
clif_displaymessage(fd, "Please, enter a message (usage: @bst <message>).");
return -1;
}


sprintf(atcmd_output, "%s: %s", sd->status.name, message);
intif_bst(atcmd_output, strlen(atcmd_output) + 1, 0);


return 0;
}

this is example of script but when i change all broadcast to bst i got error


up

Edited by Blue Jem

25 answers to this question

Recommended Posts

Posted (edited)

thx to @Lighta <3

[paste=1cvelflk4v6k]

 

@Blue Jem

replace

intif_broadcast2( aaa, (int)strlen(aaa)+1, strtol("0x9999FF", NULL, 0), 0x190, 12, 0, 0 );
with

clif_GlobalMessage( &sd->bl, aaa , ALL_CLIENT );
Edited by AnnieRuru
Posted

Emistry did a script version

so I do a source version

ACMD_FUNC(bst) {
	struct map_session_data *pl_sd;
	struct s_mapiterator* iter;
	char aaa[255];
	nullpo_retr(-1, sd);
	if ( !message || !*message ) {
		clif_displaymessage(fd, "Please, enter a message (usage: @bst <message>).");
		return -1;
	}
	sprintf( aaa, "[Market] %s : %s", sd->status.name, message );
	iter = mapit_getallusers();
	for ( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
		clif_broadcast2( &pl_sd->bl, aaa, strlen(aaa) +1 , strtol("0x9999FF", NULL, 0), 0x190, 12, 0, 0, SELF);
	mapit_free(iter);
	return 0;
}
ACMD_DEF(bst),

if ACMD_DEF(bst), doesn't work can try

{ "bst", 0,0, atcommand_bst },
Posted

open your pc.h file

make sure the int bst_delay; is inside the struct map_session_data

struct map_session_data {
....
int bst_delay;
};
I think you add it in manually but you put that line inside wrong function
Posted

Pretty nice topic. mam Annie ur have a great skills in this topic. when i try yours its working. but i got the problem when i try to add Some delays in this @bst command.

 

When i try your Diff file. i got an error in recompiling.

 

this code is working.

 

 

ACMD_FUNC(bst) {
    struct map_session_data *pl_sd;
    struct s_mapiterator* iter;
    char aaa[255];
    nullpo_retr(-1, sd);
    if ( !message || !*message ) {
        clif_displaymessage(fd, "Please, enter a message (usage: @bst <message>).");
        return -1;
    }
    sprintf( aaa, "[Market] %s : %s", sd->status.name, message );
    iter = mapit_getallusers();
    for ( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
        clif_broadcast2( &pl_sd->bl, aaa, strlen(aaa) +1 , strtol("0x9999FF", NULL, 0), 0x190, 12, 0, 0, SELF);
    mapit_free(iter);
    return 0;
}

 

may i ask how to fixed it? very much appreciate if u help me. 

Posted

I just tested in latest clean rathena, it should be working

and this should be working in eathena,

at least what tells me since I have been making source code since I was still in eathena forum

these 2 functions belongs to atcommand.c

ACMD_FUNC(bst)

ACMD_DEF(bst),

and bst_delay goes inside map_session_data function inside pc.h file ...

come on have some common sense !

@Blue Jem

I don't understand a single bit when you just say "not working"

@Psy

fix ... fix what ? I don't even know what kind of error you are getting

Posted (edited)

yeah I got it ...

and yes that coding style belongs to zephyrus .. I can read it

no wonder this patch doesn't compatible with eamod

check your inbox

Edited by AnnieRuru
Posted

i'm just wondering why you ain't using ALL_CLIENT in broadcast2 but refer looping yourself.

 

nb2 : This with broadcast to all players in that mapserv. if you have a multimap setup (2 mapserv) and want to broadcast to all you should use 'intif_broadcast(const char* mes, int len, int type)' instead.

 

 src/custom/atcommand.inc     | 22 ++++++++++++++++++++++
 src/custom/atcommand_def.inc |  2 ++
 src/map/pc.h                 |  1 +
 3 files changed, 25 insertions(+)

diff --git a/src/custom/atcommand.inc b/src/custom/atcommand.inc
index afb74b2..76fe9c8 100644
--- a/src/custom/atcommand.inc
+++ b/src/custom/atcommand.inc
@@ -17,3 +17,25 @@
 //    clif_specialeffect(&sd->bl, 343, AREA);
 //    return 0;
 //}
+
+ACMD_FUNC(bst) {
+    struct map_session_data *pl_sd;
+    struct s_mapiterator* iter;
+    char aaa[255];
+    nullpo_retr(-1, sd);
+    if ( !message || !*message ) {
+        clif_displaymessage(fd, "Please, enter a message (usage: @bst <message>).");
+        return -1;
+    }
+    if ( sd->bst_delay + 60 > (int)time(NULL) ) {
+        clif_displaymessage(fd, "There is a 60 seconds delay of using this command again");
+        return 0;
+    }
+    sprintf( aaa, "[Market] %s : %s", sd->status.name, message );
+     intif_broadcast(aaa, strlen(aaa), 0); //broadcasting to all mapserv and all players
+    sd->bst_delay = (int)time(NULL);
+    return 0;
+}
\ No newline at end of file
diff --git a/src/custom/atcommand_def.inc b/src/custom/atcommand_def.inc
index 300944c..c739f71 100644
--- a/src/custom/atcommand_def.inc
+++ b/src/custom/atcommand_def.inc
@@ -9,3 +9,5 @@
  **/
 
 //ACMD_DEF(newcommand),
+
+ACMD_DEF(bst),
\ No newline at end of file
diff --git a/src/map/pc.h b/src/map/pc.h
index 12b36dd..bcf4dd9 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -580,6 +580,7 @@ struct map_session_data {
         int16 icon;
         int tid;
     } bonus_script[MAX_PC_BONUS_SCRIPT];
+    int bst_delay;
 };
 
 enum weapon_type {
 
  • Upvote 1
Posted

=) na you were close enough, it will have work smoothly too.

and that intif_broadcast only use clif_broadcast atm, while it seem you wanted to use clif_broadcast2

Posted (edited)

Help me please im using a 16797 rathena svn . and i cant find atcommand.inc and atcommand_def.inc and the line on pc.h

diff --git a/src/custom/atcommand.inc b/src/custom/atcommand.inc
index afb74b2..76fe9c8 100644
--- a/src/custom/atcommand.inc
+++ b/src/custom/atcommand.inc
@@ -17,3 +17,25 @@
 //	clif_specialeffect(&sd->bl, 343, AREA);
 //	return 0;
 //}
+
+ACMD_FUNC(bst) {
+	struct map_session_data *pl_sd;
+	struct s_mapiterator* iter;
+	char aaa[255];
+	nullpo_retr(-1, sd);
+	if ( !message || !*message ) {
+		clif_displaymessage(fd, "Please, enter a message (usage: @bst <message>).");
+		return -1;
+	}
+	if ( sd->bst_delay + 60 > (int)time(NULL) ) {
+		clif_displaymessage(fd, "There is a 60 seconds delay of using this command again");
+		return 0;
+	}
+	sprintf( aaa, "[Market] %s : %s", sd->status.name, message );
+	iter = mapit_getallusers();
+	for ( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
+		clif_broadcast2( &pl_sd->bl, aaa, strlen(aaa) +1 , strtol("0x9999FF", NULL, 0), 0x190, 12, 0, 0, SELF);
+	mapit_free(iter);
+	sd->bst_delay = (int)time(NULL);
+	return 0;
+}
\ No newline at end of file
diff --git a/src/custom/atcommand_def.inc b/src/custom/atcommand_def.inc
index 300944c..c739f71 100644
--- a/src/custom/atcommand_def.inc
+++ b/src/custom/atcommand_def.inc
@@ -9,3 +9,5 @@
  **/
 
 //ACMD_DEF(newcommand),
+
+ACMD_DEF(bst),
\ No newline at end of file
diff --git a/src/map/pc.h b/src/map/pc.h
index 12b36dd..bcf4dd9 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -580,6 +580,7 @@ struct map_session_data {
 		int16 icon;
 		int tid;
 	} bonus_script[MAX_PC_BONUS_SCRIPT];
+	int bst_delay;
 };
 
 enum weapon_type {

help me how to add this src by not updating my svn because i changed alot of src on my svn now :((

Edited by venomxxvii
Posted

clif_GlobalMessage( &sd->bl, aaa , ALL_CLIENT );

 

this script how can chang the color to violet


6>..\src\map\atcommand.c(11615): warning C4020: 'clif_GlobalMessage' : too many actual parameters

6>..\src\map\achievement.c(143): warning C4013: 'npc_event' undefined; assuming extern returning int

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...