![]() |
2-dimensional arrays? do they exist?
Because I'm trying to make a Guild system, and it supports up to 100 guilds.
I'm using the array for the list of guilds: serverr.guild_list But how would I store the information of the guilds in serverr.guild_list? If there were 2-D arrays, it would work as simple as this: serverr.guild_list[5,1] = "Bob"; The 2nd index is 1, which represents the leader of the guild. The guild with the index of 5, will have the leader set to the player "Bob". The second index would be used to store all the information about the guilds. But then again, this would work too, wouldn't it? server.guild_list[5] = "Champions|Bob" for(i=0;i<100;i++) { temp.guild_list = serverr.guild_list[i].tokenize(|); if(#t(0) == "Champions") { for(i=0;i<10;i++) { this.view_guild_list[i] = #t(i) } } } |
Of course, Do this:
PHP Code:
To edit it, simply do: PHP Code:
|
That's a silly way to do it. I would have an array of your guilds, and then do something like:
this.( @ "guild_" @ guildname ).members = { "cbkbud", "cbk1994", "Stefan" }; |
Thanks. Exactly what I need. Meh now I have to change my guild manager script to 2d guild_list arrays though.
|
You can use twodimensional arrays like array[1][2], for your purpose it will be better to store them in separate variables, like
serverr.guilds = {"Samurai","Dustari"}; serverr.guild_Samurai = {me, you, etc}; Otherwise the whole array needs to be sent whenever you do a modification to a single guild. |
Quote:
Better to use a DB NPC. |
Quote:
Why would the amount of server flags slow down a server? What Stefan suggested is actually easier and more efficient in terms of editing variables(/guilds in this case).. |
Quote:
Plus, any idiot can make a script that says serverr.guilds = { "PIELOL" }; and erase everything. This would add atleast some protection (for example, you could use callstack, and have everything in a TStaticVar() which saves constantly backups). Just my opinion; and like I said, I was told that too many serverr vars can lag the server, like I said it may be false. I would think this to be more organized anyway, but I guess personal preference anyway. Also, you wouldn't really need to access this on clientside, as player.guild has to be set serverside (and, more secure). |
Well it depends on if you want to display the information on client-side, of course serverr. vars should be avoided if that is not required
|
How do I set an array's name to serverr.guilds_params[1] though?
params[1] is the Guild Name of the guild being added to the system. something like this wont work ? setarray(serverr.guild_params[1],10); |
I mean, I don't know, maybe I'm being silly, maybe it defeats the object, but I'd rather use the built in guild functionality?
PHP Code:
|
You won't know the total list of guilds using that, and you can't add guilds.
Can someone answer my question? |
Specifying addguildmember("Non existant guild", "Robin", "Robin); would allow me to set my nick to Robin (Non existant guild) it's not so hard.
And your question has already been answered. Quote:
Quote:
Quote:
Quote:
|
Nice. Thanks!
One question: Is there a way to delete an array? |
Quote:
|
EDIT: You beat me to it, Ian! If I'd have posted 30 seconds earlier ...
Quote:
Generally I do this: PHP Code:
|
PHP Code:
EDIT: Lol three answers at once ;) |
Haha, we all posted within the same 60 seconds or so.
I've had problems with array.clear() where it will clear things, but then when you add something back, everything will be back (including what you cleared). |
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 01:58 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.