SA-MP Forums Archive
Faction ID problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Faction ID problem (/showthread.php?tid=597837)



Faction ID problem - TwinkiDaBoss - 05.01.2016

Alright so the problem is simple.

It displays & reads from Type based on your own faction ID

For example my faction ID

PHP код:
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]); 
Now If I set my own faction ID to 2 it will and I pritn out this will happen

PHP код:
[19:38:00Faction type3
[19:38:00Faction ID3
[19:38:00Faction 2 ID2
[19:38:00Faction 2 Type
Altho OnFactionLoad works properly
PHP код:
[19:35:48Faction ID|| Faction Type1
[19:35:48Faction ID|| Faction Type2
[19:35:48Faction ID|| Faction Type
Get player faction
PHP код:
GetPlayerFactionID(playerid) return AccInfo[playerid][PlayerFaction]; 
EDIT: Problem is basicaly, with GetPlayerFactionID it reads the correct faction ID but shows Faction ID:3 type.


Re: Faction ID problem - Jefff - 05.01.2016

pawn Код:
FactionInfo[GetPlayerFactionID(playerid)][FactionID]
xd


Re: Faction ID problem - TwinkiDaBoss - 05.01.2016

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
FactionInfo[GetPlayerFactionID(playerid)][FactionID]
xd
Doesnt help mate

I tried using this too
PHP код:
GetPlayerFactionID(playerid) return FactionInfo[AccInfo[playerid][PlayerFaction]][FactionID]; 
But with that it displays faction ID: 3 and faction type 0 ...

PHP код:
public OnFactionLoad() {
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows) {
        for(new 
0rows && MAX_FACTIONSi++) {
            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(12751cache_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(string0x008080FFFactionInfo[i][FactionEnterX],FactionInfo[i][FactionEnterY],FactionInfo[i][FactionEnterZ], 5.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0);
            
printf("Faction ID: %i || Faction Type: %i",FactionInfo[i][FactionID],FactionInfo[i][FactionType]);
        }
    }
    return 
true;




Re: Faction ID problem - justinnater - 05.01.2016

What should the type be from faction id 2?

How much is MAX_FACTIONS defined as?


Re: Faction ID problem - TwinkiDaBoss - 05.01.2016

Quote:
Originally Posted by justinnater
Посмотреть сообщение
What should the type be from faction id 2?

How much is MAX_FACTIONS defined as?
Faction ID 2 type should be 2

PHP код:
#define MAX_FACTIONS 10 



Re: Faction ID problem - justinnater - 05.01.2016

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


Re: Faction ID problem - TwinkiDaBoss - 05.01.2016

Quote:
Originally Posted by justinnater
Посмотреть сообщение
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
1. Yeah 100% sure, even checked the table to see if its Int lmfao

2. GetPlayerFactionID
PHP код:
GetPlayerFactionID(playerid) return AccInfo[playerid][PlayerFaction]; 
3. Setting player faction is good, it even loads the correct faction ID.
Under OnPlayerLogin
PHP код:
printf("Player faction: %i",AccInfo[playerid][PlayerFaction]); 
It displays the correct FactionID as its set in the SQL


Re: Faction ID problem - justinnater - 05.01.2016

Can you provide us a image of your table?


Re: Faction ID problem - TwinkiDaBoss - 05.01.2016

Dont mind the non alligment, I had to crop pictures & put them together since the table is quite big
http://imgur.com/SrDz4Ui

Also if this makes any sense

PHP код:
CREATE TABLE `factions` (
    `
IDINT(10NOT NULL AUTO_INCREMENT,
    `
NameVARCHAR(128NULL DEFAULT '0',
    `
EnterXFLOAT NULL DEFAULT '0',
    `
EnterYFLOAT NULL DEFAULT '0',
    `
EnterZFLOAT NULL DEFAULT '0',
    `
ExitXFLOAT NULL DEFAULT '0',
    `
ExitYFLOAT NULL DEFAULT '0',
    `
ExitZFLOAT NULL DEFAULT '0',
    `
InteriorINT(10NULL DEFAULT '0',
    `
WorldINT(10NULL DEFAULT '0',
    `
Rank1VARCHAR(24NULL DEFAULT '0',
    `
Rank2VARCHAR(24NULL DEFAULT '0',
    `
Rank3VARCHAR(24NULL DEFAULT '0',
    `
Rank4VARCHAR(24NULL DEFAULT '0',
    `
Rank5VARCHAR(24NULL DEFAULT '0',
    `
Rank6VARCHAR(24NULL DEFAULT '0',
    `
Rank7VARCHAR(24NULL DEFAULT '0',
    `
Rank8VARCHAR(24NULL DEFAULT '0',
    `
Rank9VARCHAR(24NULL DEFAULT '0',
    `
Rank10VARCHAR(24NULL DEFAULT '0',
    `
FactionBankINT(10NULL DEFAULT '0',
    `
DeagleAmmoINT(10NULL DEFAULT '0',
    `
M4AmmoINT(10NULL DEFAULT '0',
    `
ShotgunAmmoINT(10NULL DEFAULT '0',
    `
SniperAmmoINT(10NULL DEFAULT '0',
    `
CocaineSmuggledWhenINT(15NULL DEFAULT '0',
    `
TypeINT(2NULL DEFAULT '0',
    `
CocaAmountINT(10NULL DEFAULT '0',
    
PRIMARY KEY (`ID`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB




Re: Faction ID problem - justinnater - 05.01.2016

is it only wrong for faction id 2 or also others?