Jump to content
  • 0
Eross

Revising rA script to Herc

Question

Guys, I need help on this one why its not working ? hmmm map name announcer .. im new here in herc thankyou

-	script	map_name	-1,{
OnInit:
setarray .Map$[0], // <mapname>,<Map Nick>,
			"prontera","Prontera City, The Imperial Capital",
			"morocc","Morroc Town, The Frontier",
			"geffen","Geffen, The City of Magic",
			"payon","Payon Town, The Upland Village",
			"alberta","Alberta, The Port City",
			"izlude","Izlude Town, The Satellite City of Prontera",
			"aldebaran","Al De Baran, The Gate to the New World",
			"xmas","Lutie, The City of Eternal Christmas",
			"comodo","Comodo, The City of Fun and Celebrations",
			"yuno","Juno, The Capital of the Commonwealth and Ancient Lore",
			"amatsu","Amatsu, The New Land Discovered",
			"gonryun","Gonryun, The Hermit Land",
			"umbala","Umbala, The Lost Land",
			"niflheim","Niffleheim, The Cold Land of Death",
			"louyang","Louyang, The Fortress of Dragon",
			"new_1-1","Training Ground",
			"sec_pri","Valhalla Prison",
			"jawaii","Jawaii, The Island of Love",
			"ayothaya","Ayothaya, The Land of Majectic Culture",
			"einbroch","Einbroch, The Steel City",
			"lighthalzen","Lighthalzen, The City of Scientific Myths",
			"einbech","Einbech, The Mining Town",
			"hugel","Hugel, Between the Icy Moutain and Chilly Blue Sea",
			"rachel","Rachel, The Capital City of Arunafeltz",
			"veins","Veins, The Canyon Village",
			"mid_camp","Rune Midgard Allied Forces Post";

for( set .i,0; .i < getarraysize( .Map$[ .i ] ) - 1; set .i,.i + 2 )
	setmapflag .Map$[.i],mf_loadevent;
end;

OnPCLoadMapEvent:
for( set .i,0; .i < getarraysize( .Map$[ .i ] ) - 1; set .i,.i + 2 )
	if( strcharinfo(3) == .Map$[.i] )
		announce ""+.Map$[.i+1]+"",bc_self;
end;
}

 

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

MF_LOADEVENT should be in uppercase. Also it might be faster to use a hash table than looping through the array (imagine having an array with 2k maps and doing a string comparison for each one of them every time someone enters the map)

-	script	map_name	-1,{

OnInit:
	.maps = htnew(); // create a new hash table

	// htput(.maps, "<map name>", "<map nick>");
	htput(.maps, "prontera", "Prontera City, The Imperial Capital");
	htput(.maps, "morocc", "Morroc Town, The Frontier");
	htput(.maps, "geffen", "Geffen, The City of Magic");
	htput(.maps, "payon", "Payon Town, The Upland Village");
	htput(.maps, "alberta", "Alberta, The Port City");
	htput(.maps, "izlude", "Izlude Town, The Satellite City of Prontera");
	htput(.maps, "aldebaran", "Al De Baran, The Gate to the New World");
	htput(.maps, "xmas", "Lutie, The City of Eternal Christmas");
	htput(.maps, "comodo", "Comodo, The City of Fun and Celebrations");
	htput(.maps, "yuno", "Juno, The Capital of the Commonwealth and Ancient Lore");
	htput(.maps, "amatsu", "Amatsu, The New Land Discovered");
	htput(.maps, "gonryun", "Gonryun, The Hermit Land");
	htput(.maps, "umbala", "Umbala, The Lost Land");
	htput(.maps, "niflheim", "Niffleheim, The Cold Land of Death");
	htput(.maps, "louyang", "Louyang, The Fortress of Dragon");
	htput(.maps, "new_1-1", "Training Ground");
	htput(.maps, "sec_pri", "Valhalla Prison");
	htput(.maps, "jawaii", "Jawaii, The Island of Love");
	htput(.maps, "ayothaya", "Ayothaya, The Land of Majectic Culture");
	htput(.maps, "einbroch", "Einbroch, The Steel City");
	htput(.maps, "lighthalzen", "Lighthalzen, The City of Scientific Myths");
	htput(.maps, "einbech", "Einbech, The Mining Town");
	htput(.maps, "hugel", "Hugel, Between the Icy Moutain and Chilly Blue Sea");
	htput(.maps, "rachel", "Rachel, The Capital City of Arunafeltz");
	htput(.maps, "veins", "Veins, The Canyon Village");
	htput(.maps, "mid_camp", "Rune Midgard Allied Forces Post");

	.@it = htiterator(.maps); // create an iterator to loop through the table
	for (.@map$ = htifirstkey(.@it); hticheck(.@it); .@map$ = htinextkey(.@it)) {
		// we are only interested in the key so no need to htget() here
		setmapflag(.@map$, MF_LOADEVENT);
	}
	htidelete(.@it); // we're done with the iterator: deallocate it
	end;

OnPCLoadMapEvent:
	// check whether it's in the hash table:
	if (.@nick$ = htget(.maps, strcharinfo(PC_MAP), "")) {
		announce(.@nick$, bc_self);
	}
	end;
}

 

