Crossfire Server, Trunk
navar-midane_time.py
Go to the documentation of this file.
1 # Script for Midane's house.
2 #
3 # Copyright 2007 Nicolas Weeger
4 # Released as GPL
5 
6 import Crossfire
7 import CFDataFile
8 
9 who = Crossfire.WhoAmI()
10 
11 data = CFDataFile.CFData('midane', ['state'])
12 
13 if not 'on_map' in Crossfire.GetPrivateDictionary():
14  on_map = []
15  Crossfire.GetPrivateDictionary()['on_map'] = on_map
16 else:
17  on_map = Crossfire.GetPrivateDictionary()['on_map']
18 
19 def check_player(player):
20 
21  if player in on_map:
22  return
23 
24  on_map.append(player)
25 
26  if not data.exist(player.Name):
27  who.Say('Well, welcome, stranger.')
28  record = { '#' : player.Name,
29  'state' : 'seen' }
30  data.put_record(record)
31  return
32 
33  record = data.get_record(player.Name)
34  if record['state'] == 'seen':
35  who.Say('Welcome back, stranger.')
36  return
37 
38  who.Say('Welcome back, %s'%player.Name)
39 
40 def on_time():
41  for player in Crossfire.GetPlayers():
42  if player.Map == who.Map:
43  check_player(player)
44  elif on_map.count(player) != 0:
45  on_map.remove(player)
46 
47 on_time()
navar-midane_time.check_player
def check_player(player)
Definition: navar-midane_time.py:19
CFDataFile.CFData
Definition: CFDataFile.py:94
navar-midane_time.on_time
def on_time()
Definition: navar-midane_time.py:40