View difference between Paste ID: aaUXuqY4 and m6DX0RJG
SHOW: | | - or go back to the newest paste.
1
/*------------------------------------------------------------------------------
2
					********************************
3
							SUMO - Mini-Game.
4
					********************************
5
Descrição:
6
	Um pequeno mini-game de estilo sumo.
7
Versão:
8
	1.0
9
Desenvolvedor:
10
	Luke "Larceny" G.
11
ChangeLOG:
12
	05/10/2011:
13
		Primeiro lançamento.
14
Agradecimentos:
15
	ZeeX						   			- ZCMD Command Processor.
16
	Y_Less									- foreach
17
	GhostRider                              - Mapping.
18
	Equipe SA-MP(past\present\future)		- SAMP.
19
------------------------------------------------------------------------------*/
20
21
#define FILTERSCRIPT
22
23
#include <a_samp>
24
#include  <zcmd>
25
26
#tryinclude <foreach>
27
28
new
29
	g_PLAYERS_TOTAL,
30
	g_COUNTIN_TIMER,
31
	g_SPAWNED_VEHICLE[MAX_PLAYERS];
32
33
forward CreateSumoVehicle(playerid);
34
forward OnClientUpdate();
35
36
#define IsPlayerInSumo(%0) 			GetPVarInt(%0,"IsPlayerInSumo")
37
#define SetPlayerSumo(%1,%2) 		SetPVarInt(%1,"IsPlayerInSumo",%2)
38
#define GetPlayerSumoTime(%0) 		GetPVarInt(%0,"PlayerSumoTime")
39
#define SetPlayerSumoAFK(%0,%1) 	SetPVarInt(%0,"SumoAFK",%1)
40
#define AddPlayerSumoTime(%0,%1) 	SetPVarInt(%0,"PlayerSumoTime",GetPVarInt(%0,"PlayerSumoTime")+%1)
41
#define SetPlayerSumoTime(%0,%1) 	SetPVarInt(%0,"PlayerSumoTime",%1)
42
43
stock
44
	GetPlayerNameEx(playerid)
45
{
46
    new
47
		string[MAX_PLAYER_NAME];
48
    GetPlayerName(playerid, string, MAX_PLAYER_NAME);
49
    return string;
50
}
51
52
stock
53
	CreateVehicleEx(playerid, modelid, Float:X, Float:Y, Float:Z, Float:A, color1, color2)
