![]() |
function not found in script
Hi
I'm trying to code an Inventory with GuiControl for my SQL-based Item system, but I'm running into a problem. I want to make a Combobox, that has different numbers of rows depending on how many categories of items the player has. NPC Code: that's my getCategories() function: NPC Code: That's what the F2-Log says. Quote:
I know the function works, as this NPC works: NPC Code://#Clientside I hope someone can help me. |
If you are calling the function from the clientside then it must be in the clientside part of the player class, and you probably should join the player class clientside to the player just to be certain. You can't call a serverside function in the player from the clientside.
|
"//#Clientside" should be all caps, not sure if it matters but it really ought to be.
getCategories looks like a serverside function so you have to trigger to the serverside part of the script, then trigger back to clientside. In order to do player.getCategories, it would have to be in a class joined to the player. You would still have to use it serverside. edit: skyld beat me to it |
Thanks for the quick response, you two :D
Quote:
getCategories looks like a serverside function so you have to trigger to the serverside part of the script, then trigger back to clientside. In order to do player.getCategories, it would have to be in a class joined to the player. You would still have to use it serverside. [/QUOTE] That's how I've done it. Quote:
Something like this would be nice... NPC Code: Or do I have to use triggeraction? I never used it, as I'm pretty new to Graalscript. In the wiki, triggeraction is declared as triggeraction(float x, float y, str eventname, params...) . Can I even use arrays for the params? |
You have to use triggers unfortunately.
See if this post helps: Quote:
Quote:
Sorry for the long posts but if you're interested in learning they should clear it up pretty well. |
Thanks, your post helped me understand triggering between the two sides.
It looks like I have to rethink the whole thing, as triggerClient and triggerServer can't handle arrays... Wow this is frustrating. |
Quote:
|
Quote:
|
Quote:
But I still don't see why this doesn't work: NPC Code: Maybe it's just too late. Thanks for the help, I'm heading to bed now. |
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.
|
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:
PHP Code:
Quote:
|
Quote:
|
Thanks for the help again cbk1994. :) I managed to get most of my Inventory done, as it is a weapon and I can use triggerserver and triggerclient without problems.
However I still can't access my player. itemfunctions from normal NPCs . Even though I copied your suggestion and only changed a few minor things, I get this error: Quote:
Here is the script of the NPC. PHP Code:
PHP Code:
|
In your first script you have a space into front of //#CLIENTSIDE which is causing the entire script to be interpreted on the server-side.
For the sake of the security of your server, please remove your addItem client-side function. That's basically a free pass for hackers to add whatever item they want and your system won't have a problem with it. |
In your NPC, you need to capitalize //#CLIENTSIDE.
|
| All times are GMT +2. The time now is 10:00 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.