[MySQL] Faction Problem [SOLVED]
#1

Hello... Again :P

I've been testing my faction system. Basically at the moment I'm trying to get it so that when you are part of Faction ID 1 you spawn at the location of the faction and so on..

But there is a bit of a problem:

pawn Код:
public OnPlayerSpawn(playerid)
{
  if(PlayerStatistics[ playerid ][ pFaction ] != 255)
    {
      new idx;
        SetPlayerPos(playerid,DynamicFactions[ idx ][ fX ],DynamicFactions[ idx ][ fY ],DynamicFactions[ idx ][ fZ ]);
        return 1;
    }
    else
    {
        SetPlayerPos(playerid,1743.7150,-1862.1627,13.5766);
        return 1;
    }
}
This is my spawn function and as you see if your faction ID is set to 255 you spawn at the civilian location but if it isn't you spawn at the faction location.
Well the problem is I have 2 factions. 1 is DUDE! and 2 is LSPD. I setup the LSPD faction (2) but when I login it loads up faction 1.

LoadFaction()
pawn Код:
public LoadFaction()
{
  new DataString[ 128 ], Query[ 128 ], idx;

    format( Query, sizeof( Query ), "SELECT * FROM `Factions`");
    mysql_query( Query );
    mysql_store_result();

    while( mysql_fetch_row_data() )
    {
        mysql_fetch_field( "FactionID", DataString );
        DynamicFactions[ idx ][ FactionID ] = strval( DataString );

        mysql_fetch_field( "FactionName", DataString );
        DynamicFactions[ idx ][ FactionName ] = strval( DataString );

        mysql_fetch_field( "FactionX", DataString );
        DynamicFactions[ idx ][ fX ] = strval( DataString );

        mysql_fetch_field( "FactionY", DataString );
        DynamicFactions[ idx ][ fY ] = strval( DataString );

        mysql_fetch_field( "FactionZ", DataString );
        DynamicFactions[ idx ][ fZ ] = strval( DataString );

        mysql_fetch_field( "FactionMaterials", DataString );
        DynamicFactions[ idx ][ FactionMaterials ] = strval( DataString );

        mysql_fetch_field( "FactionDrugs", DataString );
        DynamicFactions[ idx ][ FactionDrugs ] = strval( DataString );

        mysql_fetch_field( "FactionBank", DataString );
        DynamicFactions[ idx ][ FactionBank ] = strval( DataString );

        mysql_fetch_field( "FactionType", DataString );
        DynamicFactions[ idx ][ FactionType ] = strval( DataString );
       
        printf("[Factions] Name: %s ID: %d",DynamicFactions[ idx ][ FactionName ],DynamicFactions[ idx ][ FactionID ]);

        idx++;
    }

    mysql_free_result();

    return 1;
}
Anyone?
Reply
#2

[SOLVED]

I fixed this by changing:
pawn Код:
SetPlayerPos(playerid,DynamicFactions[ idx ][ fX ],DynamicFactions[ idx ][ fY ],DynamicFactions[ idx ][ fZ ]);
To:
pawn Код:
SetPlayerPos(playerid,DynamicFactions[PlayerStatistics[playerid][pFaction]][fX],DynamicFactions[PlayerStatistics[playerid][pFaction]][fY],DynamicFactions[PlayerStatistics[playerid][pFaction]][fZ]);
The reason it wasn't working was becasue I hadn't told it what faction I was belonging to.. :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)