-
Content Count
1677 -
Joined
-
Last visited
-
Days Won
245
Reputation Activity
-
AnnieRuru reacted to THPO in dispbottomcolor
Found some little thingy Ms. Annie RRGGBB is backwards, BBGGRR.
-
AnnieRuru reacted to Rytech in Last monster ID ?
No. The client can only handle a range between 1001 to 3999. Currently the highest used ID is C_RAKE_SCARABA = 3365 and im sure within a year or a year and a half they will run out and make a 2nd range.
-
AnnieRuru reacted to Angelmelody in Chat space limitation!/Scammer avoid *Will pay for help*
AFAIK, Alt+03232 = Alt+160
so just stristr( message, "xA0" )
-
AnnieRuru got a reaction from Jedzkie in Chat space limitation!/Scammer avoid *Will pay for help*
I got a very quick way of doing this
src/map/clif.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..cbb080c 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,27 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( stristr( message, ":" ) || stristr( message, ";" ) ) {+ char* array_names[8] = { // change 8 into total number of elements from the array below+ "AnnieRuru", // change all these to all your GM staff names+ "EnnyRuru",+ "Aurela",+ "Lumina",+ "Evilpunker",+ "Frost",+ "Garr",+ "KinoRuru"+ };+ int i;+ for ( i = 0; i < 8; i++ ) { // change the 8 here too+ if ( stristr( message, array_names[i] ) ) {+ clif->colormes( fd, COLOR_RED, "You can't impersonate as a GM staff !" );+ return false;+ }+ }+ }+ return true; } create a blacklist and detects them when they input ":" or ";" plus any of the names mentioned in the array
but this is not an ideal way of how to code it ... ima thinking of using the correct way on how Ind code his manner.c
using an external file impersonate.txt along with @reloadimpersonate something like Ind did
EDIT: on 2nd thought, maybe you guys can just use Ind's manner.c ...
-
AnnieRuru got a reaction from Ehwaz in Last monster ID ?
why do you need last monster ID for ? doesn't make sense
select * from mob_db where id = ( select max(id) from mob_db ); and some people also change MAX_MOB_DB
-
AnnieRuru got a reaction from evilpuncker in Add *getguildmember script command
com'on ... rathena added this ages ago ... and we still don't have ? why ?
http://rathena.org/board/topic/78308-getguildmember/?p=244554
any guild based event definitely need this command
don't have to use *query_sql anymore
prontera,152,187,5 script dsasda2 100,{.@nb = query_sql( "select name, online from `char` where guild_id = "+ getcharid(2), .@name$, .@online );for ( .@i = 0; .@i < .@nb; .@i++ )dispbottom .@i +". "+ .@name$[.@i] +" -> "+( ( .@online[.@i] )? "online" : "offline" );end;} should be change into
prontera,150,187,5 script dsasda 100,{getguildmember getcharid(2), 0;getguildmember getcharid(2), 1;getguildmember getcharid(2), 2;for ( .@i = 0; .@i < $@guildmembercount; .@i++ )dispbottom .@i +". "+ $@guildmembername$[.@i] +" -> "+( ( isloggedin( $@guildmemberaid[.@i] , $@guildmembercid[.@i] ) )? "online" : "offline" );end;}
pull request => https://github.com/HerculesWS/Hercules/pull/335
-
AnnieRuru got a reaction from kyeme in Add *getguildmember script command
com'on ... rathena added this ages ago ... and we still don't have ? why ?
http://rathena.org/board/topic/78308-getguildmember/?p=244554
any guild based event definitely need this command
don't have to use *query_sql anymore
prontera,152,187,5 script dsasda2 100,{.@nb = query_sql( "select name, online from `char` where guild_id = "+ getcharid(2), .@name$, .@online );for ( .@i = 0; .@i < .@nb; .@i++ )dispbottom .@i +". "+ .@name$[.@i] +" -> "+( ( .@online[.@i] )? "online" : "offline" );end;} should be change into
prontera,150,187,5 script dsasda 100,{getguildmember getcharid(2), 0;getguildmember getcharid(2), 1;getguildmember getcharid(2), 2;for ( .@i = 0; .@i < $@guildmembercount; .@i++ )dispbottom .@i +". "+ $@guildmembername$[.@i] +" -> "+( ( isloggedin( $@guildmemberaid[.@i] , $@guildmembercid[.@i] ) )? "online" : "offline" );end;}
pull request => https://github.com/HerculesWS/Hercules/pull/335
-
AnnieRuru got a reaction from evilpuncker in Chat space limitation!/Scammer avoid *Will pay for help*
try this
patch
src/map/clif.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..42790b9 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,20 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( sd->chatID ) {+ if ( stristr( message, ":" ) ) {+ struct chat_data *cd = (struct chat_data *)map->id2bl(sd->chatID);+ int i;+ for ( i = 0; i < cd->users; i++ ) {+ if ( stristr( message, cd->usersd[i]->status.name ) ) {+ clif->colormes( fd, COLOR_RED, "You can't impersonate others in a chatroom !" );+ return false; + }+ }+ }+ }+ return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../map/chat.h"#include "../common/HPMi.h"#include "../common/socket.h"#include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)HPExport struct hplugin_info pinfo = { "chatroom_impersonate", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true && sd->chatID ) { char* message = (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3; if ( stristr( message, ":" ) ) { struct chat_data *cd = (struct chat_data *)map->id2bl(sd->chatID); int i; for ( i = 0; i < cd->users; i++ ) { if ( stristr( message, cd->usersd[i]->status.name ) ) { clif->colormes( sd->fd, COLOR_RED, "You can't impersonate others in a chatroom !" ); return false; } } } } return true;}HPExport void plugin_init (void) { map = GET_SYMBOL("map"); clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);} -
AnnieRuru got a reaction from evilpuncker in Chat space limitation!/Scammer avoid *Will pay for help*
@Lumina
like I said, don't use Notepad++, manually type in Microsoft Windows Notepad
classic one
although,
I got a better idea
since in a chatroom, to impersonate other has to type long sentence and then [space] then follow by
Name :
how about we restrict them by not typing like this
if ( sscanf( "%s : ", sd->name ) )
so if they type something like
"EnnyRuru : "
the script will detect it and stop it
just for my personal reference ...
getwaitingroomlist
pc_getwaitingroomlist
-
AnnieRuru reacted to vBrenth in Chat space limitation!/Scammer avoid *Will pay for help*
Its working and i know why you want this because of the people who are trying to scam by using spaces on pub.
They can still bypass this by using 2space+alt03232 again and again.
-
AnnieRuru got a reaction from vBrenth in Chat space limitation!/Scammer avoid *Will pay for help*
willingly to pay ? omg, I can send this as a birthday gift
patch
src/map/clif.c | 5 +++++ 1 file changed, 5 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..ede1a52 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,11 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( stristr( message, " " ) != NULL ) {+ clif_displaymessage( fd, "You're only allowed to do max 3 spaces in a row." );+ return false;+ } return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../common/HPMi.h"#include "../common/socket.h"#include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)HPExport struct hplugin_info pinfo = { "max_3_space", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true ) { if ( stristr( (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3, " " ) != NULL ) { clif->message( sd->fd, "You're only allowed to do max 3 spaces in a row." ); return false; } } return true;}HPExport void plugin_init (void) { clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);} -
AnnieRuru got a reaction from Angelmelody in Chat space limitation!/Scammer avoid *Will pay for help*
willingly to pay ? omg, I can send this as a birthday gift
patch
src/map/clif.c | 5 +++++ 1 file changed, 5 insertions(+)diff --git a/src/map/clif.c b/src/map/clif.cindex d9acf07..ede1a52 100644--- a/src/map/clif.c+++ b/src/map/clif.c@@ -9110,6 +9110,11 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, *namelen_ = namelen; *message_ = message; *messagelen_ = messagelen;++ if ( stristr( message, " " ) != NULL ) {+ clif_displaymessage( fd, "You're only allowed to do max 3 spaces in a row." );+ return false;+ } return true; } plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../map/clif.h"#include "../common/HPMi.h"#include "../common/socket.h"#include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)HPExport struct hplugin_info pinfo = { "max_3_space", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated)};bool clif_process_message_spaces( int retVal, struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) { if ( retVal == true ) { if ( stristr( (char*)RFIFOP( sd->fd ,4) + strnlen(sd->status.name, NAME_LENGTH-1) + 3, " " ) != NULL ) { clif->message( sd->fd, "You're only allowed to do max 3 spaces in a row." ); return false; } } return true;}HPExport void plugin_init (void) { clif = GET_SYMBOL("clif"); session = GET_SYMBOL("session"); strlib = GET_SYMBOL("strlib"); addHookPost("clif->process_message", clif_process_message_spaces);} -
AnnieRuru got a reaction from GmOcean in MapServer Crash - Equip2
wow ... already trying to use plugin on the 1st day o.o
it actually took me about 1~2 weeks for me to understand what is plugin when I 1st came LOL
ok ... you actually enter the final phase when writing a plugin
which is testing for map-server to crash
the final step is search for every commands that has '->'
in your script, having ...
script->rid2sdpc->equipitemmap->id2sditemdb->existsthen just add them into the plugin_init function as thisHPExport void plugin_init (void) { script = GET_SYMBOL("script"); pc = GET_SYMBOL("pc"); map = GET_SYMBOL("map"); itemdb = GET_SYMBOL("itemdb"); addScriptCommand( "equip2", "viiiiii?", equip2);}..
.
and although already tested working in my test server too
prontera,156,184,5 script kjdhfksjfs 100,{ getitem2 1201, 1,1,0,0, 0,0,0,0; equip2 1201, 0,0, 0,0,0,0; sleep2 1000; getitem2 1201, 1,1,0,0, 0,0,0,4001; equip2 1201, 0,0, 0,0,0,4001; end;}your command keep spamming the npc coordinate in console, because you did a 'return 0;'
in rathena, commands are return by
return SCRIPT_CMD_SUCCESS; (0)
return SCRIPT_CMD_FAILURE; (1)
in hercules, note that its actually opposite
return true; (1)
return false; (0)
so change that 'return 0;' into 'return true;'
http://upaste.me/4b092e
-
AnnieRuru got a reaction from RodRich in dispbottomcolor
since our developers are ... not implementing dispbottom and message with colors
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?p=28345
I think I just make a release for this
Download: 1.2
Plugin
tested with
prontera,162,180,5 script asdf 100,{ dispbottomcolor "test color", 0xFF0000; dispbottomcolor "test color", 0x00FF00; dispbottomcolor "test color", 0x0000FF; dispbottomcolor "test color", 0xFFFFFF, 2000000; end;}PS: there is a reason that this couldn't be in the officialbecause hercules' clif->colormes is ... badly coded ...
changing that function also means change a lot of lines having clif->colormes, which is all over the places
-
AnnieRuru got a reaction from jTynne in Enchanter
problem ... there is "Atk_Speed1" and "Atk_Speed2", but there is no "Atk_Speed3"
prontera,156,179,5 script Enchanter 100,{// rentitem Cotton_Shirt_, 10; mes "select which equipment to enchant"; next; .@s = select ( "Armor - "+( ( getequipisequiped( EQI_ARMOR ) )? "^0000FF["+ getequipname( EQI_ARMOR ) +"]" : "^FF0000 (none)" )+"^000000", "Garment - "+( ( getequipisequiped( EQI_GARMENT ) )? "^0000FF["+ getequipname( EQI_GARMENT ) +"]" : "^FF0000 (none)" )+"^000000", "Shield - "+( ( getequipisequiped( EQI_HAND_L ) && getiteminfo( getequipid( EQI_HAND_L ), 2 ) == IT_ARMOR )? "^0000FF["+ getequipname( EQI_HAND_L ) +"]" : "^FF0000 (none)" )+"^000000", "Shoes - "+( ( getequipisequiped( EQI_SHOES ) )? "^0000FF["+ getequipname( EQI_SHOES ) +"]" : "^FF0000 (none)" )+"^000000" ); .@pos = .pos[.@s]; if ( getequipcardid( .@pos, 3 ) ) { mes "this item has been enchanted"; close; } .@eq = getequipid( .@pos ); mes "select the type of enchant"; next; .@type = select( .enc_menu$ ) -1; mes "select the level of enchantment"; mes "level 1 has 30% chance of success"; mes "level 2 has 20% chance of success"; mes "level 3 has 10% chance of success"; next; .@level = select( "1", "2", "3" ); mes "Are you sure you want to insert level "+ .@level +" "+ .enc$[.@type] +" into your "+ getitemname( .@eq ) +" ?"; mes "The fee is 250,000z and 3 Poring Coin"; next; if ( select( "Yes", "No" ) == 2 ) close;// counter check ... in case player change the equipment if ( getequipid( .@pos ) != .@eq ) { mes "what the hell ... you changed the item !"; close; } if ( getequipcardid( .@pos, 3 ) ) { mes "what the hell ... this item has been enchanted !"; close; } if ( Zeny < 250000 ) { mes "You don't have enough Zeny"; close; } if ( countitem( Poring_Coin ) < 3 ) { mes "You don't have enough Poring Coin"; close; } Zeny -= 250000; delitem Poring_Coin, 3; .@refine = getequiprefinerycnt( .@pos ); .@card0 = getequipcardid( .@pos, 0 ); .@card1 = getequipcardid( .@pos, 1 ); .@card2 = getequipcardid( .@pos, 2 ); if ( rand(100) < .rate[ .@level ] ) { delitem2 .@eq, 1, 1, .@refine, 0, .@card0, .@card1, .@card2, 0; getitem2 .@eq, 1, 1, .@refine, 0, .@card0, .@card1, .@card2, getd( ".enc"+ .@level +"["+ .@type +"]" ); mes "It's a success !"; } else mes "It's a failure ..."; close;OnInit: .material = Poring_Coin; setarray .pos[1], EQI_ARMOR, EQI_GARMENT, EQI_HAND_L, EQI_SHOES; setarray .enc$, "Str", "Int", "Dex", "Agi", "Vit", "Luk", "Atk", "Matk", "HP"; setarray .enc1, Strength1, Inteligence1, Dexterity1, Agility1, Vitality1, Luck1, Atk1, Matk1, HP100; setarray .enc2, Strength2, Inteligence2, Dexterity2, Agility2, Vitality2, Luck2, Atk2, Matk2, HP200; setarray .enc3, Strength3, Inteligence3, Dexterity3, Agility3, Vitality3, Luck3, Atk3, Matk3, HP300; setarray .rate[1], 30, 20, 10; .enc_menu$ = implode( .enc$, ":" ); end;}I think this script quite dangerous ... there is not script command for checking the equipment is bounded or rentedwithout the checks, player can use this script to change bounded or rented equipment into permanent trade-able equipment
-
AnnieRuru got a reaction from sever in dispbottomcolor
since our developers are ... not implementing dispbottom and message with colors
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?p=28345
I think I just make a release for this
Download: 1.2
Plugin
tested with
prontera,162,180,5 script asdf 100,{ dispbottomcolor "test color", 0xFF0000; dispbottomcolor "test color", 0x00FF00; dispbottomcolor "test color", 0x0000FF; dispbottomcolor "test color", 0xFFFFFF, 2000000; end;}PS: there is a reason that this couldn't be in the officialbecause hercules' clif->colormes is ... badly coded ...
changing that function also means change a lot of lines having clif->colormes, which is all over the places
-
AnnieRuru got a reaction from Ehwaz in dispbottomcolor
since our developers are ... not implementing dispbottom and message with colors
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?p=28345
I think I just make a release for this
Download: 1.2
Plugin
tested with
prontera,162,180,5 script asdf 100,{ dispbottomcolor "test color", 0xFF0000; dispbottomcolor "test color", 0x00FF00; dispbottomcolor "test color", 0x0000FF; dispbottomcolor "test color", 0xFFFFFF, 2000000; end;}PS: there is a reason that this couldn't be in the officialbecause hercules' clif->colormes is ... badly coded ...
changing that function also means change a lot of lines having clif->colormes, which is all over the places
-
AnnieRuru got a reaction from kyeme in dispbottomcolor
since our developers are ... not implementing dispbottom and message with colors
http://herc.ws/board/topic/3899-suggestion-displaybottom-message-colors/?p=28345
I think I just make a release for this
Download: 1.2
Plugin
tested with
prontera,162,180,5 script asdf 100,{ dispbottomcolor "test color", 0xFF0000; dispbottomcolor "test color", 0x00FF00; dispbottomcolor "test color", 0x0000FF; dispbottomcolor "test color", 0xFFFFFF, 2000000; end;}PS: there is a reason that this couldn't be in the officialbecause hercules' clif->colormes is ... badly coded ...
changing that function also means change a lot of lines having clif->colormes, which is all over the places
-
AnnieRuru got a reaction from Angelmelody in Instance System
yes, official hercules instance script doesn't change much
prontera,155,180,0 script Party Room 123,{ if ( has_instance2( "1@cata" ) >= 0 ) { warp has_instance( "1@cata" ), 0,0; end; } mes "renting a room for party"; next; if ( ( .@ins = instance_create( "Rent a Room", getcharid(1) ) ) < 0 ) { mes "error : "+ .@ins; close; } if ( instance_attachmap( "1@cata", .@ins ) == "" ) { mes "error : 5"; instance_destroy .@ins; close; } instance_set_timeout 30, 0, .@ins; instance_init .@ins; instance_attach .@ins; warp has_instance( "1@cata" ), 0,0; end;}I'm sure you'll feel familiar with the old system
but look at this ... instance guild room ... yummy ~
prontera,158,180,0 script Guild Room 123,{ if ( has_instance2( "guild_vs2" ) >= 0 ) { warp has_instance( "guild_vs2" ), 0,0; end; } mes "renting a room for guild"; next; if ( ( .@ins = instance_create( "Rent a Room", getcharid(2), IOT_GUILD ) ) < 0 ) { mes "error : "+ .@ins; close; } if ( instance_attachmap( "guild_vs2", .@ins, 1, getcharid(2)+"room" ) == "" ) { mes "error : 5"; instance_destroy .@ins; close; } instance_set_timeout 30, 0, .@ins; instance_init .@ins; instance_attach .@ins; warp has_instance( "guild_vs2" ), 0,0; end;} unfortunately, many src edit from rathena are not compatible with herculesif you can read the source code, hercules source code parse faster than rathena
example like
rathena : clif_message
hercules : clif->message
so all your source edit has to be rewritten
fortunately, we have plugin system ...
http://herc.ws/board/topic/549-
so you just need to code it once, and can forget about it
-
AnnieRuru got a reaction from GmOcean in Instance System
I been supporting scripting question on both forums so I can compare
rathena instance system is indeed easier to write
both also can create new maps ...
rathena is easier to do this ... they have instance_db.txt to make everything simple
but hercules one can attach the map to the guild ... which allows for new ideas
IOT_GUILD
allows for whole new ideas ... like guild dungeon, guild castle ... etc etc
for this, rathena can't even do this, because they default to party based, forcing the player to form a party
2nd thing about rathena is they removed the instace_set_timeout
which is kinda an outrages move
it should be configure in npc scripting so I can make a map for the time limit to be rent dynamically
eg : rathena time limit is configured at instance_db.txt,
where as hercules can use instance_set_timeout script command to change the time to the *input script command
-
AnnieRuru got a reaction from icabit in 3 questions regarding AnnieRuru scripts
if you want to ask question just open a topic, no need to shy
all these questions has been asked before on eathena
if it isn't down right now, I can just give you the links
now I have to explain all over again
1.
no, my example follows exactly the script_commands.txt
there's no different with these 2 codes
prontera,155,184,5 script sample#1 100,{.@charid = getcharid(0);getitem2 1601, 1, 1, 0,0, 255, 0, .@charid % pow(2,16), .@charid / pow(2,16); // <-- minegetitem2 1601, 1, 1, 0,0, 255, 0, .@charid & 65535, .@charid >> 16; // <-- script commands.txtend;}
both sentence will gives you same item
.
.
ok how to explain this ...
if your character has char_id of 150000
when you click the above script and look in the SQL table
select nameid, card0, card1, card2, card3 from inventory where char_id = 150000; return -> 1601,255,0,18928,2
the card2 field - 18928 is actually the remainder of 216 -> .@charid % pow(2,16)
the card3 field - 2 is actually the division of 216 -> .@charid / pow(2,16)
so my sentence is just exactly match what I said
you can also try this
prontera,157,184,5 script sample#2 100,{mes "enter a player name";next;input .@input$;if ( !query_sql( "select char_id, name from `char` where name = '"+ escape_sql( .@input$ ) +"'", .@cid, .@name$ ) ) { // if there is no row return from the querymes "player not found";close;}mes "you get "+ .@name$ +"'s Rod";getitem2 1601, 1, 1, 0,0, 255, 0, .@cid % pow(2,16), .@cid / pow(2,16);close;}
.
.
ok so now you understand that card2 is remainder and card3 is division of char_id
now why do script_commands.txt use binary operations
its because computer actually process faster with just 0 and 1
since we are small we were taught in mathematics, that numbers are in 1,2,3,4,5,6,7,8,9,10
this is actually base 10 operations
example ... every time you update your server using new client, you change PACKETVER 20140115
21040115
I can play it with the script like this
prontera,159,184,5 script sample#3 100,{mes PACKETVER +""; // return 20140115mes "Year = "+ PACKETVER / 10000; // return 2014mes "Month = "+ PACKETVER / 100 % 100; // return 1 ( 01, the zero is omitted )mes "Day = "+ PACKETVER % 100; // return 15close;} .
.
Part 2 : here comes bit-shifting operations
I assumed that you already know what is binary numbers
let say, I give a number -> 10101010
if you divide 101010 by 1, you'll get 101010
if you divide 101010 by 10, you'll get 10101
if you divide 101010 by 100, you'll get 1010
if you divide 101010 by 1000, you'll get 101
if you divide 101010 by 10000, you'll get 10
if you divide 101010 by 100000, you'll get 1
prontera,161,184,5 script sample#4 100,{.@num = 101010;dispbottom .@num / 1 +""; // return 101010dispbottom .@num / 10 +""; // return 10101dispbottom .@num / 100 +""; // return 1010dispbottom .@num / 1000 +""; // return 101dispbottom .@num / 10000 +""; // return 10dispbottom .@num / 100000 +""; // return 1end;}
same as
if you divide 101010 by 100, you'll get 101010
if you divide 101010 by 101, you'll get 10101
if you divide 101010 by 102, you'll get 1010
if you divide 101010 by 103, you'll get 101
if you divide 101010 by 104, you'll get 10
if you divide 101010 by 105, you'll get 1
prontera,163,184,5 script sample#5 100,{.@num = 101010;dispbottom .@num / pow( 10, 0 )+""; // return 101010dispbottom .@num / pow( 10, 1 ) +""; // return 10101dispbottom .@num / pow( 10, 2 ) +""; // return 1010dispbottom .@num / pow( 10, 3 ) +""; // return 101dispbottom .@num / pow( 10, 4 ) +""; // return 10dispbottom .@num / pow( 10, 5 ) +""; // return 1end;}
-> 10101010 / 100 = 10101010
-> 10101010 / 101 = 1010110
-> 10101010 / 102 = 101010
-> 10101010 / 103 = 10110
-> 10101010 / 104 = 1010
-> 10101010 / 105 = 110
and now, let's say I give a number 1010102, which is 4210
prontera,166,184,5 script sample#6 100,{.@num = 42;dispbottom ( .@num >> 0 )+""; // return 42dispbottom ( .@num >> 1 )+""; // return 21dispbottom ( .@num >> 2 )+""; // return 10dispbottom ( .@num >> 3 )+""; // return 5dispbottom ( .@num >> 4 )+""; // return 2dispbottom ( .@num >> 5 )+""; // return 1end;}prontera,168,184,5 script sample#7 100,{.@num = 42;dispbottom .@num / pow( 2, 0 )+""; // return 42dispbottom .@num / pow( 2, 1 )+""; // return 21dispbottom .@num / pow( 2, 2 )+""; // return 10dispbottom .@num / pow( 2, 3 )+""; // return 5dispbottom .@num / pow( 2, 4 )+""; // return 2dispbottom .@num / pow( 2, 5 )+""; // return 1end;}
both scripts do the same
-> 42 / 20 = 42
-> 42 / 21 = 21
-> 42 / 22 = 10
-> 42 / 23 = 5
-> 42 / 24 = 2
-> 42 / 25 = 1
equal to
-> 1010102 / 102 = 1010102 = 4210
-> 1010102 / 102 = 101012 = 2110
-> 1010102 / 102 = 10102 = 1010
-> 1010102 / 102 = 1012 = 510
-> 1010102 / 102 = 102 = 210
-> 1010102 / 102 = 12 = 110
so, you'll noticed a pattern
in base 10, to decrease the digits by removing the last digit, you do
number / 10
Example => 10101010 / 10 = 1010110
in base 2, to decrease the last bit, you do right shift
number >> 1
Example => 1010102 >> 1 = 101012
=> 4210 >> 1 = 2110
its the same when opposite
in base 10, to increase the digits by adding zero at the back, you do
number * 10
Example => 10101010 * 10 = 101010010
in base 2, to increase the bits by adding zero, you do left shift
number << 1
Example => 1010102 << 1 = 10101002
=> 4210 << 1 = 8410
another example ...
if I want cut 10101010 into half
in base 10 (decimal) operations, we do
prontera,150,180,5 script sample#8 100,{.@num = 101010;dispbottom .@num / 1000 +""; // return 101dispbottom .@num % 1000 +""; // return 10 ( 010, zero is omitted )end;}
if I want to cut 1010102 into half
in base 2 (binary) operations, 2 ways in athena script engine
prontera,152,180,5 script sample#9 100,{.@num = 42;dispbottom .@num / pow(2,3) +""; // return 5 -> 101 base 2dispbottom .@num % pow(2,3) +""; // return 2 -> 010 base 2end;}
prontera,154,180,5 script sample#10 100,{.@num = 42;dispbottom ( .@num >> 3 )+""; // return 5 -> 101 base 2dispbottom ( .@num & ( (1<<3) -1 ) )+""; // return 2 -> 010 base 2end;} although both script do the same thing,
but the computer will compute 2nd sample, which using binary shift faster
because computer prefer to calculate numbers in binary form
so revise back ...
getitem2 1601, 1, 1, 0,0, 255, 0, .@charid % pow(2,16), .@charid / pow(2,16); // <-- minegetitem2 1601, 1, 1, 0,0, 255, 0, .@charid & 65535, .@charid >> 16; // <-- script commands.txt if you go look at sql-files
https://github.com/HerculesWS/Hercules/blob/master/sql-files/main.sql#L104
the card fields are using smallint, which is 216
since 150000 is higher than 32768, that's why it is being split
150000 % pow(2,16) as card2 field
150000 / pow(2,16) as card3 field
.... actually binary shifting operation has another uses ... to store more information using lesser variables ...
which is part 3 ... damn eathena forum down really wasting my time writing again
however this post takes me almost 1 hour to write so meh ... some other time then
-
AnnieRuru got a reaction from Zirius in who has AnnieRuru's PVP Ladder with announcement files and SQL queries?
no, I put 16 | .announceannounce "blahblah",16|.announce;16 is bc_blueremove the 16 and you can put color code
btw, I have no idea why .announcekill was defaulted to off, it has to turn on
set .announcekill, 0; // announce who pawn who's head : 0 - off, 1 - on
-
AnnieRuru got a reaction from icabit in for improvement
change
query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3),.@lastmac1$;query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+.@accid,.@lastmac2$;if(.@lastmac1$==.@lastmac2$) { into
if ( query_sql( "select 1 from totaltime where last_mac = ( select last_mac from login where account_id = "+ getcharid(3) +" ) and account_id != "+ getcharid(3), .@dummy ) ) { --edited--
.
.
btw this kind of script uses way too many query_sql in a single npc click
its better that you optimized the SQL query, like I did above ( squeezing 2 Sql_handle into 1),
otherwise this script might produce lag when used on a live server
example like the one below
query_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+.@accid,.@rtime;//gets the time of the recruiterquery_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@rtime2;//gets the the of the newbieif (.@rtime2>=.@rtime) //compare both times change into
query_sql "select ( select time from totaltime where account_id = "+ getcharid(3) +" ) - ( select time from totaltime where account_id = "+ .@accid +" )", .@time_diff;if ( .@time_diff > 0 ) //compare both times ... if positive numbers
-
AnnieRuru got a reaction from Psy Ops in who has AnnieRuru's PVP Ladder with announcement files and SQL queries?
just mirror ... in-case
dota_pvpladder.2.9.txt
dotasoundeffect_2.rar
actually I want to drop this script
just ... I have no idea it can become so popular ...
that "replace into" was slower than "update" statement, I learned that only after 3 years completed this script
I was using 'replace into' just because I wanted to squeeze that accessing 12 times query_sql into just 4 times
and ultramage also proposed to make the table make a huge 'update' every 1 minute to safe further memory
however if changing 'replace into' into 'update' might need to update the whole script
and I have no motivation to improve this script, I rather focus on battleground scripts
-
AnnieRuru got a reaction from Zirius in who has AnnieRuru's PVP Ladder with announcement files and SQL queries?
of course I have, I'm the author
.... but some google search, somebody already mirror my file
http://pastebin.com/Ynze1S7P
http://tbro-ph.com/rAFreeFiles/NPC Scripts/
now I look back at this script ... that I made 6 years ago ... a lot of places can be improved
and I remember that I left out the "modify a value" option, which was took out from 2.7
though, I can guarantee this script still works in latest hercules