Jump to content

consumeitem doesn't work if the npc_id is 0 (example: bonus_script)

open

AnnieRuru
2014-01-27 06:04:28
http://rathena.org/board/topic/91800-item-script-that-allows-you-to-autopot/?p=241766

this is [member=euphy]'s script
http://rathena.org/board/pastebin/6y8ui2jsunt8

if uncomment the consumeitem script command, this error will pop up

--- nullpo info --------------------------------------------
d:
athena\src\map\script.c:17721: in func `unknown'
--- end nullpo info ----------------------------------------

responsible line is over here

nullpo_retr( 1, ( nd = (TBL_NPC *)map_id2bl( sd->npc_id ) ) );

when debug the sd->npc_id, it actually returns 0

however, when I apply this patch
[paste=6de12hy7sy72]
now his script will work

I have no idea if this patch will break anything ...
however, consumeitem script command shouldn't need to have any npc_id to begin with


EDIT:
forgot to say, change
bonus_script "{ callfunc "start_autopot"; }",3600,8,0,SI_INCHEALRATE;
into
bonus_script "{ callfunc \"start_autopot\"; }",3600,8,0,SI_INCHEALRATE;
lol ....

AnnieRuru
2014-01-27 06:26:25
I think I made a reply rather than editing main post

somehow, if I do

501,Red_potion, ...... ,{ mes "hello world"; close; },{},{}


prontera,155,184,5	script	kdhksjf	100,{
	sc_end sc_all;
	input .@id, 501, 32767;
	if ( !strcmp( getitemname(.@id), "null" ) )
		dispbottom "wrong id";
	else
		consumeitem .@id;
	end;
}

map-server crash for no matter what reason, patch or without patch

Euphy
2014-01-28 08:01:48
First part fixed in ad13f26.

'select' also crashes the map-server.

AnnieRuru
2014-01-28 08:59:33
hmm .. yeah just confirm all the run_script inside status.c, none of them have npc_id
https://github.com/rathena/rathena/blob/master/src/map/status.c#L3033
so, I think that fix was correct


for 2nd one, I think ..
maybe can use the trick like queuing multiple OnPCLoginEvent
so if the player already has sd->npc_id, queue them
example like here
https://github.com/rathena/rathena/blob/master/src/map/npc.c#L815
well, this one kinda tricky ... because how to detect that script has next; select; input; ... all these commands ?
×
×
  • Create New...