M4karov Posted December 4, 2018 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 149 Reputation: 37 Joined: 04/01/13 Last Seen: June 18, 2024 Share Posted December 4, 2018 How to create a color message using the "mes" command? In case I want to write: mes2 "Red Color"; And in-game appears:Red color Note: without using "^FF0000 ^000000 Quote Link to comment Share on other sites More sharing options...
0 n0tttt Posted December 4, 2018 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 303 Reputation: 118 Joined: 12/10/16 Last Seen: Yesterday at 02:39 AM Share Posted December 4, 2018 function script mes2 { setarray .@color$[0],"red","ff0000","green","00ff00","blue","0000ff"; .@str$ = strtolower(getarg(0)); .@mes$ = getarg(1); .@color = inarray(.@color$,.@str$); mes ((.@color != -1)? "^"+.@color$[.@i + 1] : "") + .@mes$; return; } mes2 "red","Hello there."; mes2 "green","What's up?"; close; Add colors in .@color$ 1 Quote Link to comment Share on other sites More sharing options...
0 M4karov Posted December 4, 2018 Group: Members Topic Count: 30 Topics Per Day: 0.01 Content Count: 149 Reputation: 37 Joined: 04/01/13 Last Seen: June 18, 2024 Author Share Posted December 4, 2018 Thanks for replying, but in case it would be by source same. No script. By script I had already done, wanted to change. function script F_Color { if(getarg(1) == "null") return ""; setarray .@cores$[0], "amarelo", "^FFFF00", "azul", "^0000FF", "branco", "^EEE9E9", "dourado", "^DAA520", "cinza", "^696969", "laranja", "^FF7F00", "marrom","^8B4726", "preto", "^000000", "roxo", "^4527A0", "vermelho", "^FF0000", "verde", "^1B5E20"; .@cor$ = strtolower(getarg(1)); for(.@i = 0; .@i < getarraysize(.@cores$); .@i += 2) if(.@cores$[.@i] == getarg(1)) return .@cores$[.@i + 1] + getarg(0) + "^000000"; return getarg(1) + getarg(0) + "^000000"; } Quote Link to comment Share on other sites More sharing options...
0 n0tttt Posted December 4, 2018 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 303 Reputation: 118 Joined: 12/10/16 Last Seen: Yesterday at 02:39 AM Share Posted December 4, 2018 (edited) I'm not really good with source but I tried... BUILDIN_FUNC(mes2) { TBL_PC* sd; if( !script_rid2sd(sd) ) return SCRIPT_CMD_SUCCESS; int color_n = script_getnum(st,2); char *message; size_t len = 0; unsigned long color = color_table[color_n]; char color_string = "^"; char color_code = (char*)color; message = (char*)aMalloc(2); len = strlen(color_code); memcpy(&message, color_string, 1); memcpy(&message, color_code, len); temp = script_getstr(st, 3); len = strlen(temp); memcpy(&message, temp, len); clif_scriptmes(sd, st->oid, message)); st->mes_active = 1; // Invoking character has a NPC dialog box open. return SCRIPT_CMD_SUCCESS; } BUILDIN_DEF(mes2,"is"), EDIT: Forgot to say this uses the channel system colors... if it works. Edited December 4, 2018 by n0tttt Quote Link to comment Share on other sites More sharing options...
Question
M4karov
How to create a color message using the "mes" command?
In case I want to write:
mes2 "Red Color";
And in-game appears:
Red color
Note:
without using "^FF0000 ^000000
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.