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

Maps shedule


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
Thunderpussy
New Member
Join Date: Jan 2016
Old 01-23-2016 , 14:56   Maps shedule
Reply With Quote #1

Description:
"Maps shedule" is a small plugin that provides a list of maps genereated by shedule via fake native function. You can use it for map choosing, for example.

Usage:

Here is an example of configs/maps_shedule.ini:
Code:
; de_dust2 will be available 24 hours
[ 00:00:00 - 00:00:00 ] 
de_dust2

; Other maps only from 07:00 to 23:00
[ 07:00:00 - 23:00:00 ]
de_inferno
de_nuke
de_train
Code:
/* Returns a list of maps by shedule.
 * buff      - Map names buffer.
 * maps[]    - Positions of map names in the buffer.
 * &count    - Number of maps returned.
 * rand      - Return available maps in random order.
 * limit     - Limit number of maps to return.
 * tsec      - Time in seconds from midnight. Default value will return maps for current time. 
 * current   - Return current map. 
 * return    - Time before next update.*/
native mapsh_maps( buff[], maps[], &count = -1, rand = 0, limit = -1, tsec = -1, current = 0 );
Example usage:
Code:
#include <mapsh_shedule>
#define MAP(%1) buff[map[%1]]

new buff[256], map[8], count;

mapsh_maps(buff, map, count);
    
for( new i = 0; i < count; i++)
    log_amx( "%d. %s", i + 1, MAP(i) );
Output:
Code:
1. de_dust2
2. de_inferno
3. de_nuke
4. de_train
Commands:
amx_mapsh - prints the whole shedule to console.
amx_mapsh now - prints only currently available maps.
amx_mapsh at "%H:%M" - prints maps available at the given time. ( with quotes )



Changelog:
0.1.3 - Another bug fixed.
0.1.2 - Current map is not returned by default anymore.
0.1.1 - Refactoring, bugs fixed.
0.1.0 - Release
Attached Files
File Type: sma Get Plugin or Get Source (mapsshedule.sma - 424 views - 9.7 KB)
File Type: zip amxmodx.zip (4.9 KB, 106 views)

Last edited by Thunderpussy; 02-03-2016 at 10:43.
Thunderpussy is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-23-2016 , 15:50   Re: Maps shedule
Reply With Quote #2

Owwwwwwwww, nice idea but, this scared be bejesus of me:
Code:
    new t, t1, t2, p, p1, sz = 0;
So, why so much abbreviations / acronyms?

In Amx Mod X Pawn, you have until 31 characters to have fun given names to things.

Code:
//Build a group of maps for a given time. tarr(arr[TNUM], opt[2], tsec = 0) ... secfrommid() ... contains(arr[MAX_GROUP], sz, n){    ... new sh_curr[TNUM], sh_opt[2]; ... #define STRL 64 #define STRM 32 #define STRS 16 #define TNUM 16   //max groups allowed #define TASK_ID 15658734
So, when I call tar(...), I 'Build a group of maps for a given time.', uhum, I think I got it.

Then instead of write that commentary 'TNUM 16 //max groups allowed', give a more descriptive name like 'MAX_GROUPS_ALLOWED'. If the problem is because you do not want to write so much, use a IDE/Editor with auto complete as notepad++.

Hey, do not declare variables within for. Declare them out of it, unless they are static:
Code:
        for(new i = 0; i < maps; i++){         new map[STRM];    ...     for(new i = 0; i < opt[0]; i++){         new idx = tm[i];         new count = sh_time[idx][3] - sh_time[idx][2];         if(mmax != -1)             count = count < mmax ? count : mmax;                        new map_ids[MAX_GROUP], sz = 0;           for(j = 0; j < count; j++){             new n = j;                  if(rand){                             do{                          idx = tm[random_num(0, opt[0])];                     n = random_num(0, count);                    } while(contains(map_ids, sz, n + idx * 10000) >= 0);                 map_ids[sz++] = n + idx * 10000;             }             ArrayGetString(sh_maps, sh_time[idx][2] + n, buff, STRM);             new l = strlen(buff);
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 01-23-2016 at 16:10. Reason: spelling fix
addons_zz is offline
Thunderpussy
New Member
Join Date: Jan 2016
Old 01-23-2016 , 16:10   Re: Maps shedule
Reply With Quote #3

Thanks for reply! That is my first plugin and I know the code is kinda shitty.
Thunderpussy is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 01-23-2016 , 16:18   Re: Maps shedule
Reply With Quote #4

You're welcome. Read entirely each of these links I posted, they will be very helpful. To easy things, here is a list:
  1. How to abbreviate variable names [closed]
  2. Which abbreviations should we use for python variable names?
  3. [TUT] Code Styling & Good Programming Habits
  4. [FAQ] Whether to create variables inside/outside loops
  5. [TUT] The Use of Static Variables
Look also this code mime as example, it is very well named and documented:
__________________
Plugin: Sublime Text - ITE , Galileo
Multi-Mod: Manager / Plugin / Server

Support me on Patreon, Ko-fi, Liberapay or Open Collective

Last edited by addons_zz; 01-23-2016 at 18:23. Reason: better information
addons_zz is offline
Thunderpussy
New Member
Join Date: Jan 2016
Old 01-23-2016 , 16:35   Re: Maps shedule
Reply With Quote #5

Well, that'll take some time. Thanks again!
Thunderpussy is offline
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 01-24-2016 , 14:46   Re: Maps shedule
Reply With Quote #6

Thunderpussy

Nice Plugin

Btw , im not going use it because i dont need :p.

Last edited by JoaoVieira; 01-24-2016 at 14:47.
JoaoVieira is offline
Thunderpussy
New Member
Join Date: Jan 2016
Old 01-25-2016 , 10:40   Re: Maps shedule
Reply With Quote #7

Thanks!
maybe I will use it on my own server then... someday.

Last edited by Thunderpussy; 01-28-2016 at 10:36.
Thunderpussy 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 18:50.


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