Problem with CreateDynamicCP from database -
FaLLenGirL - 30.04.2017
Hello there i made some
HQ's for Gangs but i want that checkpoints position in the front of the building where will be the HQ enter
to load from database. I made already everything and
in the console says: Loaded x headquarters (15 at me).
Here is the photo:
I'll paste here the function that loads from database the HQ's:
PHP код:
function LoadGangHq( )
{
new x_rows, x;
cache_get_row_count( x_rows );
for( new i = 0; i < x_rows; i ++ )
{
cache_get_value_int( i, "ID", x );
cache_get_value_float( i, "hqX", gTeamHq[ x ][ hqX ] );
cache_get_value_float( i, "hqY", gTeamHq[ x ][ hqY ] );
cache_get_value_float( i, "hqZ", gTeamHq[ x ][ hqZ ] );
gHQ[ x ] = CreateDynamicCP( gTeamHq[ x ][ hqX ], gTeamHq[ x ][ hqY ], gTeamHq[ x ][ hqZ ], 1.0, 0, 0 );
}
printf( "Loaded %d headquarters.", x_rows );
return 1;
}
Database `
headquarters` table:
Also in the past i made the same operation but not with MySQL i just made a variable, ex:
new gHq[ 16 ];
Than i created the Dynamic CP on the "
OnGameModeInit" public just like this:
PHP код:
gHq[ 0 ] = CreateDynamiCP( x, y, z, size, world, interior, .... );
gHq[ 1 ] = CreateDynamiCP( x, y, z, size, world, interior, .... );
gHq[ 2 ] = CreateDynamiCP( x, y, z, size, world, interior, .... );
.
.
.
gHq[ 14 ] = CreateDynamiCP( x, y, z, size, world, interior, .... );
and it worked. I wanted to change from this to MySQL because i like more to use
with MySQL almost for everything can u help me with that problem ? Thx.
Re: Problem with CreateDynamicCP from database -
CrossUSAAF - 30.04.2017
pawn Код:
function LoadGangHq( )
{
new x_rows;
cache_get_row_count( x_rows );
for( new i = 0; i < x_rows; i ++ )
{
cache_get_value_float( i, "hqX", gTeamHq[ i ][ hqX ] );
cache_get_value_float( i, "hqY", gTeamHq[ i ][ hqY ] );
cache_get_value_float( i, "hqZ", gTeamHq[ i ][ hqZ ] );
gHQ[ i ] = CreateDynamicCP( gTeamHq[ i ][ hqX ], gTeamHq[ i ][ hqY ], gTeamHq[ i ][ hqZ ], 1.0, 0, 0 );
}
printf( "Loaded %d headquarters.", x_rows );
return 1;
}
Please make sure that you do not exceed the size of your arrays.
Re: Problem with CreateDynamicCP from database -
FaLLenGirL - 30.04.2017
Quote:
Originally Posted by CrossUSAAF
pawn Код:
function LoadGangHq( ) { new x_rows; cache_get_row_count( x_rows ); for( new i = 0; i < x_rows; i ++ ) { cache_get_value_float( i, "hqX", gTeamHq[ i ][ hqX ] ); cache_get_value_float( i, "hqY", gTeamHq[ i ][ hqY ] ); cache_get_value_float( i, "hqZ", gTeamHq[ i ][ hqZ ] );
gHQ[ i ] = CreateDynamicCP( gTeamHq[ i ][ hqX ], gTeamHq[ i ][ hqY ], gTeamHq[ i ][ hqZ ], 1.0, 0, 0 ); } printf( "Loaded %d headquarters.", x_rows ); return 1; }
Please make sure that you do not exceed the size of your arrays.
|
It's creating just the first checkpoint not all the checkpoints.
Re: Problem with CreateDynamicCP from database -
FaLLenGirL - 30.04.2017
I used printf and look at this:
PHP код:
Number of vehicle models: 23
Loaded 16 gangs.
Loaded 44 teritories.
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
0 hqx
0 hqy
0 hqz
Loaded 15 headquarters.
"0" it is just the first checkpoint.
Re: Problem with CreateDynamicCP from database -
Vince - 30.04.2017
Have you replaced all instances of "x" with "i"? Because that was your original problem. You created a new empty variable "x" but never incremented its value.
Re: Problem with CreateDynamicCP from database -
CrossUSAAF - 30.04.2017
Quote:
Originally Posted by FaLLenGirL
It's creating just the first checkpoint not all the checkpoints.
|
I hope that you tried the code. It should work as you use a loop between 0 and 14 and you got 15 rows in total. Make sure you have declared arrays gTeamHq and gHQ correctly.
Re: Problem with CreateDynamicCP from database -
FaLLenGirL - 30.04.2017
Quote:
Originally Posted by CrossUSAAF
I hope that you tried the code. It should work as you use a loop between 0 and 14 and you got 15 rows in total. Make sure you have declared arrays gTeamHq and gHQ correctly.
|
Yes i tried your code. And the variables are this.
I don't see problems with them.
PHP код:
new gHq[ 15 ];
#define MAX_HQS 15
enum gTeamHqEnum
{
Float:hqX,
Float:hqY,
Float:hqZ
}
new gTeamHq[ MAX_HQS ][ gTeamHqEnum ];
@Vince CrossUSAAF did this already in his code that he paste in his reply.
Re: Problem with CreateDynamicCP from database -
CrossUSAAF - 30.04.2017
Quote:
Originally Posted by FaLLenGirL
Yes i tried your code. And the variables are this.
I don't see problems with them.
PHP код:
new gHq[ 15 ];
#define MAX_HQS 15
enum gTeamHqEnum
{
Float:hqX,
Float:hqY,
Float:hqZ
}
new gTeamHq[ MAX_HQS ][ gTeamHqEnum ];
@Vince CrossUSAAF did this already in his code that he paste in his reply.
|
Well... Take a look at CreateDynamicCP return values, if it does return some relevant information such as true or false.
Re: Problem with CreateDynamicCP from database -
FaLLenGirL - 30.04.2017
bump
Re: Problem with CreateDynamicCP from database -
AndreiWow - 01.05.2017
Why x
PHP код:
cache_get_value_float( i, "hqX", gTeamHq[ x ][ hqX ] );
and not i
PHP код:
cache_get_value_float( 0, "hqX", gTeamHq[ i ][ hqX ] );
Re: Problem with CreateDynamicCP from database -
FaLLenGirL - 01.05.2017
I already tried that... it is not working.
Re: Problem with CreateDynamicCP from database -
FaLLenGirL - 01.05.2017
Someone else ?
EDIT: Actually the code create all the checkpoints but when i spawn it shows just the first checkpoint, when i go to the second checkpoint it is not there, but in console shows that is created.
PHP код:
[03:31:03] CP: 1 | Pos1: 1159423754 | Pos2: -993160561 | Pos3: 1096891446
[03:31:03] CP: 2 | Pos1: 1150047928 | Pos2: 1143069458 | Pos3: 1116457429
[03:31:03] CP: 3 | Pos1: -989263790 | Pos2: -1019055309 | Pos3: 1111867392
[03:31:03] CP: 4 | Pos1: -989614326 | Pos2: 1155050783 | Pos3: 1108166653
[03:31:03] CP: 5 | Pos1: 1147817640 | Pos2: 1155902259 | Pos3: 1091412007
[03:31:03] CP: 6 | Pos1: 1158361498 | Pos2: -997515756 | Pos3: 1093476339
[03:31:03] CP: 7 | Pos1: 1156465213 | Pos2: 1144764891 | Pos3: 1104498708
[03:31:03] CP: 8 | Pos1: 1152777503 | Pos2: 1158306120 | Pos3: 1093689305
[03:31:03] CP: 9 | Pos1: 1152976896 | Pos2: 1148973548 | Pos3: 1093689305
[03:31:03] CP: 10 | Pos1: 1157392957 | Pos2: 1152423363 | Pos3: 1093476339
[03:31:03] CP: 11 | Pos1: -987494154 | Pos2: -996181033 | Pos3: 1088618601
[03:31:03] CP: 12 | Pos1: 1143789961 | Pos2: -995022111 | Pos3: 1096349752
[03:31:03] CP: 13 | Pos1: 1155897999 | Pos2: 1152196116 | Pos3: 1096392743
[03:31:03] CP: 14 | Pos1: -993174897 | Pos2: -992906445 | Pos3: 1088783018
[03:31:03] CP: 15 | Pos1: 1153591214 | Pos2: -992906445 | Pos3: 1099010041
[03:31:03] Loaded 15 headquarters.
I really don't know what's the problem. These checkpoints are all checkpoints that i create in my GM.
There are no more checkpoints in FS or others.
Re: Problem with CreateDynamicCP from database -
CrossUSAAF - 01.05.2017
Quote:
Originally Posted by FaLLenGirL
Someone else ?
EDIT: Actually the code create all the checkpoints but when i spawn it shows just the first checkpoint, when i go to the second checkpoint it is not there, but in console shows that is created.
PHP код:
[03:31:03] CP: 1 | Pos1: 1159423754 | Pos2: -993160561 | Pos3: 1096891446
[03:31:03] CP: 2 | Pos1: 1150047928 | Pos2: 1143069458 | Pos3: 1116457429
[03:31:03] CP: 3 | Pos1: -989263790 | Pos2: -1019055309 | Pos3: 1111867392
[03:31:03] CP: 4 | Pos1: -989614326 | Pos2: 1155050783 | Pos3: 1108166653
[03:31:03] CP: 5 | Pos1: 1147817640 | Pos2: 1155902259 | Pos3: 1091412007
[03:31:03] CP: 6 | Pos1: 1158361498 | Pos2: -997515756 | Pos3: 1093476339
[03:31:03] CP: 7 | Pos1: 1156465213 | Pos2: 1144764891 | Pos3: 1104498708
[03:31:03] CP: 8 | Pos1: 1152777503 | Pos2: 1158306120 | Pos3: 1093689305
[03:31:03] CP: 9 | Pos1: 1152976896 | Pos2: 1148973548 | Pos3: 1093689305
[03:31:03] CP: 10 | Pos1: 1157392957 | Pos2: 1152423363 | Pos3: 1093476339
[03:31:03] CP: 11 | Pos1: -987494154 | Pos2: -996181033 | Pos3: 1088618601
[03:31:03] CP: 12 | Pos1: 1143789961 | Pos2: -995022111 | Pos3: 1096349752
[03:31:03] CP: 13 | Pos1: 1155897999 | Pos2: 1152196116 | Pos3: 1096392743
[03:31:03] CP: 14 | Pos1: -993174897 | Pos2: -992906445 | Pos3: 1088783018
[03:31:03] CP: 15 | Pos1: 1153591214 | Pos2: -992906445 | Pos3: 1099010041
[03:31:03] Loaded 15 headquarters.
I really don't know what's the problem. These checkpoints are all checkpoints that i create in my GM.
There are no more checkpoints in FS or others.
|
Please read the return values of CreateDynamicCP native in a loop, e.g.
pawn Код:
printf("Return value: %d", gHQ[i]);
. Make sure your virtual world and interior is "0", when you are near your CPs, because you have overwritten the default parameters where the interior and virtual world does not matter.