[TF2][Help]Array or enum: which to use in my case?
Hi. I want to create a sort of sheet that keeps the players' info for my plugin.
My idea was to make 18 arrays for the 18 in-game users (Highlander mode) Each array has 4 integers: 1. userid 2. team (1 = red; 2= blu) 3. class (1 = scout; 2=soldier; etc...) 4. BOT (1 = no; 2 = yes) These variables will be refreshed everytime someone joins a class, leaves the match or does some specified command. This would let the plugin recognize the Bots with a specified class or team and would make a sort of filter for some commands of my choice. Do you think an array is a good thing for this case? Or should i use something else? Thank you, and sorry if this question is a blasphemy to SourcePawn language: i just got into it :oops: |
Re: [TF2][Help]Array or enum: which to use in my case?
Should be in the scripting section.
As for your question, array will be fine. Using an array with enum will make it easier to work with. Something like this. Code:
enum userData |
Re: [TF2][Help]Array or enum: which to use in my case?
Quote:
But how can i get the userid of a player who has, for example, value 1 on class, value 3 on team and value 2 on bot? And also, i don't understand very well the point of enum: what's the difference between array and enum in this case? |
Re: [TF2][Help]Array or enum: which to use in my case?
An enum is just a enumaration, which means it's assigning a string a number (Counting upwards from 0 as the word enumation implicates). In your exampel userid = 0, team = 1, class = 3 and so on. You don' need the enum. It just makes it easier to read the code.
The array is a way to store the informations (as you maybe know). So to access a clients userid you could write HTML Code:
userArray[client][userid]HTML Code:
userArray[client][0] |
Re: [TF2][Help]Array or enum: which to use in my case?
Quote:
Code:
public ScoutMenuHandler(Handle:menu, MenuAction:action, client, param2)If he is a bot then kick him using the id on the first column. As i said this is in highlander mode, so there will be only one per class. How can i do this? Should i use a while command? |
Re: [TF2][Help]Array or enum: which to use in my case?
I'm very confused at what your trying to accomplish.
This is a menu handler than clients can select, a bot can't select from a menu. So in this case every time someone selects from the menu the "bot" value will always be false (Player is never a bot). Are you trying to loop through every client and kick all the bots when client selects "1"? |
Re: [TF2][Help]Array or enum: which to use in my case?
I generally use an enum for array organization
enum { CLIENT_BITFLAGS CLIENT_LOADED CLIENT_TIMESTAMP CLIENT_ARRAY_SIZE }; new g_clientarray[MAXPLAYERS+1][CLIENT_ARRAY_SIZE] then do like public OnClientPostAdminCheck (client) { g_clientarray[client][CLIENT_LOADED] = 1 } |
| All times are GMT -4. The time now is 21:34. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.