Gang Teritories don't load ...
#1

Hi all .

I created a function what load automaticlly gang zone's from SQL database. Here is the code:
Код:
SetupTeritories( )
{
	new DBResult:r, pField[ 56 ];
	
	r = db_query( DBGangWar, "SELECT * FROM `teritories`" );

	for ( new i = 1; i < db_num_rows( r ); i++ )
	{
		db_get_field_assoc( r, "minx", pField, 56 );	Teritories[ i ][ minx ] 	= floatstr( pField );
		db_get_field_assoc( r, "miny", pField, 56 );	Teritories[ i ][ miny ] 	= floatstr( pField );
		db_get_field_assoc( r, "maxx", pField, 56 );	Teritories[ i ][ maxx ] 	= floatstr( pField );
		db_get_field_assoc( r, "maxy", pField, 56 );	Teritories[ i ][ maxy ] 	= floatstr( pField );
		db_get_field_assoc( r, "owner", pField, 56 );	Teritories[ i ][ owner ] 	= strval( pField );
		Teritories[ i ][ ID ] = GangZoneCreate( Teritories[ i ][ minx ], Teritories[ i ][ miny ], Teritories[ i ][ maxx ], Teritories[ i ][ maxy ] );
		db_next_row( r );
		printf( "%d teritories loaded", i );
	}
	db_free_result( r );
	return 1;
}
And here are 2 problems ...:
1. In database i have 2 gang zone's and when i start the console, it shows me just: "1 teritories loaded".
2. When i enter the game, don't show's me any teritory

PS. - Sorry for my bad english.
Reply
#2

Change your loop to start at 0 instead of 1.
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Change your loop to start at 0 instead of 1.
I make the change ... now load all teritories, but it don't shows me when i enter the game.
Reply
#4

Quote:
Originally Posted by Edvin
Посмотреть сообщение
I make the change ... now load all teritories, but it don't shows me when i enter the game.
Did you use GangZoneShowForPlayer?

https://sampwiki.blast.hk/wiki/GangZoneShowForPlayer
Reply
#5

I use this:
Код:
public OnPlayerConnect( playerid )
{
    ShowGangZones( playerid );
    return 1;
}
and ShowGangZones function:
Код:
ShowZonesFor( playerid )
	for ( new i; i < MAX_TERITORIES; i++ )
		GangZoneShowForPlayer( playerid, Teritories[ i ][ ID ], Gangs[ Teritories[ i ][ owner ] ][ color ] );
and, i forgot to say ... i use
#define MAX_TERITORIES
Reply
#6

EDIT: Solved Just changed in ShowZonesFor in loop for ( new i ... ; to for ( new i = 1, and done!

Thanks !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)