Revising rA script to Herc

Eross

New member
Messages
12
Points
0
Location
Philippines
Emulator
Guys, I need help on this one why its not working ? hmmm map name announcer .. im new here in herc thankyou

Code:
-	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;
}
 
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)

Code:
-	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;
}
 
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.png

 
Last edited by a moderator:
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 

 
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
 

 
it said what constant MF_LOADEVENT not defined

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

 
Back
Top