File: CFGuildClearance.py

package info (click to toggle)
crossfire-maps 1.71.0-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 211,128 kB
  • sloc: python: 7,656; ansic: 2,143; perl: 744; sh: 73; makefile: 6
file content (64 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import Crossfire
import CFGuilds

import sys
import string
activator=Crossfire.WhoIsActivator()
activatorname=activator.Name
mymap = activator.Map
def find_player(object):
    while (object.Type != 1) : #1 is type 'Player'
        object = object.Above
        if not object:
            return 0
    return object




whoami=Crossfire.WhoAmI()

def CheckClearance(lParams,oActivator):

        ClearanceLevels={"Initiate":1,"Novice":2,"Guildman":3,"Journeyman":4,"Master":5,"GuildMaster":6}
        oGuild=CFGuilds.CFGuild(lParams[0])

        if oActivator.DungeonMaster==1:
                return True
        iClearanceLevel=ClearanceLevels.get(lParams[1],0)
        dGuildInfo=oGuild.info(oActivator.Name)

        if dGuildInfo==0:
            return False

        iClearanceApproved=ClearanceLevels.get(dGuildInfo['Rank'],0)
        if dGuildInfo["Status"]=='suspended':
                iClearanceApproved=0
                Crossfire.WhoIsActivator().Say("You are currently suspended from the guild.")
        elif dGuildInfo["Status"]=="probation":
                Crossfire.WhoIsActivator().Say("You are currently on probation.")
        if iClearanceLevel>iClearanceApproved:
                return False
        return True


if __name__=='__builtin__':

        texta = [ '' ]
        if Crossfire.WhatIsMessage():
            texta=string.split(Crossfire.WhatIsMessage())

        if (texta[0].upper() == 'ENTER'):
                Params=string.split(Crossfire.ScriptParameters())
                if CheckClearance(Params,activator):
                        Approved = "Access granted"
                else:
                       Approved = "Access denied"
                whoami.Say(Approved)


                if (Approved == 'Access granted'):
                        mymap.TriggerConnected(int(Params[2]),0,activator)

        else:
                whoami.Say('Say enter to request entry')