52 lines
2.0 KiB
Plaintext
52 lines
2.0 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 nPosition = GetLocalInt(oPC, "HouseAuthPosition");
|
|
|
|
//Clear the list if the owner chose the last dialogue option
|
|
if (nPosition == 11)
|
|
{
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_1");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_2");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_3");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_4");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_5");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_6");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_7");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_8");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_9");
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_10");
|
|
return;
|
|
}
|
|
|
|
//Otherwise delete only a single entry
|
|
string sPosition = IntToString(nPosition);
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_"+sPosition);
|
|
|
|
//Check if higher-numbered entries exist in order to potentially move them
|
|
int nNextPosition = nPosition+1;
|
|
string sNextPosition = IntToString(nNextPosition);
|
|
|
|
//As long as an entry numbered higher by 1 exists, move it down (to fill the gap created by variable deletion)
|
|
string sNextEntry;
|
|
sNextEntry = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_"+sNextPosition);
|
|
|
|
while (sNextEntry != "")
|
|
{
|
|
SetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_"+sPosition, sNextEntry);
|
|
DeleteCampaignVariable(sDatabase, "H_"+sHouse+"_AUTH_"+sNextPosition);
|
|
nPosition++;
|
|
nNextPosition++;
|
|
if (nNextPosition == 11) return;
|
|
sPosition = IntToString(nPosition);
|
|
sNextPosition = IntToString(nNextPosition);
|
|
sNextEntry = GetCampaignString(sDatabase, "H_"+sHouse+"_AUTH_"+sNextPosition);
|
|
}
|
|
|
|
}
|