Raised This Month: $ Target: $400
 0% 

[TF2][Help]Array or enum: which to use in my case?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
cidra
Junior Member
Join Date: Jun 2016
Location: Italy
Old 06-20-2016 , 08:57   Re: [TF2][Help]Array or enum: which to use in my case?
Reply With Quote #3

Quote:
Originally Posted by Chaosxk View Post
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
{
	userid = 0,
	team,
	class,
	bot
};

int userArray[MAXPLAYERS + 1][userData];					//Creates an array for each client with enums

public void OnClientPostAdminCheck(int client)
{
	userArray[client][userid] = GetClientUserId(client);		//Gets the user id and set the array
	userArray[client][bot] = IsFakeClient(client) ? 2 : 1;		//If client is a bot set array to 2 otherwise 1
}
That was really helpful, thank you.
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?
cidra is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode