The problem is that you can't trigger a NPC with this.name. You'd either have to use triggeraction with the NPC's x/y (not recommended) or create a weapon to handle it. My suggestion would be like:
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.setshape(1,32,64);
this.chat="Touch me to find out how many categories you have";
}
function onPlayerTouchsMe() {
// passing this npc as a parameter so it can store it so it knows
// which npc's chat to update
(@ "-MyCategoryWeapon").showCategories(this);
}
function onPlayerTouchsMe()
{
triggerServer("gui", this.name,null);
}
Script of weapon -MyCategoryWeapon, added to players on login
PHP Code:
function onActionServerSide(param) {
if(param=="getCategories") { // it's a good idea to always have a "command" parameter
temp.categories=player.getCategories();
triggerClient("gui", this.name, categories);
}
}
//#CLIENTSIDE
public function showCategories(npcToUpdate) {
this.npcToUpdate = npcToUpdate;
triggerServer("gui", this.name, "getCategories");
}
function onActionClientSide(categories) {
this.npcToUpdate.chat="Categories: " @ categories.size() @ " first category: " @ categories[][];
}
also, please use [PHP] and [/PHP] instead of [CODE].
Quote:
Originally Posted by WhiteDragon
If you call triggerserver or triggerclient with only one value, and that value is an array, it'll set params to that array rather than just the first variable. I think.
|
I'm 99% certain it doesn't happen.