Raised This Month: $32 Target: $400
 8% 

[ANY] City Bans


Post New Thread Reply   
 
Thread Tools Display Modes
ish12321
Veteran Member
Join Date: May 2016
Old 10-26-2016 , 05:28   Re: [ANY] City Bans
Reply With Quote #21

LoL
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-26-2016 , 11:07   Re: [ANY] City Bans
Reply With Quote #22

You could have long city name with unicode characters, though it probably doesn't happen often.
The GeoIP module uses 256k as buffer length to be large enough but 64 or 128 should be fine too I guess.
Not like it does matter for this plugin anyway.

@OP:

- new Array:gA_BannedCities = view_as<Array>(null);
Global variables are already initialized to 0 by default, you don't need to do that. You have also a define for that, Invalid_Array (0 as value).
- Don't create variables in a loop
- Don't hardcode the buffer max length, use charsmax() (macro for sizeof(var) - 1, and yeah in AMXX, you need to do -1, it's important)
- Instead of using an Array, you could use a Trie, and just checking the key with TrieKeyExists (less code, more efficient, even though it's probably trivial here).

What do you mean by "do not kick properly"?
__________________

Last edited by Arkshine; 10-26-2016 at 11:09.
Arkshine is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 10-26-2016 , 13:55   Re: [ANY] City Bans
Reply With Quote #23

Some sugestions:

- Make command like amx_reloadbannedcities (it will reload cities to the trie)
- Make something like whitelist and blacklist. For example i want to allow only players from my city. Then i must find all cities in the world and add them to the list? I don't this it would be a good idea.
- Also, make countries ban too.
siriusmd99 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-09-2017 , 10:33   Re: [ANY] City Bans
Reply With Quote #24

The ideea is nice, the implementation... well, not the best:
-a trie would suit better than an array here
-an invalid file pointer will be 0, not -1(INVALID_HANDLE)
-no need to check both file exists and the fFile
-the for does not make much sense.
-never create variables inside a loop
-what's your problem with "kick" command?

Unapproved since section needs to be cleaned. PM me after you make the changes.
__________________

Last edited by HamletEagle; 01-09-2017 at 10:33.
HamletEagle is offline
Reply


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 20:39.


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