Raised This Month: $12 Target: $400
 3% 

VIPs in a file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 02-07-2015 , 14:39   VIPs in a file
Reply With Quote #1

Hi there! How can I make a VIP plugin based on a file? I mean a file with the names, ips, steamids or something of the vips, so no specific admin flags would be needed.
Let's say it's "vips.txt", located in configs. How could I do that? I'm guessing nvault, but I have extremely poor knowledge in nvault and formatting text. So could you please explain me and maybe give me an example of how would that work?
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-07-2015 , 14:44   Re: VIPs in a file
Reply With Quote #2

There's a plugin on the forum that does this already, take a look at for reference.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-07-2015 , 15:53   Re: VIPs in a file
Reply With Quote #3

Simple, on server startup read the file, push all the identifiers(vip steamid) in a trie. When a player connect get his steamid and check if it exists into the trie(you can use that steamid as a key and simply use TrieSetCell(Trie, steamid, 0)). If true, set a bool to true, you will know he is vip.
__________________

Last edited by HamletEagle; 02-07-2015 at 15:54.
HamletEagle is offline
Old 02-07-2015, 15:58
fysiks
This message has been deleted by fysiks. Reason: ...
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 02-07-2015 , 15:59   Re: VIPs in a file
Reply With Quote #4

Thank you, guys!
__________________
~ Swiftly and with style ~

Last edited by EpicKiller; 02-07-2015 at 16:00.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2015 , 16:01   Re: VIPs in a file
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
Simple, on server startup read the file, push all the identifiers(vip steamid) in a trie. When a player connect get his steamid and check if it exists into the trie(you can use that steamid as a key and simply use TrieSetCell(Trie, steamid, 0)). If true, set a bool to true, you will know he is vip.
You should use TrieKeyExists() to check if the person is in the trie and thus has VIP status. Use TrieSetCell(trie, steamid, 1) when reading the file (the value here doesn't matter since it's not being used).

The way you stated it was confusing.
__________________
fysiks is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 02-07-2015 , 17:02   Re: VIPs in a file
Reply With Quote #6

Why you always want to use tries ? Why u dont want to using default arrays ? (new asd[33][33]) I always hearing that tries, and dynamic arrays are bettter. (faster? how faster? They are using includes, and i think that this have to take more time than using build-in compiler arrays) [Sorry for english]
grs4 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2015 , 17:45   Re: VIPs in a file
Reply With Quote #7

Quote:
Originally Posted by grs4 View Post
Why you always want to use tries ? Why u dont want to using default arrays ? (new asd[33][33]) I always hearing that tries, and dynamic arrays are bettter. (faster? how faster? They are using includes, and i think that this have to take more time than using build-in compiler arrays) [Sorry for english]
Tries are much faster than arrays when you simply want to check if a string is in a list. Arrays are faster than dynamic arrays but dynamic arrays are dynamically sizable (unlike traditional arrays). Without using a Trie, you would have to use a loop to loop through every single string in the array using the equal[i]() command. This is very time consuming, exponentially so when you get larger and larger lists or you need to do it often.

So, using Tries is a solution to both the size and speed issues. Lists of SteamIDs for this type of purpose should be in a Trie.

Read the post by JoaquimAndrade in the Code Snippets/Tutorials forum regarding Tries.
__________________

Last edited by fysiks; 02-07-2015 at 17:46.
fysiks is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 02-07-2015 , 18:05   Re: VIPs in a file
Reply With Quote #8

Thanks for simple answer for my question ! Of course I readed many topic about tries, and it is dettering(?[deters]) me him build. Though my 3,5 years experience of PAWN i never used TRIES or Dynamic Arrays. i was always using arrays, because the code was clean for read. I'm having my Tower Defense Mod, where (o think) better will be use tries/dynamic arrays, but my knowledge of english, and advance vaculbary of your tutorials blocks me for understand tries -> keys -> values, cellsize .. omg... [sorry for english] Thanks again for answerm and to the topic: I think that @HamletEagle put to you the most better solution.
grs4 is offline
Reply



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 10:09.


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