54
{
55
	if (g_SPAWNED_VEHICLE[playerid] != 0) DestroyVehicle(g_SPAWNED_VEHICLE[playerid]);
56
	g_SPAWNED_VEHICLE[playerid] = CreateVehicle(modelid, X,Y,Z,A, color1, color2, -1);
57
}
58
59
new SUMO_CARS[17][1] =
60
{
61
	{411},
62
	{541},
63
	{451},
64
	{602},
65
	{429},
66
	{402},
67
	{415},
68
	{587},
69
	{502},
70
	{503},
71
	{559},
72
	{603},
73
	{475},
74
	{506},
75
	{477},
76
	{504},
77
	{558}
78
};
79
80
new Float:SUMO_SPAWNS[11][4] =
81
{
82
	{2913.7920,-3130.5566,107.2750,163.2152},
83
	{2901.9172,-3126.9749,107.2984,191.7273},
84
	{2888.5759,-3131.6440,107.3228,208.8633},
85
	{2876.4026,-3138.3540,107.3490,235.2153},
86
	{2869.5813,-3150.2598,107.3736,264.0153},
87
	{2869.2766,-3161.9634,107.3946,276.5433},
88
	{2872.5164,-3174.3484,107.4165,291.9513},
89
	{2878.2810,-3185.4270,107.4387,321.1833},
90
	{2887.4141,-3192.7739,107.4608,321.1833},
91
	{2897.9683,-3196.9666,107.4779,355.0377},
92
	{2911.6592,-3197.2813,107.5027,355.0377}
93
};
94
95
public OnFilterScriptInit()
96
{
97
	print("\n--------------------------------------------------------");
98
	print(" Iniciando \"SUMO_SCRIPT\" by Luke \"Larceny\" G...");
99
	print(" ...\"SUMO_SCRIPT\" iniciado com sucesso!");
100
	print("--------------------------------------------------------\n");
101
	CreateObject(13607,2905.9548339844,-3160.29296875,104.93536376953,0,0,0,300.0);
102
	CreateObject(18450,2958.955078125,-3215.8120117188,86.87939453125,359.58288574219,20.072540283203,314.08843994141,300.0);
103
	CreateObject(13607,3007.0251464844,-3267.2795410156,78.075241088867,0,0,306,300.0);
104
	CreateObject(1633,2931.97265625,-3195.7143554688,99.627136230469,11.920684814453,0,43.659301757813,300.0);
105
	CreateObject(1633,2940.1413574219,-3188.4636230469,99.581954956055,11.920166015625,0,43.654174804688,300.0);
106
	CreateObject(1633,2937.1958007813,-3191.3784179688,99.564033508301,11.920166015625,0,43.654174804688,300.0);
107
	CreateObject(1633,2934.4245605469,-3193.8444824219,99.583084106445,11.920166015625,0,43.654174804688,300.0);
108
	CreateObject(3864,2918.455078125,-3195.91796875,107.33255767822,0,0,0,300.0);
109
	CreateObject(3864,2904.1618652344,-3198.6179199219,107.49332427979,0,0,0,300.0);
110
	CreateObject(3864,2891.4709472656,-3195.6599121094,107.49332427979,0,0,0,300.0);
111
	CreateObject(3864,2882.2456054688,-3190.8923339844,107.49332427979,0,0,0,300.0);
112
	CreateObject(3864,2873.7077636719,-3181.337890625,107.49332427979,0,0,0,300.0);
113
	CreateObject(3864,2869.1154785156,-3168.7836914063,107.49332427979,0,0,0,300.0);
114
	CreateObject(3864,2868.744140625,-3155.3662109375,107.49332427979,0,0,0,300.0);
115
	CreateObject(3864,2871.6098632813,-3144.1569824219,107.49332427979,0,0,0,300.0);
116
	CreateObject(3864,2879.5402832031,-3132.4753417969,107.49332427979,0,0,0,300.0);
117
	CreateObject(3864,2893.7329101563,-3124.2341308594,107.49332427979,0,0,0,300.0);
118
	CreateObject(3864,2908.5739746094,-3122.6245117188,107.49332427979,0,0,0,300.0);
119
	CreateObject(3864,2923.6279296875,-3127.2817382813,107.49332427979,0,0,0,300.0);
120
	CreateObject(3864,2936.5686035156,-3137.7502441406,107.49332427979,0,0,0,300.0);
121
	CreateObject(3864,2941.8908691406,-3148.3449707031,107.49332427979,0,0,0,300.0);
122
	CreateObject(3864,2944.1440429688,-3162.4973144531,107.5002746582,0,0,0,300.0);
123
	CreateObject(3864,2940.5539550781,-3177.8244628906,107.49332427979,0,0,0,300.0);
124
	g_COUNTIN_TIMER = SetTimer("OnClientUpdate", 1000, true);
125
	return 1;
126
}
127
128
public OnFilterScriptExit()
129
{
130
	KillTimer(g_COUNTIN_TIMER);
131
	return 1;
132
}
133
134
public OnPlayerSpawn(playerid)
135
{
136
	if (IsPlayerInSumo(playerid))
137
	{
138
		new
139
			SUMO_STRING[58],
140
			RAND = random(sizeof(SUMO_SPAWNS)),
141
			RAND_CARS = random(sizeof(SUMO_CARS));
142
		format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s morreu no ringue.", GetPlayerNameEx(playerid));
143
		#if defined _foreach_included
144
			foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
145
		#else
146
			for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
147
		#endif
148
		SetPlayerSumoTime(playerid, 0);
149
		CreateVehicleEx(playerid, SUMO_CARS[RAND_CARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
150
		PutPlayerInVehicle(playerid, g_SPAWNED_VEHICLE[playerid], 0);
151
	}
152
	return 1;
153
}
154
155
public OnPlayerDisconnect(playerid, reason)
156
{
157
	if (IsPlayerInSumo(playerid))
158
	{
159
		g_PLAYERS_TOTAL--;
160
		#if defined _foreach_included
161
		foreach (Player, i)
162
		#else
163
		for (new i = 0; i < MAX_PLAYERS; i++)
164
		#endif
165
		{
166
			if (IsPlayerInSumo(i))
167
			{
168
				new
169
					STRING[75];
170
				format(STRING, sizeof STRING, "[X] {FFFFFF}%s desconectou e foi removido do ringue.", GetPlayerNameEx(playerid));
171
				SendClientMessage(i, 0x00FF33FF, STRING);
172
				/* strdel(STRING, 0, 12);
173
				printf("SUMO_SCRIPT: %s", STRING); */
174
			}
175
		}
176
	}
177
	return 1;
178
}
179
180
public OnClientUpdate()
181
{
182
	#if defined _foreach_included
183
	foreach (Player, i)
184
	#else
185
	for (new i = 0; i < MAX_PLAYERS; i++)
186
	#endif
187
	{
188
		if (IsPlayerInSumo(i))
189
		{
190
			if (g_PLAYERS_TOTAL > 0 && GetPVarInt(i,"SumoAFK") < 15){ AddPlayerSumoTime(i, 1); }
191
			new
192
				SUMO_TIME[18],
193
				TEXT_TIME[90],
194
				Float:pPos[3];
195
			format(SUMO_TIME, sizeof SUMO_TIME, "%d {FFFFFF}/ 500", GetPlayerSumoTime(i));
196
			SetPlayerChatBubble(i, SUMO_TIME, 0x00FF33FF, 50.0, 1500);
197
			format(TEXT_TIME, sizeof TEXT_TIME, "~n~~n~~n~~n~~n~~n~~n~~n~                                           ~g~~h~~h~%i ~w~/ 500", GetPlayerSumoTime(i));
198
			GameTextForPlayer(i, TEXT_TIME, 2000, 3);
199
			GetPlayerPos(i, pPos[0], pPos[1], pPos[2]);
200
			if (GetPVarFloat(i,"SumoX") != pPos[0] || GetPVarFloat(i,"SumoY") != pPos[1] || GetPVarFloat(i,"SumoZ") != pPos[2])
201
			{// Caso o jogador ficar ausente
202
				SetPVarFloat(i, "SumoX", pPos[0]);
203
				SetPVarFloat(i, "SumoY", pPos[1]);
204
				SetPVarFloat(i, "SumoZ", pPos[2]);
205
				SetPVarInt(i, "SumoAFK", 0);
206
			}
207
			else
208
			{
209
				SetPVarInt(i, "SumoAFK", GetPVarInt(i,"SumoAFK")+1);
210
				if (GetPVarInt(i,"SumoAFK") == 15)
211
				{
212
					new
213
						SUMO_STRING[73];
214
					format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s está ausente e não ganhará pontos.", GetPlayerNameEx(i));
215
					#if defined _foreach_included
216
						foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
217
					#else
218
						for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
219
					#endif
220
				}
221
			}
222
			new
223
				Float:Saude;
224
			GetPlayerHealth(i, Saude);
225
			if (Saude < 1)
226
			{// Caso o jogador morrer
227
				return 1;
228
			}
229
			if (pPos[2] < 25.0)
230
			{// Caso o jogador cair do ringue
231
				new
232
					SUMO_STRING[55],
233
					RAND = random(sizeof(SUMO_SPAWNS)),
234
					RANDCARS = random(sizeof(SUMO_CARS));
235
				format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s caiu do ringue.", GetPlayerNameEx(i));
236
				#if defined _foreach_included
237
					foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
238
				#else
239
					for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
240
				#endif
241
				SetPlayerSumoTime(i, 0);
242
				CreateVehicleEx(i, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
243
				PutPlayerInVehicle(i, g_SPAWNED_VEHICLE[i], 0);
244
				return 1;
245
			}
246
			if (GetPlayerState(i) != PLAYER_STATE_DRIVER && !GetPVarInt(i, "FirstSumo"))
247
			{// Caso o jogador sair do carro
248
				new
249
					SUMO_STRING[53],
250
					RAND = random(sizeof(SUMO_SPAWNS)),
251
					RANDCARS = random(sizeof(SUMO_CARS));
252
				format(SUMO_STRING, sizeof(SUMO_STRING), "[X]{FFFFFF} %s saiu do carro.", GetPlayerNameEx(i));
253
				#if defined _foreach_included
254
					foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
255
				#else
256
					for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
257
				#endif
258
				SetPlayerSumoTime(i, 0);
259
				CreateVehicleEx(i, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
260
				PutPlayerInVehicle(i, g_SPAWNED_VEHICLE[i], 0);
261
				return 1;
262
			}
263
			if (GetPlayerSumoTime(i) == 399)
264
			{// Caso o jogador obter 400segundos sem cair
265
				new
266
					SUMO_STRING[70];
267
				format(SUMO_STRING, sizeof SUMO_STRING, "[X]{FFFFFF} %s está quase vencendo, derrube-o!", GetPlayerNameEx(i));
268
				#if defined _foreach_included
269
					foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS) && OTHERS != i){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
270
				#else
271
					for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS) && OTHERS != i){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING);}}
272
				#endif
273
				SendClientMessage(i, 0x00FF33FF, "[X]{FFFFFF} Você está quase vencendo!");
274
			}
275
			if (GetPlayerSumoTime(i) == 499)
276
			{// Caso o jogador obter 500segundos sem cair
277
				SendClientMessage(i, 0x00FF33FF, "[X]{FFFFFF} Você venceu o jogo e ganhou $6000!");
278
				GivePlayerMoney(i, 6000);
279
				new
280
					SUMO_STRING[60];
281
				format(SUMO_STRING, sizeof SUMO_STRING, "[X]{FFFFFF} %s é o vencedor do sumo.", GetPlayerNameEx(i));
282
				#if defined _foreach_included
283
					foreach (Player, OTHERS){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING); SetPlayerSumoTime(OTHERS, 0);}}
284
				#else
285
					for (new OTHERS = 0; OTHERS < MAX_PLAYERS; OTHERS++){if (IsPlayerInSumo(OTHERS)){SendClientMessage(OTHERS, 0x00FF33FF, SUMO_STRING); SetPlayerSumoTime(OTHERS, 0);}}
286
				#endif
287
			}
