Party System & Party.txt

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am
Location: Germany

Party System & Party.txt

Post by Harley »

Greetings!
Guys, I need your help!
How can I read party.txt in data folder?
Is there some trick to read Leader or Member serial from it?
Example of my Party.txt

Code: Select all

#
#  PARTIES.TXT: Party Data
#

Party
{
	Leader	0x2
	Member	0x2
	Member	0x1d21
}

When I use DEBUG code:
print(" attacker.party : " + attacker.party ); // DEBUG
print(" attacker.party.candidates : " + attacker.party.candidates ); // DEBUG
print(" attacker.party.candidate_of_party : " + attacker.party.candidate_of_party ); // DEBUG
print(" attacker.party.leader : " + attacker.party.leader ); // DEBUG

var party_members := attacker.party.members;
print(" party_members : " + party_members ); // DEBUG
if( attacker.serial in party_members )
print(" attacker.serial : " + attacker.serial ); // DEBUG
endif

print(" attacker.party.members.member : " + attacker.party.members.member ); // DEBUG
It gives me that:

Code: Select all

attacker.party : <appobj:PartyRef>
attacker.party.candidates : {  }
attacker.party.candidate_of_party : <uninitialized object>
attacker.party.leader : <appobj:OfflineMobileRef>
party_members : { <appobj:OfflineMobileRef>, <appobj:OfflineMobileRef> }
attacker.party.members.member : <uninitialized object>
attacker.party.propnames() : {  }
I really don't know how to read that "appobj:OfflineMobileRef" and how can I get something I need from it.
I think your help will be very helpful to others.

With best regards!
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Party System & Party.txt

Post by CWO »

Attacker.party is a party object reference. https://docs.polserver.com/pol099/objref.php#Party

OfflineMobileRef is a character reference https://docs.polserver.com/pol099/objref.php#Character. You would use that object just like you would your attacker object. So to make this easier, you can do something like this: (bear with me, it's been years since I coded POL)

Code: Select all


var atkparty := attacker.party; // Let's set the attacker.party to its own variable
var partyleader := atkparty.leader; // Setting the character reference of the leader to its own variable

// Party Leader info
print("Attacker party leader name: " + partyleader.name); // attacker.party.leader.name
print("Attacker party leader serial: " + partyleader.serial); // attacker.party.leader.serial

// Party Member info
print("Attacker party members: ");
foreach character in atkparty.members   //members is an ARRAY of char references
  print(character.name + "(" + character.serial + ")");   // member name(serial)
endforeach

// Party Candidate info
if (atkparty.candidates.size() == 0)
  print("This party currently has no candidates.");
else
  print("Attacker party candidates: ");
  foreach character in atkparty.candidates //candidates is also an array char references
    print (character.name + "(" + character.serial + ")");  //candidate name(serial)
  endforeach
endif
Harley
Forum Regular
Posts: 360
Joined: Sat Mar 18, 2006 1:41 am
Location: Germany

Re: Party System & Party.txt

Post by Harley »

Thank you CWO, I'll try it!
Post Reply