Thanks for the advice Chompy. I was actually thinking to myself in Maths today: "Crap, I forgot to add functionality to update the list! Damn...", lol.
Anyway, enjoy!
EDIT: Holy crap, I didn't expect the percentage symbols to work!
Instructions & Code
Add this to Control-NPC - if event exists, just copy the function call and do whatever you wish.
PHP Code:
function onRCChat() {
if ( params[0] == "updateweaponlist" ) ( @ globalWeaponTrigger ).updateWeaponList();
}
This is the updated code:
PHP Code:
function onCreated() {
updateWeaponList();
globalTriggerName = this.name;
}
public function triggerAll( eventName, parameters ) {
for ( temp.weapon: this.weapons ) {
( @ temp.weapon ).trigger( eventName, parameters );
}
}
public function updateWeaponList() {
this.weapons = NULL;
temp.charMap = {
{"%045", "-"},
{"%042", "*"},
{"%047", "/"},
{"%032", " "}
};
temp.weaponsFolder.loadfolder( "weapons/*.txt", 1 );
for (temp.weapon: temp.weaponsFolder) {
removeescapesfromfilename( temp.weapon );
this.weapons.add( temp.weapon.substring( 6, temp.weapon.length() - 4 ) );
}
echo( this.name @ ": weapon list updated." );
}