288
		}
289
	}
290
	return 1;
291
}
292
293
public CreateSumoVehicle(playerid)
294
{
295
	new
296
		RAND = random(sizeof(SUMO_SPAWNS)),
297
		RANDCARS = random(sizeof(SUMO_CARS));
298
	CreateVehicleEx(playerid, SUMO_CARS[RANDCARS][0], SUMO_SPAWNS[RAND][0], SUMO_SPAWNS[RAND][1], SUMO_SPAWNS[RAND][2], SUMO_SPAWNS[RAND][3]+5, -1, -1);
299
	PutPlayerInVehicle(playerid, g_SPAWNED_VEHICLE[playerid], 0);
300
	if (GetPVarInt(playerid, "FirstSumo")) DeletePVar(playerid, "FirstSumo");
301
}
302
303
CMD:sumo( playerid, params[] )
304
{
305
	if (IsPlayerInSumo(playerid))
306
	{
307
		SetPlayerSumo(playerid, 0);
308
		SetPlayerSumoTime(playerid, 0);
309
		g_PLAYERS_TOTAL--;
310
		SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} Você saiu do jogo: \"{00FF33}Sumo{FFFFFF}\"");
311
		SetPlayerPos(playerid, 1642.3619, -2333.0234, 13.5469);
312
		SetPlayerFacingAngle(playerid, 356.8151);
