new xx = AccInfo[playerid][PlayerFaction];
printf("Faction type: %i",FactionInfo[xx][FactionType]);
printf("Faction ID: %i",FactionInfo[xx][FactionID]);
/* test 2 with GetPlayerFactionID */
printf("Faction 2 ID: %i",GetPlayerFactionID(playerid));
printf("Faction 2 Type: %i",FactionInfo[GetPlayerFactionID(playerid)][FactionType]);
[19:38:00] Faction type: 3
[19:38:00] Faction ID: 3
[19:38:00] Faction 2 ID: 2
[19:38:00] Faction 2 Type: 3
[19:35:48] Faction ID: 1 || Faction Type: 1
[19:35:48] Faction ID: 2 || Faction Type: 2
[19:35:48] Faction ID: 3 || Faction Type: 3
GetPlayerFactionID(playerid) return AccInfo[playerid][PlayerFaction];
FactionInfo[GetPlayerFactionID(playerid)][FactionID]
GetPlayerFactionID(playerid) return FactionInfo[AccInfo[playerid][PlayerFaction]][FactionID];
public OnFactionLoad() {
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows) {
for(new i = 0; i < rows && i < MAX_FACTIONS; i++) {
new string[512];
cache_get_field_content(i, "Name", string);
strreplace(string, '_', ' ');
format(FactionInfo[i][FactionName], sizeof(string), string);
FactionInfo[i][FactionID] = cache_get_field_content_int(i,"ID");
FactionInfo[i][FactionEnterX] = cache_get_field_content_float(i,"EnterX");
FactionInfo[i][FactionEnterY] = cache_get_field_content_float(i,"EnterY");
FactionInfo[i][FactionEnterZ] = cache_get_field_content_float(i,"EnterZ");
FactionInfo[i][FactionExitX] = cache_get_field_content_float(i,"ExitX");
FactionInfo[i][FactionExitY] = cache_get_field_content_float(i,"ExitY");
FactionInfo[i][FactionExitZ] = cache_get_field_content_float(i,"ExitZ");
FactionInfo[i][FactionWorld] = cache_get_field_content_int(i,"World");
FactionInfo[i][FactionInterior] = cache_get_field_content_int(i,"Interior");
FactionInfo[i][FactionBank] = cache_get_field_content_int(i,"FactionBank");
FactionInfo[i][FactionDeagleAmmo] = cache_get_field_content_int(i,"DeagleAmmo");
FactionInfo[i][FactionM4Ammo] = cache_get_field_content_int(i,"M4Ammo");
FactionInfo[i][FactionShotgunAmmo] = cache_get_field_content_int(i,"ShotgunAmmo");
FactionInfo[i][FactionSniperAmmo] = cache_get_field_content_int(i,"SniperAmmo");
FactionInfo[i][FactionSmuggledCocaine] = cache_get_field_content_int(i,"CocaineSmuggledWhen");
FactionInfo[i][FactionType] = cache_get_field_content_int(i,"Type");
FactionInfo[i][FactionCocaineAmount] = cache_get_field_content_int(i,"CocaAmount");
FactionInfo[i][FactionPickup] = CreateDynamicPickup(1275, 1, cache_get_field_content_float(i,"EnterX"),cache_get_field_content_float(i,"EnterY"),cache_get_field_content_float(i,"EnterZ"));
format(string,sizeof(string),"Faction Name: %s\nFaction ID:%i",FactionInfo[i][FactionName],FactionInfo[i][FactionID]);
FactionInfo[i][FactionText] = CreateDynamic3DTextLabel(string, 0x008080FF, FactionInfo[i][FactionEnterX],FactionInfo[i][FactionEnterY],FactionInfo[i][FactionEnterZ], 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0);
printf("Faction ID: %i || Faction Type: %i",FactionInfo[i][FactionID],FactionInfo[i][FactionType]);
}
}
return true;
}
What should the type be from faction id 2?
How much is MAX_FACTIONS defined as? |
#define MAX_FACTIONS 10
Are you 100% percent sure? Check the table just incase.
Could you show me how you set someone in a faction? Could you please show the current function to get a player's faction |
GetPlayerFactionID(playerid) return AccInfo[playerid][PlayerFaction];
printf("Player faction: %i",AccInfo[playerid][PlayerFaction]);
CREATE TABLE `factions` (
`ID` INT(10) NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(128) NULL DEFAULT '0',
`EnterX` FLOAT NULL DEFAULT '0',
`EnterY` FLOAT NULL DEFAULT '0',
`EnterZ` FLOAT NULL DEFAULT '0',
`ExitX` FLOAT NULL DEFAULT '0',
`ExitY` FLOAT NULL DEFAULT '0',
`ExitZ` FLOAT NULL DEFAULT '0',
`Interior` INT(10) NULL DEFAULT '0',
`World` INT(10) NULL DEFAULT '0',
`Rank1` VARCHAR(24) NULL DEFAULT '0',
`Rank2` VARCHAR(24) NULL DEFAULT '0',
`Rank3` VARCHAR(24) NULL DEFAULT '0',
`Rank4` VARCHAR(24) NULL DEFAULT '0',
`Rank5` VARCHAR(24) NULL DEFAULT '0',
`Rank6` VARCHAR(24) NULL DEFAULT '0',
`Rank7` VARCHAR(24) NULL DEFAULT '0',
`Rank8` VARCHAR(24) NULL DEFAULT '0',
`Rank9` VARCHAR(24) NULL DEFAULT '0',
`Rank10` VARCHAR(24) NULL DEFAULT '0',
`FactionBank` INT(10) NULL DEFAULT '0',
`DeagleAmmo` INT(10) NULL DEFAULT '0',
`M4Ammo` INT(10) NULL DEFAULT '0',
`ShotgunAmmo` INT(10) NULL DEFAULT '0',
`SniperAmmo` INT(10) NULL DEFAULT '0',
`CocaineSmuggledWhen` INT(15) NULL DEFAULT '0',
`Type` INT(2) NULL DEFAULT '0',
`CocaAmount` INT(10) NULL DEFAULT '0',
PRIMARY KEY (`ID`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
;