Help with with multi dimensional arrays.
#1

Hello everyone!

I'm making a bridge collapse and repair system upon bombing. I have stored the coordinates and stuff in the enumerator arrays, planning to move them in the database after I successfully make it working. But my problem here right now is, the bridge has 2 objects and both has their own coordinates for fixed and damaged ones.

PHP код:
#define MAX_BRIDGES 2
enum E_BRIDGE_DATA {
    
b_ID,
    
Float:b_Fixed_X,
    
Float:b_Fixed_Y,
    
Float:b_Fixed_Z,
    
Float:b_Fixed_RX,
    
Float:b_Fixed_RY,
    
Float:b_Fixed_RZ,
    
Float:b_Damaged_X,
    
Float:b_Damaged_Y,
    
Float:b_Damaged_Z,
    
Float:b_Damaged_RX,
    
Float:b_Damaged_RY,
    
Float:b_Damaged_RZ,
    
b_Objects[2]
}
new 
g_Bridge[MAX_BRIDGES][E_BRIDGE_DATA] = {
    {
16610, -1024.410892710.7136248.40410359.985410.0, -173.35580, -1024.410892710.7136243.02410359.985415.0, -173.35580},
     {
16037, -1143.704222696.8532748.73220359.985410.0, -173.37590, -1143.704222696.8532743.45050359.98541, -5.0, -173.37590}
}; 
As you can see the single bridge has two IDs in this one.

This works when I loop through the bridge IDs and set the objects' position defined in the array like
PHP код:
for (new 0MAX_BRIDGESi++) {
    
SetDynamicObjectPos(g_Bridge[i][b_Objects][i],
        
g_Bridge[i][b_Damaged_X],
        
g_Bridge[i][b_Damaged_Y],
        
g_Bridge[i][b_Damaged_Z]);
    
SetDynamicObjectRot(g_Bridge[i][b_Objects][i],
        
g_Bridge[i][b_Damaged_RX],
        
g_Bridge[i][b_Damaged_RY],
        
g_Bridge[i][b_Damaged_RZ]);

I am trying to include both objects and their coordinates in one bridge ID so that I could just use bridge ID 0 and both the objects would change their position, but I am out of idea on how to do it.

Sorry for the poor explanation but I hope you can understand what I mean.
Reply
#2

Are there 2 bridge objects (and each bridge has fixed and damaged one)?
And what is b_Objects[2] for?
Can you show the code line where you used CreateDynamicObject()?
Reply
#3

Quote:
Originally Posted by RoboN1X
Посмотреть сообщение
Are there 2 bridge objects (and each bridge has fixed and damaged one)?
And what is b_Objects[2] for?
Can you show the code line where you used CreateDynamicObject()?
The b_Objects[2] holds the object IDs that are being created. And yes, two objects form a single bridge. When the bridge is collapsed, those two objects changes their positions.

PHP код:
for (new 0MAX_BRIDGESi++) {
    
g_Bridge[i][b_Objects][i] = CreateDynamicObject(g_Bridge[i][b_ID],
        
g_Bridge[i][b_Fixed_X],
        
g_Bridge[i][b_Fixed_Y],
        
g_Bridge[i][b_Fixed_Z],
        
g_Bridge[i][b_Fixed_RX],
        
g_Bridge[i][b_Fixed_RY],
        
g_Bridge[i][b_Fixed_RZ]);

I will have to create few more bridges like this so, bridge IDs 1, 2, 3 or 4 should also have two objects in each and I don't know how to store the object ID and their coordinates there.
Reply
#4

/Bump

Still looking for the solution.

Edit: Got it working, nevermind.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)