Gang Teritories don't load ... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Gang Teritories don't load ... (
/showthread.php?tid=339916)
Gang Teritories don't load ... -
Edvin - 05.05.2012
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.
Re: Gang Teritories don't load ... -
JaTochNietDan - 05.05.2012
Change your loop to start at 0 instead of 1.
Re: Gang Teritories don't load ... -
Edvin - 05.05.2012
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.
Re: Gang Teritories don't load ... -
KingHual - 05.05.2012
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
Re: Gang Teritories don't load ... -
Edvin - 05.05.2012
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
Re: Gang Teritories don't load ... -
Edvin - 05.05.2012
EDIT: Solved
Just changed in ShowZonesFor in loop for ( new i ... ; to for ( new i = 1, and done!
Thanks !