· 10 years ago · Sep 12, 2016, 01:32 AM
1/*
2UPDATED: 22.10.2014
3
4Vice City Multiplayer 0.4 Blank Server (by Seby) for 32bit Windows.
5You can use it to script your own server. Here you can find all events developed.
6VC:MP 0.4 rocks ! :D
7QuerySQL(clandb, "create teable if not exists clans (clan text, tags text)");
8VC:MP Official: www.vc-mp.org
9Forum: forum.vc-mp.org
10Wiki: wiki.vc-mp.org
11*/
12
13// =========================================== S E R V E R E V E N T S ==============================================
14
15/*
16function onServerStart()
17{
18}
19/exec Message(""+split(GetSQLColumnData(QuerySQL(clandb, "select * from clans"),1), " ")[0]+"")
20function onServerStop()
21{
22}
23*/
24
25function onScriptLoad()
26{
27clandb <- ConnectSQL("clans.sqli");
28QuerySQL(clandb, "create table if not exists clans (clan text, tags text)");
29clanst <- {};
30local tag;
31local clanq = QuerySQL(clandb, "select * from clans");
32while (GetSQLNextRow(clanq))
33{
34tag = split(GetSQLColumnData(clanq,1), " ");
35if (tag[0] != null) clanst[tag[0]] <- GetSQLColumnData(clanq,0);
36if (tag[1] != null) clanst[tag[1]] <- GetSQLColumnData(clanq,0);
37if (tag[2] != null) clanst[tag[2]] <- GetSQLColumnData(clanq,0);
38}
39}
40// GetTag Function
41function GetTag( string )
42{
43 local
44 Tag = FindClan( string ).toupper();
45if ( Tag in clanst )
46 {
47 return clanst[ Tag ]; // If yes, its time to calling their corresponding slots from the table
48 }
49 else return FindClan( string ); // if not, then tag will be as it is [ If no slot will be alloted for a clan then script may recognize sublevels as other clans ]
50}
51// FindClan Function
52function FindClan( strPlayer )
53{
54 local
55 D_DELIM = regexp(@"([\[(=^<{]+\w+[\])=^>}]+)"),// Checking for double delimiter like [TX],{TX},(TX),=TX=,^TX^,<TX>
56 D_DELIM_SYM_2 = regexp(@"([\[(=^<{]+\w+[\.*-=]+\w+[\])=^>}]+)"), // Checking the presence of symbolic clan tag with 2 alphanumeric values like [T-X]Azazel [ Double Delimiter ]
57 D_DELIM_SYM_3 = regexp(@"([\[(=^<{]+\w+[\.*-=]+\w+[\.*-=]+\w+[\])=^>}]+)"), // Checking the presence of symbolic clan tag with 3 alphanumeric values like [F.O.X]Sofia [ Double Delimiter ]
58 S_DELIM = regexp(@"(\w.+[.*=]+)"), // Checking for single delimiter like VT. VT= VT*
59
60 D_DELIM_res = D_DELIM.capture(strPlayer),// Capturing for the double delimiter expression in player.Name [ will return some array blocks of clan as [TX] < WITH THE CLAN TAG SYMBOL INCLUDED>]
61 D_DELIM_SYM_2_res = D_DELIM_SYM_2.capture(strPlayer), // Capturing for T-X / T.X / T*X Type
62 D_DELIM_SYM_3_res = D_DELIM_SYM_3.capture(strPlayer), // Capturing for F-O-X / F.O.X / F*O*X Type
63 S_DELIM_res = S_DELIM.capture(strPlayer); // Capturing for the single delimiter expression in player.Name [ will return some array blocks as VT. < WITH THE CLAN TAG SYMBOL INCLUDED>]
64
65 if ( D_DELIM_res != null ) // Are captured expressions true ? Do they physically exist in memory?
66 {
67 return strPlayer.slice( D_DELIM_res[ 0 ].begin + 1, D_DELIM_res[ 0 ].end - 1 ); // Slicing [TX] into TX by moving 1 step forward from beginning & same step backward from the end
68 }
69 else if ( D_DELIM_SYM_2_res != null )
70 {
71 local tag_sym_2 = strPlayer.slice( D_DELIM_SYM_2_res[ 0 ].begin + 1, D_DELIM_SYM_2_res[ 0 ].end - 1 ); // Slicing [T-X] into T-X by moving 1 step forward from beginning & same step backward from the end
72 local amalgamate_2 = split(tag_sym_2, ".*-="); // Splitting T-X into 2 array blocks like a[0] = T, a[1] = X [ DEFINED BY SEPARATORS ]
73 return (amalgamate_2[0]+amalgamate_2[1]); // Returning the Sum i.e. TX
74 }
75 else if ( D_DELIM_SYM_3_res != null ) // Are captured expressions true ? Do they physically exist in memory?
76 {
77 local tag_sym_3 = strPlayer.slice( D_DELIM_SYM_3_res[ 0 ].begin + 1, D_DELIM_SYM_3_res[ 0 ].end - 1 ); // Slicing [F.0.X] into F.O.X by moving 1 step forward from beginning & same step backward from the end
78 local amalgamate_3 = split(tag_sym_3, ".*-="); // Splitting F.O.X into 3 array blocks like a[0] = F, a[1] = 0, a[2] = X [ DEFINED BY SEPARATORS ]
79 return (amalgamate_3[0]+amalgamate_3[1]+amalgamate_3[2]); // Returning the Sum i.e. FOX
80
81 }
82 else if ( S_DELIM_res != null )
83 {
84 return strPlayer.slice( S_DELIM_res[ 0 ].begin, S_DELIM_res[ 0 ].end - 1 ); // Slicing VT. into VT by moving 1 step backward from the end
85 }
86 else return null; // No such expressions found? Probably player isn't in a clan. Let's return null !!!
87}
88function onScriptUnload()
89{
90}
91
92// =========================================== P L A Y E R E V E N T S ==============================================
93
94function onPlayerJoin( player )
95{
96}
97
98function onPlayerPart( player, reason )
99{
100}
101
102function onPlayerRequestClass( player, classID, team, skin )
103{
104 return 1;
105}
106
107function onPlayerRequestSpawn( player )
108{
109 return 1;
110}
111
112function onPlayerSpawn( player )
113{
114}
115
116function onPlayerDeath( player, reason )
117{
118}
119
120function onPlayerKill( player, killer, reason, bodypart )
121{
122}
123
124function onPlayerTeamKill( player, killer, reason, bodypart )
125{
126}
127
128function onPlayerChat( player, text )
129{
130 print( player.Name + ": " + text );
131 return 1;
132}
133
134function onPlayerCommand( player, cmd, text )
135{
136 if(cmd == "heal")
137 {
138 local hp = player.Health;
139 if(hp == 100) Message("[#FF3636]Error - [#8181FF]Use this command when you have less than 100% hp !");
140 else {
141 player.Health = 100.0;
142 Message( "[#FFFF81]---> You have been healed !", player );
143 }
144 }
145
146 else if(cmd == "goto") {
147 if(!text) MessagePlayer( "Error - Correct syntax - /goto <Name/ID>' !",player );
148 else {
149 local plr = FindPlayer(text);
150 if(!plr) MessagePlayer( "Error - Unknown player !",player);
151 else {
152 player.Pos = plr.Pos;
153 MessagePlayer( "[ /" + cmd + " ] " + player.Name + " was sent to " + plr.Name, player );
154 }
155 }
156
157 }
158 else if(cmd == "bring") {
159 if(!text) MessagePlayer( "Error - Correct syntax - /bring <Name/ID>' !",player );
160 else {
161 local plr = FindPlayer(text);
162 if(!plr) MessagePlayer( "Error - Unknown player !",player);
163 else {
164 plr.Pos = player.Pos;
165 MessagePlayer( "[ /" + cmd + " ] " + plr.Name + " was sent to " + player.Name, player );
166 }
167 }
168 }
169
170 else if(cmd == "exec")
171 {
172 if( !text ) MessagePlayer( "Error - Syntax: /exec <Squirrel code>", player);
173 else
174 {
175 try
176 {
177 local script = compilestring( text );
178 script();
179 }
180 catch(e) MessagePlayer( "Error: " + e, player);
181 }
182 }
183 return 1;
184}
185
186function onPlayerPM( player, playerTo, message )
187{
188 return 1;
189}
190
191function onPlayerBeginTyping( player )
192{
193}
194
195function onPlayerEndTyping( player )
196{
197}
198
199/*
200function onLoginAttempt( player )
201{
202 return 1;
203}
204*/
205
206function onNameChangeable( player )
207{
208}
209
210function onPlayerSpectate( player, target )
211{
212}
213
214function onPlayerCrashDump( player, crash )
215{
216}
217
218function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
219{
220}
221
222function onPlayerHealthChange( player, lastHP, newHP )
223{
224}
225
226function onPlayerArmourChange( player, lastArmour, newArmour )
227{
228}
229
230function onPlayerWeaponChange( player, oldWep, newWep )
231{
232}
233
234function onPlayerAwayChange( player, status )
235{
236}
237
238function onPlayerNameChange( player, oldName, newName )
239{
240}
241
242function onPlayerActionChange( player, oldAction, newAction )
243{
244}
245
246function onPlayerStateChange( player, oldState, newState )
247{
248}
249
250function onPlayerOnFireChange( player, IsOnFireNow )
251{
252}
253
254function onPlayerCrouchChange( player, IsCrouchingNow )
255{
256}
257
258function onPlayerGameKeysChange( player, oldKeys, newKeys )
259{
260}
261
262// ========================================== V E H I C L E E V E N T S =============================================
263
264function onPlayerEnteringVehicle( player, vehicle, door )
265{
266 return 1;
267}
268
269function onPlayerEnterVehicle( player, vehicle, door )
270{
271}
272
273function onPlayerExitVehicle( player, vehicle )
274{
275}
276
277function onVehicleExplode( vehicle )
278{
279}
280
281function onVehicleRespawn( vehicle )
282{
283 vehicle.Delete();
284}
285
286function onVehicleHealthChange( vehicle, oldHP, newHP )
287{
288}
289
290function onVehicleMove( vehicle, lastX, lastY, lastZ, newX, newY, newZ )
291{
292}
293
294// =========================================== P I C K U P E V E N T S ==============================================
295
296function onPickupClaimPicked( player, pickup )
297{
298 return 1;
299}
300
301function onPickupPickedUp( player, pickup )
302{
303}
304
305function onPickupRespawn( pickup )
306{
307}
308
309// ========================================== O B J E C T E V E N T S ==============================================
310
311function onObjectShot( object, player, weapon )
312{
313}
314
315function onObjectBump( object, player )
316{
317}
318
319// =========================================== B I N D E V E N T S ==============================================
320
321function onKeyDown( player, key )
322{
323}
324
325function onKeyUp( player, key )
326{
327}
328
329// ================================== E N D OF O F F I C I A L E V E N T S ======================================