forked from tsx-eu/csgo-roleplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roleplay_mcdo.sp
291 lines (221 loc) · 8.37 KB
/
roleplay_mcdo.sp
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
/*
* Cette oeuvre, création, site ou texte est sous licence Creative Commons Attribution
* - Pas d’Utilisation Commerciale
* - Partage dans les Mêmes Conditions 4.0 International.
* Pour accéder à une copie de cette licence, merci de vous rendre à l'adresse suivante
* http://creativecommons.org/licenses/by-nc-sa/4.0/ .
*
* Merci de respecter le travail fourni par le ou les auteurs
* https://www.ts-x.eu/ - [email protected]
*/
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#include <colors_csgo> // https://forums.alliedmods.net/showthread.php?p=2205447#post2205447
#include <smlib> // https://github.com/bcserv/smlib
#define __LAST_REV__ "v:0.1.0"
#pragma newdecls required
#include <roleplay.inc> // https://www.ts-x.eu
//#define DEBUG
public Plugin myinfo = {
name = "Jobs: Mc'Do", author = "KoSSoLaX",
description = "RolePlay - Jobs: Mc'Donalds",
version = __LAST_REV__, url = "https://www.ts-x.eu"
};
int g_cBeam, g_cGlow;
// ----------------------------------------------------------------------------
public void OnPluginStart() {
RegServerCmd("rp_item_hamburger", Cmd_ItemHamburger, "RP-ITEM", FCVAR_UNREGISTERED);
RegServerCmd("rp_item_banane", Cmd_ItemBanane, "RP-ITEM", FCVAR_UNREGISTERED);
}
public void OnMapStart() {
g_cBeam = PrecacheModel("materials/sprites/laserbeam.vmt");
g_cGlow = PrecacheModel("materials/sprites/glow01.vmt");
}
// ------------------------------------------------------------------------------
public Action Cmd_ItemHamburger(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemHamburger");
#endif
char arg1[12];
GetCmdArg(1, arg1, 11);
int client = GetCmdArgInt(2);
if( StrEqual(arg1, "vital") || StrEqual(arg1, "max") ) {
float vita = rp_GetClientFloat(client, fl_Vitality);
rp_SetClientFloat(client, fl_Vitality, vita + 256.0);
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous ressentez votre vitalité s'augmenter (%.1f -> %.1f).", vita, vita+256.0);
}
if( StrEqual(arg1, "energy") || StrEqual(arg1, "max") ) {
rp_SetClientFloat(client, fl_Energy, 100.0);
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous ressentez votre énergie s'augmenter.");
}
if( StrEqual(arg1, "fat") ) {
float size = rp_GetClientFloat(client, fl_Size);
rp_SetClientInt(client, i_Kevlar, 100);
if( size < 1.6 ) {
rp_SetClientFloat(client, fl_Size, size + 0.05);
SetEntPropFloat(client, Prop_Send, "m_flModelScale", size + 0.05);
}
}
else if( StrEqual(arg1, "mac") ) {
if( rp_IsInPVP(client) ) {
rp_SetClientFloat(client, fl_CoolDown, rp_GetClientFloat(client, fl_CoolDown) + 5.0);
rp_SetClientFloat(client, fl_Reflect, GetGameTime() + 3.0);
}
else {
rp_SetClientFloat(client, fl_Reflect, GetGameTime() + 5.0);
}
float vecTarget[3];
GetClientAbsOrigin(client, vecTarget);
TE_SetupBeamRingPoint(vecTarget, 10.0, 300.0, g_cBeam, g_cGlow, 0, 15, 0.5, 50.0, 0.0, {255, 255, 0, 50}, 10, 0);
TE_SendToAll();
}
else if( StrEqual(arg1, "chicken") ) {
if( Math_GetRandomInt(1, 4) == 4 ) {
int wepID = GivePlayerItem(client, "weapon_mac10");
rp_SetClientWeaponSkin(client, wepID);
}
else {
int ent = CreateEntityByName("chicken");
DispatchSpawn(ent);
float vecOrigin[3];
GetClientAbsOrigin(client, vecOrigin);
vecOrigin[2] += 20.0;
TeleportEntity(ent, vecOrigin, NULL_VECTOR, NULL_VECTOR);
}
}
else if( StrEqual(arg1, "happy") ) {
int amount = 0;
int iItemRand[MAX_ITEMS*2];
int jobID;
char cmd[128];
bool lucky = rp_IsClientLucky(client);
for(int i = 0; i < MAX_ITEMS; i++) {
if( rp_GetItemInt(i, item_type_prix) <= 0 )
continue;
if( rp_GetItemInt(i, item_type_auto) == 1 )
continue;
jobID = rp_GetItemInt(i, item_type_job_id);
if( jobID <= 0 || jobID == 61 || jobID == 91 ) // Aucun, Appart, Mafia
continue;
if( jobID == 51 && Math_GetRandomInt(0, 1) ) // Moins de chance pour carshop stp
continue;
rp_GetItemData(i, item_type_extra_cmd, cmd, sizeof(cmd));
if( strlen(cmd) <= 1 ) // UNKNOWN
continue;
if( StrContains(cmd, "rp_chirurgie") == 0 )
continue;
iItemRand[amount] = i;
amount++;
if( StrContains(cmd, "rp_giveitem weapon_") == 0 ) { // 2x plus de chance d'avoir une arme
iItemRand[amount] = i;
amount++;
}
if( lucky && rp_GetItemInt(i, item_type_prix) > 2000 ) { // 2x plus de chance... Si on a de la chance grâce aux portes bonheures
iItemRand[amount] = i;
amount++;
}
}
int item_id = iItemRand[ Math_GetRandomInt(0, amount-1) ];
rp_ClientGiveItem(client, item_id, 1, true);
rp_GetItemData(item_id, item_type_name, cmd, sizeof(cmd));
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous avez reçu comme cadeau: %s", cmd);
if( item_id == GetCmdArgInt(args) )
rp_IncrementSuccess(client, success_list_mcdo);
}
else if( StrEqual(arg1, "box") ) { // TODO: Move to roleplay_armurerie
int amount = 0;
int iItemRand[MAX_ITEMS];
bool lucky = rp_IsClientLucky(client);
for(int i = 0; i < MAX_ITEMS; i++) {
if( rp_GetItemInt(i, item_type_job_id) != 111 )
continue;
iItemRand[amount] = i;
amount++;
if( !lucky && rp_GetItemInt(i, item_type_prix) <= 1000 ) { // 2x plus de chance... Si on a de la chance grâce aux portes bonheures
iItemRand[amount] = i;
amount++;
}
}
char cmd[128];
int item_id = iItemRand[ Math_GetRandomInt(0, amount-1) ];
rp_ClientGiveItem(client, item_id, 1, true);
rp_GetItemData(item_id, item_type_name, cmd, sizeof(cmd));
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous avez reçu comme cadeau: %s", cmd);
}
else if( StrEqual(arg1, "drugs") ) { // TODO: Move to roleplay_dealer
int amount = 0;
int iItemRand[MAX_ITEMS];
char cmd[128];
for(int i = 0; i < MAX_ITEMS; i++) {
rp_GetItemData(i, item_type_extra_cmd, cmd, sizeof(cmd));
if( StrContains(cmd, "rp_item_drug") != 0 )
continue;
iItemRand[amount] = i;
amount++;
}
int item_id = iItemRand[ Math_GetRandomInt(0, amount-1) ];
int rnd = 7+Math_GetRandomPow(1, 5);
rp_ClientGiveItem(client, item_id, rnd, true);
rp_GetItemData(item_id, item_type_name, cmd, sizeof(cmd));
CPrintToChat(client, "{lightblue}[TSX-RP]{default} Vous avez reçu comme cadeau: %dx %s", rnd, cmd);
}
else if( StrEqual(arg1, "spacy") ) {
rp_SetClientKnifeType(client, ball_type_fire);
}
return Plugin_Handled;
}
public Action Cmd_ItemBanane(int args) {
#if defined DEBUG
PrintToServer("Cmd_ItemBanane");
#endif
char arg1[12];
GetCmdArg(1, arg1, 11);
int client = StringToInt(arg1);
char classname[64];
Format(classname, sizeof(classname), "rp_banana_%i", client);
float vecOrigin[3];
GetClientAbsOrigin(client, vecOrigin);
int ent = CreateEntityByName("prop_physics_override");
DispatchKeyValue(ent, "classname", classname);
DispatchKeyValue(ent, "model", "models/props/cs_italy/bananna.mdl");
DispatchSpawn(ent);
ActivateEntity(ent);
SetEntityModel(ent, "models/props/cs_italy/bananna.mdl");
SetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity", client);
SetEntityRenderMode(ent, RENDER_NONE);
TeleportEntity(ent, vecOrigin, NULL_VECTOR, NULL_VECTOR);
Entity_SetOwner(ent, client);
SetEntProp(ent, Prop_Data, "m_takedamage", 0);
ServerCommand("sm_effect_fading \"%i\" \"0.5\" \"0\"", ent);
rp_ScheduleEntityInput(ent, 60.0, "Kill");
SDKHook(ent, SDKHook_Touch, BuildingBanana_touch);
return Plugin_Handled;
}
public Action BuildingBanana_touch(int index, int client) {
#if defined DEBUG
PrintToServer("BuildingBanana_touch");
#endif
if( !IsValidClient(client) )
return Plugin_Continue;
char sound[128];
Format(sound, sizeof(sound), "hostage/hpain/hpain%i.wav", Math_GetRandomInt(1, 6));
EmitSoundToAll(sound, client);
rp_ClientDamage(client, 25, Entity_GetOwner(index));
float vecPlayerOrigin[3];
vecPlayerOrigin[2] += 1.0;
GetClientAbsOrigin(client, vecPlayerOrigin);
if(GetEntityFlags(client) & FL_ONGROUND) {
int flags = GetEntityFlags(client);
SetEntityFlags(client, (flags&~FL_ONGROUND) );
SetEntPropEnt(client, Prop_Send, "m_hGroundEntity", -1);
}
float vecVelocity[3];
vecVelocity[0] = GetRandomFloat(400.0, 500.0);
vecVelocity[1] = GetRandomFloat(400.0, 500.0);
vecVelocity[2] = GetRandomFloat(600.0, 800.0);
TeleportEntity(client, vecPlayerOrigin, NULL_VECTOR, vecVelocity);
AcceptEntityInput(index, "Kill");
SDKUnhook(index, SDKHook_Touch, BuildingBanana_touch);
return Plugin_Continue;
}