Jump to content
  • 0

[SOLVED] SetD/GetD - RID required? + dynamic shop problem - Close please


llchrisll

Question


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Hello, guys. I'm in need of help with the command setd/getd.

Short explanation what I wanna talk about.

Currently I'm scripting an PvP/GvG/MvP Arena with Ranking and Bounty feature (+Shops).

Before I added the bounty feature it kinda worked fine, to say that before hand :I.

Anyway also I'm working on my Global NPC Handler, which uses setd/getd partly.

Then I thought about saving some space and make an improvement.

So I'm tried to add the set/getd in the extra Conf NPC (need explanation? view my script)

This is what I exactly mean - a main problem of it...

-	script	<NPC_Name>_Conf	-1,{
end;

OnInit:
// Exchange the NPC 1, etc, with the NPC Name you want to disable
setarray .npc$[0],"NPC 1","NPC 2","NPC 3"; // etc, but don't put this npc
set .conf_npc$,strnpcinfo(1); // Here comes this NPC, will be unloaded only.
end;
}

Now the newer one:

setarray .npc$[0],"PvPGvGMain","Arena Master","Arena_ShopB","Arena_ShopC","Arena_ShopZ"; // etc, but don't put this npc
set .ext$,"main"; // In which variable is it saved? $@npc_main$ > "main" ... as example
set .conf_npc$,strnpcinfo(1); // Here comes this NPC, will be unloaded only.
OnNPCConf:
if(playerattached() == 1) dispbottom "Extension: "+.ext$;
for( set .@i,0; .@i < getarraysize(getd("$@npc_"+.ext$+"_alias$")); set .i,.i + 1) {
if(.conf_npc$ == getd("$@npc_"+.ext$+"_alias$["+.@i+"]")) {
	setd("$@npc_"+.ext$+"_a["+.@i+"]"),getarraysize(.npc$);
	setd("$@npc_"+.ext$+"_lo["+.@i+"]"),1;
	setd("$@npc_"+.ext$+"_ab["+.@i+"]"),1;
}
}
end;

(Don't mind the "OnNPCConf" - is used for bug fixxing atm.)

Here comes the problem - to get a hang of the problem I added this:

OnWhisperGlobal:
if(!getgmlevel()) end;
for( set .@i,0; .@i < getarraysize(getd("$@npc_"+.ext$+"_alias$")); set .@i,.@i + 1)
if(.conf_npc$ == getd("$@npc_"+.ext$+"_alias$["+.@i+"]")) {
	dispbottom "Index :"+.@i+" - NPC "+.conf_npc$+" and these "+getd("$@npc_"+.ext$+"_a["+.@i+"]")+"(Setd Array) / "+getarraysize(.npc$)+"(.npc$ Array) NPCs found:";
	for( set .@n,0; .@n < getarraysize(.npc$); set .@n,.@n + 1)
		dispbottom "- "+.npc$[.@n];
	dispbottom "Loaded: "+getd("$@npc_"+.ext$+"_lo["+.@i+"]") +"/Enabled: "+getd("$@npc_"+.ext$+"_ab["+.@i+"]");
}
if(select("- OnNPCConf:- Nevermind") == 2) close;
goto OnNPCConf;
end;
}

After the Map Server start, the "set/getd" shows "0", after I chose "OnNPCConf" and rewhisper him again, it shows the wanted result.

Here are some images:

pvparenahandler1.th.png

pvparenahandler2.th.png

So does this mean "setd/getd" requires an rid attached?

Something similiar happenes to my Bounty Shops - about attached rid I mean q.q:

	// Shop Items: PvP useful stuff D:, like Elements, Boxes and Food
