forked from Sphereserver/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsphere_genericstone_functions.scp
217 lines (178 loc) · 6.9 KB
/
sphere_genericstone_functions.scp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//****************************************************************************
//SPHERE by : Menasoft ©1997-2007
//www.sphereserver.net
// All SPHERE script files and formats are copyright Menasoft & Partners.
// This file may be freely edited for personal use, but may not be distributed
// in whole or in part, in any format without express written permission from
// Menasoft & Partners. All donations and contributions
// become the property of Menasoft & Partners.
//****************************************************************************
// FILE LAST UPDATED: 14-March-2007
VERSION=0.56b
// ------------------------------------------------------
// ------------------------------------------------------
// ------------------------------------------------------
[FUNCTION TRANSFERSTONE]
src.targetf f_stonesys_transfer <args>
src.sysmessage Who do you wish to transfer the <f_stonesys_gettypename <args>> to?
[FUNCTION f_stonesys_transfer]
// args = stone uid
// argo = future owner
ref1 = <args>
local.typename = <f_stonesys_gettypename <ref1.uid>>
If (<argo.isitem>)
sysmessage You cannot transfer a <local.typename> to that.
elif (<argo.npc>)
sysmessage You cannot transfer a <local.typename> to an npc.
elif (<argo> == <ref1.masteruid>)
sysmessage You are already the master of <ref1.name>.
elif (<argo.memoryfindtype.memory_guild.link.uid> != <ref1.uid>) && (<argo.memoryfindtype.memory_town.link.uid> != <ref1.uid>)
sysmessage That player is not a member of the <local.typename>.
elif (!<argo.npc>)
ref1.masteruid = <argo.uid>
serv.log <name> (<uid>) transferred <sex his/her> <local.typename> (<ref1.name>) to <argo.name> (<argo.uid>)
sysmessage @038A You have transfered the <local.typename> to <argo.name>.
argo.sysmessage @038A You are now the master of <ref1.name>.
else
sysmessage You cannot transfer a <local.typename> to that.
endif
return 1
// ------------------------------------------------------
[FUNCTION f_stonesys_isnameused]
local.stoneuid=<argv[0]>
local.typeid=<qval (<uid.<local.stoneuid>.type> == t_stone_guild) ? 1 : 0>
local.name=<strsub <eval (strlen(<local.stoneuid>) + 1)> <eval strlen(<args>)> <args>>
local.index=0
local.return=0
local.totalstones=<qval (<local.typeid>) ? <serv.guildstones.count> : <serv.townstones.count>>
while (<local.index> < <local.totalstones>)
local.currentstoneuid=<qval (<local.typeid>) ? <serv.guildstones.<local.index>.uid> : <serv.townstones.<local.index>.uid>>
If (<local.currentstoneuid>)
If (!strcmpi(<uid.<local.currentstoneuid>.name>,<local.name>))
local.return=1
local.index=<local.totalstones> + 1
endif
endif
local.index += 1
endwhile
return <local.return>
// ------------------------------------------------------
[FUNCTION f_stonesys_isabbrevused]
local.stoneuid=<argv[0]>
local.typeid=<qval (<uid.<local.stoneuid>.type> == t_stone_guild) ? 1 : 0>
local.abbrev=<strsub <eval (strlen(<local.stoneuid>) + 1)> <eval strlen(<args>)> <args>>
local.index=0
local.return=0
local.totalstones=<qval (<local.typeid>) ? <serv.guildstones.count> : <serv.townstones.count>>
while (<local.index> < <local.totalstones>)
local.currentstoneuid=<qval (<local.typeid>) ? <serv.guildstones.<local.index>.uid> : <serv.townstones.<local.index>.uid>>
If (<local.currentstoneuid>)
If (!strcmpi(<uid.<local.currentstoneuid>.abbrev>,<local.abbrev>))
local.return=1
local.index=<local.totalstones> + 1
endif
endif
local.index += 1
endwhile
return <local.return>
// ------------------------------------------------------
[FUNCTION f_stonesys_sendsmsg]
ref1=<argv[0]>
local.message=<StrEat <args>>
If ((<ref1.type>!=t_stone_guild) && (<ref1.type>!=t_stone_town))
return 0
endif
If (!strlen(<local.message>))
return 0
endif
ref1.allmembers -1,sysmessage @68,0,3 <f_stonesys_gettypename <ref1.uid>> Message: <local.message>
// ------------------------------------------------------
[FUNCTION f_stonesys_speech_sendsmsg]
ref1=<argv[0]>
local.message=<StrEat <args>>
If ((<ref1.type>!=t_stone_guild) && (<ref1.type>!=t_stone_town))
return 0
endif
If (!strlen(<local.message>))
return 0
endif
ref1.allmembers -1,sysmessage @68,0,3 <f_stonesys_gettypename <ref1.uid>> Message[<name>]: <local.message>
// ------------------------------------------------------
[FUNCTION f_stonesys_determine_timeleft]
local.sec=<eval (<argn>-<serv.time>)/10>
If (<eval <local.sec>/86400>)
local.timeleft=<eval <local.sec>/86400> day(s)
elif (<eval <local.sec>/3600>)
local.timeleft=<eval <local.sec>/3600> hour(s)
elif (<eval <local.sec>/60>)
local.timeleft=<eval <local.sec>/60> min(s)
else
local.timeleft=<eval <local.sec>> second(s).
endif
return <local.timeleft>
// ------------------------------------------------------
[FUNCTION f_stonesys_gettypename]
ref1 = <argv[0]> // The stone
local.typename = <DEF.STONECONFIG_TYPENAME_UNK>
if ( !<ref1.isitem> )
elif ( <ref1.type> == t_stone_guild )
local.typename = <DEF.STONECONFIG_TYPENAME_GUILD>
elif ( <ref1.type> == t_stone_town )
local.typename = <DEF.STONECONFIG_TYPENAME_TOWN>
endif
return <local.typename>
// ------------------------------------------------------
[function f_stonesys_updatenoto]
ref1 = <argv[0]> // The stone
if (<ref1.IsChar>)
return 0
endif
If ((<ref1.type>!=t_stone_guild) && (<ref1.type>!=t_stone_town))
return 0
endif
for member 0 <eval <ref1.member.count> - 1>
ref10 = <ref1.member.<dlocal.member>>
if (<ref10.IsOnline>)
ref10.NotoUpdate
endif
endfor
// ------------------------------------------------------
// ------- Hardcoded functions called by Sphere -------
// ------------------------------------------------------
// Called to check If a stone is at war (If commented sphere will use its internal check)
// I -> Stone
// ARGO -> Stone to check against
// return -> 0: not an enemy
// 1: an enemy
// 2: use sphere internal check
[COMMENT FUNCTION f_stonesys_internal_isatwarwith]
If ((<type> == t_stone_guild) && (<argo.type> == t_stone_guild))
If (<align> && <argo.align>)
return (<align>!=<argo.align>)
endif
If (<guildfromuid.<argo.uid>.isenemy> && <argo.guildfromuid.<uid>.isenemy>)
return 1
endif
return 0
else If ((<type> == t_stone_town) && (<argo.type> == t_stone_town))
If (<guildfromuid.<argo.uid>.isenemy> && <argo.guildfromuid.<uid>.isenemy>)
return 1
endif
return 0
endif
return 2
// Called to check If a stone is allied (If commented sphere will use its internal check)
// I -> Stone
// ARGO -> Stone to check against
// return -> 0: not an ally
// 1: an ally
// 2: use sphere internal check
[COMMENT FUNCTION f_stonesys_internal_isalliedwith]
If ((<type> == t_stone_guild) && (<argo.type> == t_stone_guild))
If (<align> && <argo.align>)
return (<align>==<argo.align>)
endif
return 0
endif
return 2
[EOF]