Monday, September 28, 2020

moving word in waitingroom

today I just review another member's script and this part caught my eye

HAHAHA !! this is so cute yet so wasting server resources !!!


I dunno I should praise him for creativity or comment him for being dump for wasting so much server bandwidth for doing this 😅

yes I don't recommend doing this on your live server ...
because every *waitingroom script command means sending one packet to each player surround this npc
... but I'm sooo impressed 😝

Sunday, September 27, 2020

A race condition in npc scripts

today I just reviewed a paid script (I couldn't show because its paid)
and I saw multiple errors and mistakes on the said script !!

this one in particular, is something less well known, but it is VERY important if you are making a Game script

let's give an example

at first glance this script looks bug free, but there is a race condition going on after the *input command

step to reproduce :-
1. open up 4 client, first 2 player claim the reward normally
2. on 3rd client, type 'ragnarok' but don't hit enter yet
3. on 4th client, type 'ragnarok' and hit enter, now the script says the event has ended
4. back on 3rd client, hit the Enter key, now this event has 4 players won this event !

to prevent this from happening, needs to add another check right after the *input command


another example is on my Private MVP Room script, which can be found in rathena repo
https://github.com/rathena/rathena/blob/a4d57cb8a398368c0d720aedc669dff88f73c4d4/npc/custom/etc/mvp_room.txt#L62-L66

now try remove these line
1. let player A register an empty room, but left the menu window open
2. player B register the empty room faster than player A
3. now both player A and player B can go into the same room !
4. if this is register under party/guild, player's B party/guild member couldn't get in even after paying the fees !!

so remember, if you are making a Game or Event script, every time after hitting a next; *menu *select *input *progressbar
the value might have changed from the original value, and might lead to race conditions between players

The Importance of *checkweight

today I just reviewed a paid script (I couldn't show because its paid)
and I saw multiple errors and mistakes on the said script !!

and this is one that MANY ... I mean MANY scripters has made this mistakes !!


if the player is currently overweight, or having more items than *getinventorysize(), the item will drop on the floor
if this actually happens, other players around this npc can come in to steal the reward item while the actual winner still desperately trying to store item

to fix this, all you have to do is add *checkweight script command
or use *rodex_sendmail script command ... or *mail script command for rathena

Friday, February 22, 2019

List pet eggs in your inventory

Just like signed items, which use 255 or 254 in the card1 field


Hercules Pet egg uses -256 in the card1 field
rathena use 256 ... without the negative

the earliest ... traceable topic is over here
https://rathena.org/board/topic/76954-can-i-request-script-evolution-pet/?sortby=date

and now for the latest script available...
https://drive.google.com/file/d/1hQgJO4MbHIQtymKxnsrxsi37nkJ1eruz/view

the way to retrieve the pet ID is almost similar to the signed item

Signed Item
card1 = 255 or 254
card2 = star crumb + element
card3 = CHAR_ID & (( 1 << 16 ) -1)
card4 = CHAR_ID >> 16

Pet ID
card1 = -256 (Hercules) or 256 (rAthena)
card2 = CHAR_ID & (( 1 << 16 ) -1)
card3 = CHAR_ID >> 16
card4 = 0


External Links:

Pet egg renewal fixing

Saturday, February 16, 2019

Hercules script engine is case-sensitive, rAthena isn't

I still remember when I was still Scripting Moderator in rAthena, there was this old bug report ...
...  after rAthena switched to IPB4 ... forum bug tracker down ....
anyway, it goes like this

Joseph open a bug report, claiming some official script doesn't execute the monster label properly
after some debate between the developers, I posted a script and prove them it is true
make one npc with the capital letter, and another one without capital letter -> OnDead - Ondead
click on 'asdf' npc, after kill the monster, the map-server.exe spam error
BrianL immediately add tag [Confirmed] and [Severity-Medium] to this bug report
within a few weeks, both Euphy and Joseph fix all the npc scripts in the emulator, and they mark it as [Solved]

..... the truth is, if you try the above script in latest rAthena, this bug still happen TODAY
this bug can't reproduce in Hercules because Hercules has case-sensitive script engine



Now let's talk about how crazy the script can be, if the script engine is not case-sensitive

other than npc header, 'prontera' and '1_F_MARIA',
script commands, labels, variables and constants are case-insensitive in rAthena
strings that enclosed in " double-quotation mark are not affected
means "this" "--ja--" "all" "All" still has to retain its format


This will throw duplicate label error in rAthena
in Hercules, click on the npc will display "2" properly

So, rAthena users, remember, don't simply use Onmobdead: label in your scripts
because official script already uses OnMobDead, OnMyMobDead, ... etc
... anyways, any official script already using that label name, Don't change into small letters in your scripts


... btw, SQL commands are still case-insensitive,
so me as Hercules user still uses small letters in *query_sql script commands


External Links:

Player Checker NPC
... once rAthena forum bug tracker up, will post that bug tracker ID here ...

Linux compiler error that never shown on Visual Studio

let's just admit Visual Studio sux ... ok ? right now, if you want to host a Private Ragnarok Online server, its just better to choose...