66 lines
2.8 KiB
Plaintext
66 lines
2.8 KiB
Plaintext
#include "x4_inc_functions"
|
|
void main()
|
|
{
|
|
object oPC = GetPCSpeaker();
|
|
object oModule = GetModule();
|
|
string sDatabase = GetLocalString(oModule, "DB");
|
|
|
|
string sHouse = GetLocalString(oPC, "HouseToSell");
|
|
|
|
int nFreeSlots;
|
|
int nAuthPosition;
|
|
string sAuth1 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_1");
|
|
string sAuth2 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_2");
|
|
string sAuth3 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_3");
|
|
string sAuth4 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_4");
|
|
string sAuth5 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_5");
|
|
string sAuth6 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_6");
|
|
string sAuth7 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_7");
|
|
string sAuth8 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_8");
|
|
string sAuth9 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_9");
|
|
string sAuth10 = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_10");
|
|
|
|
if (sAuth1 == "") {nFreeSlots = 10; nAuthPosition = 1;}
|
|
else if (sAuth2 == "") {nFreeSlots = 9; nAuthPosition = 2;}
|
|
else if (sAuth3 == "") {nFreeSlots = 8; nAuthPosition = 3;}
|
|
else if (sAuth4 == "") {nFreeSlots = 7; nAuthPosition = 4;}
|
|
else if (sAuth5 == "") {nFreeSlots = 6; nAuthPosition = 5;}
|
|
else if (sAuth6 == "") {nFreeSlots = 5; nAuthPosition = 6;}
|
|
else if (sAuth7 == "") {nFreeSlots = 4; nAuthPosition = 7;}
|
|
else if (sAuth8 == "") {nFreeSlots = 3; nAuthPosition = 8;}
|
|
else if (sAuth9 == "") {nFreeSlots = 2; nAuthPosition = 9;}
|
|
else if (sAuth10 == "") {nFreeSlots = 1; nAuthPosition = 10;}
|
|
else { FloatingTextStringOnCreature("The limit for the number of people authorized to access this estate has been reached! Operation cancelled!", oPC); return; }
|
|
|
|
object oMember = GetFirstFactionMember(oPC);
|
|
int nCount = 0;
|
|
//Firstly, count party members to see if there are enough slots to authorize all of them
|
|
while(GetIsObjectValid(oMember) == TRUE)
|
|
{
|
|
if(oMember != oPC)
|
|
{
|
|
nCount++;
|
|
}
|
|
oMember = GetNextFactionMember(oPC);
|
|
}
|
|
|
|
if(nFreeSlots <= nCount) { FloatingTextStringOnCreature("This estate does not have enough empty visitor slots to authorize everyone in your party! Operation cancelled!", oPC); return; }
|
|
|
|
//Now let's authorize everyone in the party.
|
|
oMember = GetFirstFactionMember(oPC);
|
|
string sAuthPosition;
|
|
while(GetIsObjectValid(oMember) == TRUE)
|
|
{
|
|
if(oMember != oPC)
|
|
{
|
|
sAuthPosition = IntToString(nAuthPosition);
|
|
SetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_"+sAuthPosition, CharacterDB(oMember));
|
|
nAuthPosition++;
|
|
}
|
|
oMember = GetNextFactionMember(oPC);
|
|
}
|
|
|
|
FloatingTextStringOnCreature("Party authorized successfully!", oPC);
|
|
|
|
}
|