313
		SetCameraBehindPlayer(playerid);
314
		DestroyVehicle(g_SPAWNED_VEHICLE[playerid]);
315
	}
316
	else
317
	{
318
		g_PLAYERS_TOTAL++;
319
		SetPlayerPos(playerid, 2924.0842,-3189.0569,102.2883);
320
		SetPlayerFacingAngle(playerid, 174.5274);
321
		SetTimerEx("CreateSumoVehicle", 1200, false, "i", playerid);
322
		SetPlayerInterior(playerid, 0);
323
		SetPlayerVirtualWorld(playerid, 0);
324
		SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} Você agora está jogando: \"{00FF33}Sumo{FFFFFF}\"");
325
		SetPlayerSumo(playerid, 1);
326
		SetPVarInt(playerid, "FirstSumo", 1);
327
	}
328
	return 1;	
329
}
330
331
CMD:sumotime( playerid, params[] )
332
{
333
	if (!IsPlayerInSumo(playerid))
334
		return SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} Você não está no ringue.");
335
	new
336
		e_STRING[61];
337
	format(e_STRING, sizeof e_STRING, "[X]{FFFFFF} Seu tempo no sumo é de {00FF33}%d{FFFFFF}/500.", GetPlayerSumoTime(playerid));	
338
	SendClientMessage(playerid, 0x00FF33FF, e_STRING);
339
	return 1;	
340
}
341
342
CMD:sumoplayers( playerid, params[] )
343
{
344
	new
345
		e_STRING[70];
346
	format(e_STRING, sizeof e_STRING, "[X]{FFFFFF} Jogadores atualmente no sumo {00FF33}%d{FFFFFF}/%i.", g_PLAYERS_TOTAL, GetMaxPlayers());
347
	SendClientMessage(playerid, 0x00FF33FF, e_STRING);
348
	return 1;
349
}
350
351
CMD:ajudasumo( playerid, params[] )
352
	return SendClientMessage(playerid, 0x00FF33FF, "[X]{FFFFFF} /sumo - /sumotime - /sumoplayers");