-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnew.sp
59 lines (56 loc) · 1.55 KB
/
new.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cstrike>
#include <sourcemod>
ArrayList g_aMapList;
ArrayList g_aMapTiers;
Database g_hDatabase;
public void OnPluginStart()
{
g_aMapList = new ArrayList( ByteCountToCells(PLATFORM_MAX_PATH) );
g_aMapTiers = new ArrayList();
OnMapStart();
RegConsoleCmd( "sm_lol", Command_lol, "Lets players Rock The Vote" );
}
public Action Command_lol( int client, int args )
{
char map[PLATFORM_MAX_PATH];
PrintToChatAll( "maplist_length=%i", g_aMapList.Length);
int length = g_aMapList.Length;
for( int i = 0; i < length; i++ )
{
g_aMapList.GetString( i, map, sizeof(map) );
PrintToChatAll( "%s",map );
}
}
public void OnMapStart()
{
LoadMapList();
}
void LoadMapList()
{
g_aMapList.Clear();
g_aMapTiers.Clear();
char buffer[512];
g_hDatabase = SQL_Connect( "shavit", true, buffer, sizeof(buffer) );
Format( buffer, sizeof(buffer), "SELECT * FROM `maptiers` ORDER BY `map`");
g_hDatabase.Query( LoadZonedMapsCallback, buffer, _, DBPrio_High );
}
public void LoadZonedMapsCallback( Database db, DBResultSet results, const char[] error, any data )
{
if( results == null )
{
LogError( "[SMC] - (LoadMapZonesCallback) - %s", error );
return;
}
char map[PLATFORM_MAX_PATH];
while( results.FetchRow() )
{
results.FetchString( 0, map, sizeof(map) );
// TODO: can this cause duplicate entries?
if( FindMap( map, map, sizeof(map) ) != FindMap_NotFound )
{
GetMapDisplayName( map, map, sizeof(map) );
g_aMapList.PushString( map );
g_aMapTiers.Push( results.FetchInt( 1 ) );
}
}
}