// These will be used for all shops, but the prices depends on the Bounty Type you have set.
setarray .arena_sh[0],12020,12028,12029,12030,12031,12032,12033,12034,12108,12215,12216,12217,12218,12219,12075,12080,12085,12090,12095,12100,12114,12115,12116,12117,12118,12119,12120,12121,13543,13544,13545,13546,13547,14593;
if($@bty_type == 1) {
	npcshopdelitem "Arena_ShopZ",512;
	// Prices:
	// Default is a formula: ($@bty_z+(.@s*($@bty_z/10)))/2
	// Base Price = $@bty_z, "Multiplier" = + (Index ID* ($@bty_z/10))/2
	// Example: 5000 + (4(=Index of 12031)*(5000/10=500) > 7000/2 = 3500 Zeny for 12031
	// Note: If the formula results in a decimal number it will be degraded.

	// If you wanna use your own prices, comment the line with the formula and uncommented the line with the array below.
	// But remember to put the prices for all items.

	// setarray .arena_pr[0],100,100,0; // Etc

	// For the Shop itself, how the costs are set:
	set .arena_pay,1; // 1 = Formula, 2 = Per Array

	for ( set .@s,0; .@s < getarraysize(.arena_sh); set .@s,.@s + 1) {
		if(.arena_pay == 2) npcshopadditem "Arena_ShopZ",.arena_sh[.@s],.arena_pr[.@s];
		else {
			set .@arena_pr,($@bty_z+(.@s*($@bty_z/10)))/2; // Formula
			npcshopadditem "Arena_ShopZ",.arena_sh[.@s],.@arena_pr;
		}
	}

} else if($@bty_type == 2) {
	npcshopdelitem "Arena_ShopC",512;
	// Prices:
	// Default is a formula: ($@bty_c+.@s)/2
	// Base Price = $@bty_c, "Multiplier" = + Index ID/2
	// Example: 2 + 4(=Index of 12031) > 6/2 = 3 Cash Points for 12031
	// Note: If the formula results in a decimal number it will be degraded.

	// If you wanna use your own prices, comment the line with the formula and uncommented the line with the array below.
	// But remember to put the prices for all items.

	// setarray .arena_pr[0],100,100,0; // Etc

	// For the Shop itself, define the way how the costs are set:
	set .arena_pay,1; // 1 = Formula, 2 = Per Array

	for ( set .@s,0; .@s < getarraysize(.arena_sh); set .@s,.@s + 1) {
		if(.arena_pay == 2) npcshopadditem "Arena_ShopC",.arena_sh[.@s],.arena_pr[.@s];
		else {
			set .@arena_pr,($@bty_c+.@s)/2;	// Formula
			npcshopadditem "Arena_ShopC",.arena_sh[.@s],.@arena_pr;
		}
	}

} else if($@bty_type == 3) {
	npcshopdelitem "Arena_ShopB",512;
	// Prices:
	// Default is a formula: ($@bty_b+(.@s*10))/2
	// Base Price = $@bty_b, "Multiplier" = + (Index ID* 10)/2
	// Example: 5 + (4(=Index of 12031)*10) > 45/2 = 22 Bounty Points for 12031
	// Note: If the formula results in a decimal number it will be degraded.

	// If you wanna use your own prices, comment the line with the formula and uncommented the line with the array below.
	// But remember to put the prices for all items.

	// setarray .arena_pr[0],100,100,0; // Etc

	// For the Shop itself, how the costs are set:
	set .arena_pay,1; // 1 = Formula, 2 = Per Array

	for ( set .@s,0; .@s < getarraysize(.arena_sh); set .@s,.@s + 1)
	if(.arena_pay == 2) npcshopadditem "Arena_ShopB",.arena_sh[.@s],.arena_pr[.@s];
	else {
		set .@arena_pr,($@bty_b+(.@s*10))/2; // Formula
		npcshopadditem "Arena_ShopB",.arena_sh[.@s],.@arena_pr;
	}
}
if($@debug) announce "Arena Shop loaded.",bc_self;
if(!.@re_in) end;

Previously I had it execute "OnInit" but opening the shop, shows it doesnt work.

So I added also the "OnWhisperGlobal" to see what happened.

When I initate it via whisper the shops (item/prices) are being added like I wanted.

First I thought that the loading order would be the problem, but it wasn't (well I believed that, but to be sure)

so I exchanged/added an extra label to it and used "doevent" after I had loaded the required variables.

But didn't help either so far.

So can anybody help me with this? o.o

Regards,

Chris

Note: I'm using eAthena SVN 14434 SQL Trunk for my Test server, could that be the problem?

Edited by llchrisll
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

are you sure is .i not .@i ?

h4frS.png

and make sure this is working

getarraysize(getd("$@npc_"+.ext$+"_alias$"))

use this for seeing dates.

for(.... e(getarraysize(getd("$@npc_"+.ext$+"_alias$"))); ....)
.....
function e { debugnes ""+getarg(0); return getarg(0); }

Edited by goddameit
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Thanks for the post, goddameit..

It seems it was a part of "OnInit" mistake, what I'm still unsure about why it didn't work for exactly this script.

Because I tested the same on an another script I had to test with multiply NPCs and THERE it worked just fine.....

I was like "Wtf, why does it work for this script, but not for this one" >_<.

I'm gonna try another solution I had in mind before I had to go to work, so I couldn't respond immediatly.

Just to make sure, I learned that "setd/getd" doesn't require RID attached, so I (sry mods) I apologize for not testing it for other scripts first to proof that it wasn't just this script.

Still.... I'm wondering why, like mentioned, it didn't work for this script.

Well got to fight with my "Unload multiply NPCs > Map Server Crash" problem ^^.

Dunno why though.

About .@i and .i: In my first script I had .@i, then tried .i, still didn't work ,and forgot to rechange it back to .@i at those two positions when I posted this thread.

Best regards and thanks again,

Chris

~ Close please

Link to comment
Share on other sites

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.

×
×
  • Create New...