![]() |
Bind a variable to a function?
Ok, after my lack of success in the last thread I'm attempting to build an associative array manually. (Hopefully with more functionaility too, like being able to iterate through it.)
What I want to achieve is standard in OOP, but i'm not sure whether it's possible in GS. The code will hopefully make more sense: PHP Code:
If this is possible it'd really help me with a lot of scripts. Thanks. |
You can do things like this:
PHP Code:
|
ah. Thanks.
Joined classes dont seem to get updated when I press apply. I just added a function to one and it's not recongnised. The ones I added originally are. Also, if I change something it doesn't seem to update. |
You need to recreate the TStaticVar. Call a destroy() to it in some script, then remake it. Should work.
|
Where should destroy go?
Heres what I have: PHP Code:
PHP Code:
PHP Code:
I added arr.destroy(); to my NPC but it still never updates. Is it because both the weapon NPC and the class npc have //#CLIENTSIDE ? UPDATE: If I copy and paste the entire remove function and call it remove2, then call arr.remove2() it will execute as expected. remove() still executes as if it were never changed since the first time I called it even though the code is identical to remove2(). Any ideas? This is a bit strange and highly annoying because I don't know whether the script is working or not because I cant tell whether it's using the latest version of the function. |
Fixed. I stopped using the function name remove() and all is fine. Is it a reserved function name or used for something else?
Anyway, it all seems to be working fine now. Heres my associatve array class. Feel free to use it. PHP Code:
PHP Code:
|
You can also do:
PHP Code:
|
| All times are GMT +2. The time now is 12:18 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.