-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.ms
75 lines (65 loc) · 2.1 KB
/
util.ms
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
65
66
67
68
69
70
71
72
73
74
75
# gets the warps data called for : returns <array> : expects <warp_name>
proc(_get_warp, @n,
@name = _warp_sanitize(@n)
@info = get_value('entityreborn.chwarps.warps.'. @name)
return(@info)
)
# returns a storeable version of the warp
proc(_warp_sanitize, @n,
return(reg_replace('[^0-9a-zA-Z.]', '_', to_lower(@n)))
)
# gets all warps : returns <array>
proc(_get_warps,
@info = get_values('entityreborn.chwarps.warps')
return(@info)
)
# deletes warp from persistance : returns <null> : expects <warp_name>
proc(_delete_warp, @n,
@name = _warp_sanitize(@n)
clear_value('entityreborn.chwarps.warps.'. @name)
)
# stores the warp in persistance with data provided : returns <null> : expects <warp_name>, <warp_data>
proc(_set_warp, @n, @warp,
@name = _warp_sanitize(@n)
store_value('entityreborn.chwarps.warps.' .@name, @warp)
)
# checks if warp exists : returns <boolean> : expects <warp_name>
proc(_warp_exists, @name,
if(!has_value('entityreborn.chwarps.warps.'. _warp_sanitize(@name))) {
return(false)
} else {
return(true)
}
)
# checks the permissions for chwarps : returns <boolean> : expects <permission>, [<player>]
proc(_warp_perm, @perm, @p = player(),
@perm = 'chwarps.'. @perm
if(has_permission(@p, @perm) || pisop(@p)) {
return(true)
} else {
return(false)
}
)
# finds a warp name from an array of values (usally made with parse_args()) : returns <mixed> : expects <array_string>
proc(_search_warp, @arr,
@name = array()
foreach(@arr, @c) {
array_push(@name, @c)
if(_warp_exists(array_implode(@name, ' '))) {
@warp = array_implode(@name, ' ')
@id = array_index(@arr, @c)
return(array(@warp, @id))
}
}
return(array(false))
)
proc(_warp_config, @option,
@config = read('config.txt')
@lines = split('\n', @config)
foreach(@lines, @line,
@data = split(':', @line)
if(trim(@data[0]) == @option) {
return(trim(@data[1]))
}
)
)