Share this post


Link to post
Share on other sites
  • 0
9 hours ago, meko said:

MF_LOADEVENT should be in uppercase. Also it might be faster to use a hash table than looping through the array (imagine having an array with 2k maps and doing a string comparison for each one of them every time someone enters the map)

- script map_name -1,{ OnInit: .maps = htnew(); // create a new hash table // htput(.maps, "<map name>", "<map nick>"); htput(.maps, "prontera", "Prontera City, The Imperial Capital"); htput(.maps, "morocc", "Morroc Town, The Frontier"); htput(.maps, "geffen", "Geffen, The City of Magic"); htput(.maps, "payon", "Payon Town, The Upland Village"); htput(.maps, "alberta", "Alberta, The Port City"); htput(.maps, "izlude", "Izlude Town, The Satellite City of Prontera"); htput(.maps, "aldebaran", "Al De Baran, The Gate to the New World"); htput(.maps, "xmas", "Lutie, The City of Eternal Christmas"); htput(.maps, "comodo", "Comodo, The City of Fun and Celebrations"); htput(.maps, "yuno", "Juno, The Capital of the Commonwealth and Ancient Lore"); htput(.maps, "amatsu", "Amatsu, The New Land Discovered"); htput(.maps, "gonryun", "Gonryun, The Hermit Land"); htput(.maps, "umbala", "Umbala, The Lost Land"); htput(.maps, "niflheim", "Niffleheim, The Cold Land of Death"); htput(.maps, "louyang", "Louyang, The Fortress of Dragon"); htput(.maps, "new_1-1", "Training Ground"); htput(.maps, "sec_pri", "Valhalla Prison"); htput(.maps, "jawaii", "Jawaii, The Island of Love"); htput(.maps, "ayothaya", "Ayothaya, The Land of Majectic Culture"); htput(.maps, "einbroch", "Einbroch, The Steel City"); htput(.maps, "lighthalzen", "Lighthalzen, The City of Scientific Myths"); htput(.maps, "einbech", "Einbech, The Mining Town"); htput(.maps, "hugel", "Hugel, Between the Icy Moutain and Chilly Blue Sea"); htput(.maps, "rachel", "Rachel, The Capital City of Arunafeltz"); htput(.maps, "veins", "Veins, The Canyon Village"); htput(.maps, "mid_camp", "Rune Midgard Allied Forces Post"); .@it = htiterator(.maps); // create an iterator to loop through the table for (.@map$ = htifirstkey(.@it); hticheck(.@it); .@map$ = htinextkey(.@it)) { // we are only interested in the key so no need to htget() here setmapflag(.@map$, MF_LOADEVENT); } htidelete(.@it); // we're done with the iterator: deallocate it end; OnPCLoadMapEvent: // check whether it's in the hash table: if (.@nick$ = htget(.maps, strcharinfo(PC_MAP), "")) { announce(.@nick$, bc_self); } end; }


-	script	map_name	-1,{

OnInit:
	.maps = htnew(); // create a new hash table

	// htput(.maps, "<map name>", "<map nick>");
	htput(.maps, "prontera", "Prontera City, The Imperial Capital");
	htput(.maps, "morocc", "Morroc Town, The Frontier");
	htput(.maps, "geffen", "Geffen, The City of Magic");
	htput(.maps, "payon", "Payon Town, The Upland Village");
	htput(.maps, "alberta", "Alberta, The Port City");
	htput(.maps, "izlude", "Izlude Town, The Satellite City of Prontera");
	htput(.maps, "aldebaran", "Al De Baran, The Gate to the New World");
	htput(.maps, "xmas", "Lutie, The City of Eternal Christmas");
	htput(.maps, "comodo", "Comodo, The City of Fun and Celebrations");
	htput(.maps, "yuno", "Juno, The Capital of the Commonwealth and Ancient Lore");
	htput(.maps, "amatsu", "Amatsu, The New Land Discovered");
	htput(.maps, "gonryun", "Gonryun, The Hermit Land");
	htput(.maps, "umbala", "Umbala, The Lost Land");
	htput(.maps, "niflheim", "Niffleheim, The Cold Land of Death");
	htput(.maps, "louyang", "Louyang, The Fortress of Dragon");
	htput(.maps, "new_1-1", "Training Ground");
	htput(.maps, "sec_pri", "Valhalla Prison");
	htput(.maps, "jawaii", "Jawaii, The Island of Love");
	htput(.maps, "ayothaya", "Ayothaya, The Land of Majectic Culture");
	htput(.maps, "einbroch", "Einbroch, The Steel City");
	htput(.maps, "lighthalzen", "Lighthalzen, The City of Scientific Myths");
	htput(.maps, "einbech", "Einbech, The Mining Town");
	htput(.maps, "hugel", "Hugel, Between the Icy Moutain and Chilly Blue Sea");
	htput(.maps, "rachel", "Rachel, The Capital City of Arunafeltz");
	htput(.maps, "veins", "Veins, The Canyon Village");
	htput(.maps, "mid_camp", "Rune Midgard Allied Forces Post");

	.@it = htiterator(.maps); // create an iterator to loop through the table
	for (.@map$ = htifirstkey(.@it); hticheck(.@it); .@map$ = htinextkey(.@it)) {
		// we are only interested in the key so no need to htget() here
		setmapflag(.@map$, MF_LOADEVENT);
	}
	htidelete(.@it); // we're done with the iterator: deallocate it
	end;

OnPCLoadMapEvent:
	// check whether it's in the hash table:
	if (.@nick$ = htget(.maps, strcharinfo(PC_MAP), "")) {
		announce(.@nick$, bc_self);
	}
	end;
}

 

THANKYOU SIR !!!!

 

 

Edited:

 

Sir I think its not working ? or is there something wrong like typographical error ??

image.thumb.png.05865f84b07f663bdfb65beaf3c332ef.png

Edited by Origami
not working

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, Origami said:

THANKYOU SIR !!!!

 

 

Edited:

 

Sir I think its not working ? or is there something wrong like typographical error ??

image.thumb.png.05865f84b07f663bdfb65beaf3c332ef.png

It uses a plugin, you need to add the plugin he mentioned to make it work

Share this post


Link to post
Share on other sites
  • 0
2 minutes ago, Samuel said:

It uses a plugin, you need to add the plugin he mentioned to make it work

Ohh I get it ... Sorry for being such a noob hehe ... Gonna try It later when I come home ..I dont have compiler here at my office ,I think its an SRC file 

Share this post


Link to post
Share on other sites
  • 0

@Origami

  1. Put the hashtable.c file in Hercules/src/plugins
  2. Build the plugin
  3. Add "hashtable" to plugins_list in src/plugins.conf

Share this post


Link to post
Share on other sites
  • 0

hi... i already apply the plugins but i got this error on map-server

 

[Error]: script_rid2sd: fatal error ! player not attached!
[Debug]: Function: setmapflag (2 parameters):
[Debug]: Data: string value="prontera"
[Debug]: Data: variable name='MF_LOADEVENT' index=0
[Debug]: Source (NPC): map_name (invisible/not on a map)
[Warning]: script_get_val: cannot access player variable 'MF_LOADEVENT', defaulting to 0
 

Share this post


Link to post
Share on other sites
  • 0

idk what this constant mean. you got script somewhere, get this constant too or try use similar hercules constant

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.