Problem with CreateDynamicCP from database
#1

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_rowsx;
    
cache_get_row_countx_rows );
    for( new 
0x_rows++ )
    {
         
cache_get_value_inti"ID");
         
         
cache_get_value_floati"hqX"gTeamHq][ hqX ] );
        
cache_get_value_floati"hqY"gTeamHq][ hqY ] );
        
cache_get_value_floati"hqZ"gTeamHq][ hqZ ] );
        
gHQ] = CreateDynamicCPgTeamHq][ hqX ], gTeamHq][ hqY ], gTeamHq][ hqZ ], 1.00);
    }
    
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] = CreateDynamiCPxyzsizeworldinterior, .... );
gHq] = CreateDynamiCPxyzsizeworldinterior, .... );
gHq] = CreateDynamiCPxyzsizeworldinterior, .... );
.
.
.
gHq14 ] = CreateDynamiCPxyzsizeworldinterior, .... ); 
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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

I used printf and look at this:

PHP код:
Number of vehicle models23
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.
Reply
#5

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.
Reply
#6

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.
Reply
#7

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 gHq15 ];
#define MAX_HQS 15
enum gTeamHqEnum
{
     
Float:hqX,
     
Float:hqY,
     
Float:hqZ
}
new 
gTeamHqMAX_HQS ][ gTeamHqEnum ]; 
@Vince CrossUSAAF did this already in his code that he paste in his reply.
Reply
#8

Quote:
Originally Posted by FaLLenGirL
Посмотреть сообщение
Yes i tried your code. And the variables are this.
I don't see problems with them.

PHP код:
new gHq15 ];
#define MAX_HQS 15
enum gTeamHqEnum
{
     
Float:hqX,
     
Float:hqY,
     
Float:hqZ
}
new 
gTeamHqMAX_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.
Reply
#9

bump
Reply
#10

Why x
PHP код:
cache_get_value_floati"hqX"gTeamHq][ hqX ] ); 
and not i
PHP код:
cache_get_value_float0"hqX"gTeamHq][ hqX ] ); 
Reply
#11

I already tried that... it is not working.
Reply
#12

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:03CPPos11159423754 Pos2: -993160561 Pos31096891446
[03:31:03CPPos11150047928 Pos21143069458 Pos31116457429
[03:31:03CPPos1: -989263790 Pos2: -1019055309 Pos31111867392
[03:31:03CPPos1: -989614326 Pos21155050783 Pos31108166653
[03:31:03CPPos11147817640 Pos21155902259 Pos31091412007
[03:31:03CPPos11158361498 Pos2: -997515756 Pos31093476339
[03:31:03CPPos11156465213 Pos21144764891 Pos31104498708
[03:31:03CPPos11152777503 Pos21158306120 Pos31093689305
[03:31:03CPPos11152976896 Pos21148973548 Pos31093689305
[03:31:03CP10 Pos11157392957 Pos21152423363 Pos31093476339
[03:31:03CP11 Pos1: -987494154 Pos2: -996181033 Pos31088618601
[03:31:03CP12 Pos11143789961 Pos2: -995022111 Pos31096349752
[03:31:03CP13 Pos11155897999 Pos21152196116 Pos31096392743
[03:31:03CP14 Pos1: -993174897 Pos2: -992906445 Pos31088783018
[03:31:03CP15 Pos11153591214 Pos2: -992906445 Pos31099010041
[03:31:03Loaded 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.
Reply
#13

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:03CPPos11159423754 Pos2: -993160561 Pos31096891446
[03:31:03CPPos11150047928 Pos21143069458 Pos31116457429
[03:31:03CPPos1: -989263790 Pos2: -1019055309 Pos31111867392
[03:31:03CPPos1: -989614326 Pos21155050783 Pos31108166653
[03:31:03CPPos11147817640 Pos21155902259 Pos31091412007
[03:31:03CPPos11158361498 Pos2: -997515756 Pos31093476339
[03:31:03CPPos11156465213 Pos21144764891 Pos31104498708
[03:31:03CPPos11152777503 Pos21158306120 Pos31093689305
[03:31:03CPPos11152976896 Pos21148973548 Pos31093689305
[03:31:03CP10 Pos11157392957 Pos21152423363 Pos31093476339
[03:31:03CP11 Pos1: -987494154 Pos2: -996181033 Pos31088618601
[03:31:03CP12 Pos11143789961 Pos2: -995022111 Pos31096349752
[03:31:03CP13 Pos11155897999 Pos21152196116 Pos31096392743
[03:31:03CP14 Pos1: -993174897 Pos2: -992906445 Pos31088783018
[03:31:03CP15 Pos11153591214 Pos2: -992906445 Pos31099010041
[03:31:03Loaded 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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)