This repository has been archived by the owner on Dec 18, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vgm_console.cpp
633 lines (607 loc) · 23.8 KB
/
vgm_console.cpp
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
#include "vgm_actions.h"
#include "vgm_player.h"
#include "vgm_console.h"
class Ban_Hash : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_banhash"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_BANHASH <HASH> <0/1> - Bans or unbans a hash (0 = unban, 1 = ban).");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
const char *hash = strtok((char *)input," ");
if (strlen(hash) == 32) {
int m = atoi(strtok(NULL," "));
if (m == 1) {
writeProfileString("HashBans",hash,"1","vgm_bans.ini");
ConsoleOut("[VGM] Hash %s has been banned.",hash);
} else if (m == 0) {
if (getProfileInt("HashBans",hash,0,"vgm_bans.ini") == 1) {
ConsoleOut("[VGM] Hash %s has been removed from the banlist.",hash);
writeProfileString("HashBans",hash,"0","vgm_bans.ini");
} else {
ConsoleOut("[VGM] Hash %s is not in the banlist.",hash);
}
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Buildings : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_buildinginfo"; }
const char* Get_Alias() { return "v_buildings"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_BUILDINGINFO - Shows building status for both teams.");
return "";
}
void Activate(const char* input) {
Building_Status();
}
};
class CharacterChg_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_character"; }
const char* Get_Alias() { return "v_char"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_CHARACTER <ID> <unit> - Changes a player's character.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
if (ID > 0) {
char w[256];
sprintf(w,"%s",Get_Preset_From_Short("char",strtok(NULL," ")).c_str());
if (stricmp((const char *)w,"None")) {
Change_Character(Player_GameObj(ID),(const char *)w);
ConsoleOut("[VGM] Player %s is now a %s.",Player_Name_From_ID(ID).c_str(),Get_Pretty_Name((const char *)w).c_str());
} else { ConsoleOut("[VGM] Unknown unit."); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Create_Veh : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_create"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_CREATE <ID> <vehicle> - Gives a vehicle to a player.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
if (ID > 0) {
char* V = strtok(NULL," ");
std::string Veh = Get_Preset_From_Short("veh",V);
#ifdef _DEV_
if (!stricmp(Veh.c_str(),"None")) { Veh = std::string(V); }
#else
if (!stricmp(Veh.c_str(),"None")) { ConsoleOut("[VGM] Unknown unit."); return; }
#endif
GameObject *o = Player_GameObj(ID);
GameObject *f = Find_Vehicle_Factory(Commands->Get_Player_Type(o));
if (f && Commands->Get_Health(f) > 0.0f) {
Create_Vehicle(Veh.c_str(),0.0f,o,Commands->Get_Player_Type(o));
ConsoleOut("[VGM] Player %s has been given a %s.",Player_Name_From_ID(ID).c_str(),Get_Pretty_Name(Veh.c_str()).c_str());
} else { ConsoleOut("[VGM] The %s for team %s is either dead or not available. Use V_SPAWN instead.",f ? Get_Pretty_Name(f).c_str() : "Vehicle Factory",Get_Translated_Team_Name(Commands->Get_Player_Type(o)).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Credit_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_credit"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_CREDIT <ID> <amount> - Gives a player an amount of credits. Negative numbers accepted.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
float x = (float)atof(strtok(NULL," "));
if (ID > 0) {
GameObject *o = Player_GameObj(ID);
Commands->Give_Money(o,x,false);
ConsoleOut("[VGM] Player %s has been given %.0f credits.",Player_Name_From_ID(ID).c_str(),x);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Credit2_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_credit2"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_CREDIT2 <ID> <amount> - Sets a player's credits to a given amount. Negative numbers accepted.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
float x = (float)atof(strtok(NULL," "));
if (ID > 0) {
GameObject *o = Player_GameObj(ID);
Commands->Give_Money(o,-1 * Commands->Get_Money(o) + x,false);
ConsoleOut("[VGM] Player %s now has %.0f credits.",Player_Name_From_ID(ID).c_str(),x);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Emergency_Shutdown : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_emergencyshutdown"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_EMERGENCYSHUTDOWN - Emergency shutdown for the server in case of internal or severe errors. USE AT OWN RISK.");
return "";
}
void Activate(const char* input) {
EmergencyShutdown = true;
}
};
class GetPos_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_getpos"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_GETPOS <ID> - Show's a player's X,Y,Z coords and their Facing Angle.");
return "";
}
void Activate(const char* input) {
int ID = atoi(input);
if (ID > 0) {
Vector3 v = Commands->Get_Position(Player_GameObj(ID));
float f = Commands->Get_Facing(Player_GameObj(ID));
ConsoleOut("[VGM] Player %s is at %fX,%fY,%fZ, facing %f.",Player_Name_From_ID(ID).c_str(),v.X,v.Y,v.Z,f);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Get_Serial : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_getserial"; }
const char* Get_Alias() { return "v_serial"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_GETSERIAL <ID> - Gets the hash of a player's serial number.");
return "";
}
void Activate(const char* input) {
int ID = atoi(input);
if (ID > 0) {
Request_Serial(ID);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Grant_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_grant"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_GRANT <ID> <weapon> - Gives a weapon to a player.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
if (ID > 0) {
const char *t = strtok(NULL," ");
if (!stricmp(t,"all")) {
Stewie_SoldierGameObj *s = Stewie_GameObjManager::Find_Soldier_Of_Client_ID(ID);
if (Commands->Get_Health((GameObject *)s) <= 0.0f) { return; }
Give_All_Weapons(ID);
ConsoleOut("[VGM] Player %s has been given all weapons.",Player_Name_From_ID(ID).c_str());
} else {
char w[256];
sprintf(w,"%s",Get_Preset_From_Short("weapons",t).c_str());
if (stricmp((const char *)w,"None")) { Give_Weapon(ID,(const char *)w); }
Stewie_SoldierGameObj *s = Stewie_GameObjManager::Find_Soldier_Of_Client_ID(ID);
if (Commands->Get_Health((GameObject *)s) <= 0.0f) { return; }
ConsoleOut("[VGM] Player %s has been given a(n) %s.",Player_Name_From_ID(ID).c_str(),Get_Pretty_Name((const char *)w).c_str());
}
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Kill_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_kill"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_KILL <ID> - Kills a player.");
return "";
}
void Activate(const char* input) {
int ID = atoi(input);
if (ID > 0) {
Kill_Player(ID);
ConsoleOut("[VGM] Player %s has been killed.",Player_Name_From_ID(ID).c_str());
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Move_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_move"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_MOVE <ID> <x> <y> <z> - Moves a player X, Y, Z respectively.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 4) {
int ID = atoi(strtok((char *)input," "));
float x = (float)atof(strtok(NULL," "));
float y = (float)atof(strtok(NULL," "));
float z = (float)atof(strtok(NULL," "));
if (ID > 0) {
Move_Player(ID,x,y,z,true,true);
ConsoleOut("[VGM] Player %s has been moved %fX,%fY,%fZ.",Player_Name_From_ID(ID).c_str(),x,y,z);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Mute_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_mute"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_MUTE <ID> <0/1> - Toggles player's muting (0 = off, 1 = on).");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
int m = atoi(strtok(NULL," "));
if (ID > 0) {
std::string rname = Player_Name_From_ID(ID);
vPlayer *player = vPManager->Get_Player(rname.c_str());
if (player) {
if (m == 1) {
player->Set_Muted(true);
ConsoleOut("[VGM] Player %s has been muted.",rname.c_str());
} else if (m == 0) {
player->Set_Muted(false);
ConsoleOut("[VGM] Player %s is no longer muted.",rname.c_str());
}
}
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class PInfo : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_pinfo"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_PINFO - Shows all players ingame and corresponding info such as score, kills, deaths, etc..");
return "";
}
void Activate(const char* input) {
ConsoleOut("Start PInfo output");
for (int i = 1; i <= 128; i++) {
Stewie_cPlayer *player = Stewie_cPlayerManager::Find_Player(i);
if (player && player->IsInGame && player->IsActive) {
GameObject *o = Player_GameObj(i);
ConsoleOut("%d,%s,%.0f,%d,%d,%s;%d,%d,%d,%d,%d,%.0f,%f,%s,%s",
i,Player_Name_From_ID(i).c_str(),
(float)(player->Score.Get()),
(int)(player->PlayerType.Get()),
player->Get_Ping(),
inet_ntoa(player->IpAddress),
Stewie_cNetwork::PServerConnection->RemoteHosts[i]->address.sin_port,
Get_KBPS(i),
0,
(int)(player->Kills.Get()),
(int)(player->Deaths.Get()),
(float)(player->Money.Get()),
Get_KD_Ratio(player),
Get_Pretty_Name(o).c_str(),
Get_Pretty_Name(Get_Vehicle(o)).c_str()
);
}
}
ConsoleOut("End PInfo output");
}
};
class PLimit : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_plimit"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_PLIMIT <num> - Sets the number of players allowed ingame.");
return "";
}
void Activate(const char* input) {
unsigned int Plimit = (unsigned int)atoi(input);
if (Plimit > 0 && Plimit <= 127) {
bool Success = GameDataObj()->Set_Max_Players(Plimit);
if (Success) { ConsoleOut("[VGM] Player limit set to %u.",Plimit); }
else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class QSpec_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_qspectate"; }
const char* Get_Alias() { return "v_qspec"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_QSPECTATE <ID> - Activate spectating for player.");
return "";
}
void Activate(const char* input) {
int ID = atoi(input);
if (ID > 0) {
if (Stewie_cPlayerManager::Find_Player(ID)) {
int s = Spectate_Player(ID,true);
if (s == false) { ConsoleOut("[VGM] Player %s is no longer quietly spectating.",Player_Name_From_ID(ID).c_str()); }
else { ConsoleOut("[VGM] Player %s is now in quiet spectate mode.",Player_Name_From_ID(ID).c_str()); }
} else {
ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str());
}
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Rehash : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_rehash"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_REHASH - Rehashes all Settings (vgm.ini changes).");
return "";
}
void Activate(const char* input) {
Config->Rehash(false,false,true);
ConsoleOut("[VGM] Configuration rehashed.");
}
};
class Score_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_score"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_SCORE <ID> <amount> - Increases/decreases a player's score by a given amount. Negative numbers accepted.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
float x = (float)atof(strtok(NULL," "));
if (ID > 0) {
GameObject *o = Player_GameObj(ID);
Commands->Give_Points(o,x,false);
ConsoleOut("[VGM] Player %s has been given %.0f points.",Player_Name_From_ID(ID).c_str(),x);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Score2_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_score2"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_SCORE2 <ID> <amount> - Sets a player's score to a given amount. Negative numbers accepted.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
float x = (float)atof(strtok(NULL," "));
if (ID > 0) {
GameObject *o = Player_GameObj(ID);
Commands->Give_Points(o,-1 * Commands->Get_Points(o) + x,false);
ConsoleOut("[VGM] Player %s now has %.0f points.",Player_Name_From_ID(ID).c_str(),x);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class SetPos_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_setpos"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_SETPOS <ID> <x> <y> <z> - Moves a player to a set of X, Y, Z coords.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 4) {
int ID = atoi(strtok((char *)input," "));
float x = (float)atof(strtok(NULL," "));
float y = (float)atof(strtok(NULL," "));
float z = (float)atof(strtok(NULL," "));
if (ID > 0) {
Move_Player(ID,x,y,z,false);
ConsoleOut("[VGM] Player %s has been moved to %fX,%fY,%fZ.",Player_Name_From_ID(ID).c_str(),x,y,z);
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class SetFPS : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_sfpslimit"; }
const char* Get_Alias() { return "v_sfps"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("V_SFPSLIMIT <FPS> - Sets FPS limit for the server.");
return "";
}
void Activate(const char* input) {
if (input) {
int NewFps = atoi(input);
int Success = Set_SFPS_Limit(NewFps);
if (Success == -1) { ConsoleOut("[VGM] Could not set server FPS at this time."); }
else if (Success == 0) { ConsoleOut("[VGM] Server FPS uncapped."); }
else { ConsoleOut("[VGM] New server FPS is now: %d",Success); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Spawn_Veh : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_spawn"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_SPAWN <ID> <vehicle> <amount> - Gives an amount of a vehicle to a player. If no amount specified, 1 is used.");
return "";
}
void Activate(const char* input) {
vTokenParser *Str = new vTokenParser();
Str->Set((char *)input);
Str->Parse(" ");
if (Str->Numtok() >= 2) {
int ID = atoi(Str->Gettok(1).c_str());
if (ID > 0) {
std::string w = Get_Preset_From_Short("veh",Str->Gettok(2).c_str());
if (stricmp(w.c_str(),"None")) {
int a = 1;
if (Str->Numtok() >= 3) { a = atoi(Str->Gettok(3).c_str()); }
if (a <= 0) { a = 1; }
Vector3 pos = Commands->Get_Position(Player_GameObj(ID));
for (int i = 0; i < a; i++) {
pos.Z += 5.0f;
GameObject *o = Commands->Create_Object(w.c_str(),pos);
Commands->Set_Player_Type(o,-2);
}
ConsoleOut("[VGM] Player %s has been given %d '%s's.",Player_Name_From_ID(ID).c_str(),a,w.c_str());
} else { ConsoleOut("[VGM] Unknown unit."); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
Str->Delete();
}
};
class Spec_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_spectate"; }
const char* Get_Alias() { return "v_spec"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("V_SPECTATE <ID> - Activate spectating for player.");
return "";
}
void Activate(const char* input) {
int ID = atoi(input);
if (ID > 0) {
if (Stewie_cPlayerManager::Find_Player(ID)) {
int s = Spectate_Player(ID,false);
if (s == false) { ConsoleOut("[VGM] Player %s is no longer spectating.",Player_Name_From_ID(ID).c_str()); }
else { ConsoleOut("[VGM] Player %s is now in spectate mode.",Player_Name_From_ID(ID).c_str()); }
} else {
ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str());
}
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Tele_Pl : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_tele"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_TELE <ID> <x> <y> <z> - Moves a player to a set of X, Y, Z coords.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 2) {
int ID = atoi(strtok((char *)input," "));
int target = atoi(strtok(NULL," "));
if (ID > 0) {
GameObject *obj = Player_GameObj(target);
Vector3 pos = Commands->Get_Position(obj);
Move_Player(ID,pos.X,pos.Y,(pos.Z + 3),false);
ConsoleOut("[VGM] Player %s has been teleported to %s.",Player_Name_From_ID(ID).c_str(),Player_Name_From_ID(target).c_str());
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
class Vault_Display : public Stewie_ConsoleCommandClass {
public:
const char* Get_Name() { return "v_vault"; }
const char* Get_Help() {
if (ServerInit == false) { return ""; }
ConsoleOut("[VGM] V_VAULT <name> - Displays all medals for a specific player.");
return "";
}
void Activate(const char* input) {
if (numtok(input,32) >= 1) {
const char *nick = strtok((char *)input," ");
if (nick && strlen(nick) > 0) {
bool allowed = false;
if (Config->MedalsRestricted) {
for (int totry = 1; totry <= 256; totry++) {
char entry[64];
sprintf(entry,"User%d",totry);
char result[512];
if (getProfileString("MedalUsers",(const char *)entry,"",result,512,"vgm_users.ini")) {
if (!stricmp(result,nick)) {
allowed = true;
break;
}
}
}
} else {
allowed = true;
for (int totry = 1; totry <= 256; totry++) {
char entry[64];
sprintf(entry,"User%d",totry);
char result[512];
if (getProfileString("MedalUsers",(const char *)entry,"",result,512,"vgm_users.ini")) {
if (!stricmp(result,nick)) {
allowed = false;
break;
}
}
}
}
if (allowed) {
ConsoleOut("[VGM] Displaying %s Achievements:",nick);
int TotalMedals = 0;
for (unsigned int j = 0; j < (int)vMManager->vLAST; j++) {
char m[16],f[128];
sprintf(m,"Medal%d",j);
sprintf(f,"vgm\\medals_%s.ini",nick);
int Medals = getProfileInt("Medals",(const char*)m,0,(const char*)f);
TotalMedals += Medals;
if (Medals > 0) { ConsoleOut("[VGM] %s times Achieved: %d",AwardNames[j],Medals); }
}
if (TotalMedals == 0) { ConsoleOut("[VGM] %s has no achievements.",nick); }
else { ConsoleOut("[VGM] Total %d achievements.",TotalMedals); }
} else {
ConsoleOut("[VGM] Server does not record achievements for %s.",nick);
}
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
} else { ConsoleOut("[VGM] Invalid use of command %s.",To_Uppercase(Get_Name()).c_str()); }
}
};
void ConsoleCommandHook(Stewie_DynamicVectorClass<Stewie_ConsoleCommandClass*>& Functions) {
Stewie_ConsoleCommandClass* cf;
Functions.Add(cf = new Ban_Hash);
Functions.Add(cf = new Buildings);
Functions.Add(cf = new CharacterChg_Pl);
Functions.Add(cf = new Create_Veh);
Functions.Add(cf = new Credit_Pl);
Functions.Add(cf = new Credit2_Pl);
//Functions.Add(cf = new Emergency_Shutdown);
Functions.Add(cf = new GetPos_Pl);
Functions.Add(cf = new Get_Serial);
Functions.Add(cf = new Grant_Pl);
Functions.Add(cf = new Kill_Pl);
Functions.Add(cf = new Move_Pl);
Functions.Add(cf = new Mute_Pl);
Functions.Add(cf = new PInfo);
Functions.Add(cf = new PLimit);
Functions.Add(cf = new QSpec_Pl);
Functions.Add(cf = new Rehash);
Functions.Add(cf = new Score_Pl);
Functions.Add(cf = new Score2_Pl);
Functions.Add(cf = new SetFPS);
Functions.Add(cf = new SetPos_Pl);
Functions.Add(cf = new Spawn_Veh);
Functions.Add(cf = new Spec_Pl);
Functions.Add(cf = new Tele_Pl);
Functions.Add(cf = new Vault_Display);
}
ASMHackCall ConsoleCommandHack(0x000000, &ConsoleCommandHook); // For security and licensing purposes, an address has been hidden from this line