View difference between Paste ID: Z26eU4c4 and u1S2cDL7
SHOW: | | - or go back to the newest paste.
1
// This is a comment
2
// uncomment the line below if you want to write a filterscript
3
//#define FILTERSCRIPT
4
5
#include <a_samp>
6
#define MAX_DYN_OBJECTS 1000
7
8
public OnFilterScriptInit()
9
{
10
	print("\n--------------------------------------");
11-
	print(" Streamer на Pawn by Caypen v0.1.2");
11+
	print(" Streamer на Pawn by Caypen v0.1.3");
12
	print("--------------------------------------\n");
13
	return 1;
14
}
15
16
public OnFilterScriptExit()
17
{
18
	return 1;
19
}
20
new DynObjects;
21
enum ObjInf
22
{
23-
	modelid2,
23+
	stream_modelid2,
24-
	used,
24+
Float:stream_X2,
25-
Float:X2,
25+
Float:stream_Y2,
26-
Float:Y2,
26+
Float:stream_Z2,
27-
Float:Z2,
27+
Float:rstream_X2,
28-
Float:rX2,
28+
Float:rstream_Y2,
29-
Float:rY2,
29+
Float:rstream_Z2,
30-
Float:rZ2,
30+
Float:stream_DrawDistance2
31-
Float:DrawDistance2
31+
32
new Oinf[MAX_DYN_OBJECTS][ObjInf];
33
new timerupdate[MAX_PLAYERS];
34
CreateDynObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance = 0.0)
35
{
36
	if(DynObjects >= MAX_DYN_OBJECTS-1) return INVALID_OBJECT_ID;
37
	new rands = AddObject();
38
	Oinf[rands][stream_modelid2] = modelid;
39-
	Oinf[rands][modelid2] = modelid;
39+
	Oinf[rands][stream_X2] = X;
40-
	Oinf[rands][X2] = X;
40+
	Oinf[rands][stream_Y2] = Y;
41-
	Oinf[rands][Y2] = Y;
41+
	Oinf[rands][stream_Z2] = Z;
42-
	Oinf[rands][Z2] = Z;
42+
	Oinf[rands][rstream_X2] = rX;
43-
	Oinf[rands][rX2] = rX;
43+
	Oinf[rands][rstream_Y2] = rY;
44-
	Oinf[rands][rY2] = rY;
44+
	Oinf[rands][rstream_Z2] = rZ;
45-
	Oinf[rands][rZ2] = rZ;
45+
	Oinf[rands][stream_DrawDistance2] = DrawDistance;
46-
	Oinf[rands][DrawDistance2] = DrawDistance;
46+
47
	return rands;
48
}
49
static streamer__CreatedForPlayerFlag[MAX_PLAYERS][MAX_DYN_OBJECTS char];
50-
new bool:Created[MAX_PLAYERS][MAX_DYN_OBJECTS];
50+
51
public UpdateObjects(player)
52
{
53
	for(new obj = 0;obj < MAX_DYN_OBJECTS;obj++)
54
	{
55
		if(Oinf[obj][stream_modelid2] == 0) continue;
56-
		if(Oinf[obj][used] == 0) continue;
56+
		if(IsPlayerInRangeOfPoint(player,Oinf[obj][stream_DrawDistance2],Oinf[obj][stream_X2],Oinf[obj][stream_Y2],Oinf[obj][stream_Z2]))
57-
		if(IsPlayerInRangeOfPoint(player,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
57+
58
			if(streamer__CreatedForPlayerFlag[player][obj] == 0)
59-
			if(Created[player][obj] == false)
59+
60
				CreatePlayerObject(player, Oinf[obj][stream_modelid2], Oinf[obj][stream_X2],Oinf[obj][stream_Y2],Oinf[obj][stream_Z2], Oinf[obj][rstream_X2],Oinf[obj][rstream_Y2],Oinf[obj][rstream_Z2], Oinf[obj][stream_DrawDistance2]);
61-
				CreatePlayerObject(player, Oinf[obj][modelid2], Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2], Oinf[obj][rX2],Oinf[obj][rY2],Oinf[obj][rZ2], Oinf[obj][DrawDistance2]);
61+
				streamer__CreatedForPlayerFlag[player][obj] = 1;
62-
				Created[player][obj] = true;
62+
63
		}
64
		else
65
		{
66
			if(streamer__CreatedForPlayerFlag[player][obj] == 1)
67-
			if(Created[player][obj] == true)
67+
68
				DestroyPlayerObject(player, obj);
69
				streamer__CreatedForPlayerFlag[player][obj] = 0;
70-
				Created[player][obj] = false;
70+
71
		}
72
	}
73
	return 1;
74-
	return true;
74+
75
AddObject()
76
{
77
	for(new rands = 0;rands < MAX_DYN_OBJECTS;rands++)
78
	{
79
		if(Oinf[rands][stream_modelid2] == 0)
80-
		if(Oinf[rands][used] == 0)
80+
81
			return rands;
82-
			Oinf[rands][used] = 1;
82+
83
	}
84
	return INVALID_OBJECT_ID;
85
}
86
stock DestroyDynObject(objectid)
87
{
88
	Oinf[objectid][stream_modelid2] = 0;
89
	Oinf[objectid][stream_X2] = -1;
90-
	Oinf[objectid][used] = 0;
90+
	Oinf[objectid][stream_Y2] = -1;
91-
	Oinf[objectid][modelid2] = -1;
91+
	Oinf[objectid][stream_Z2] = -1;
92-
	Oinf[objectid][X2] = -1;
92+
	Oinf[objectid][rstream_X2] = -1;
93-
	Oinf[objectid][Y2] = -1;
93+
	Oinf[objectid][rstream_Y2] = -1;
94-
	Oinf[objectid][Z2] = -1;
94+
	Oinf[objectid][rstream_Z2] = -1;
95-
	Oinf[objectid][rX2] = -1;
95+
	Oinf[objectid][stream_DrawDistance2] = -1;
96-
	Oinf[objectid][rY2] = -1;
96+
97-
	Oinf[objectid][rZ2] = -1;
97+
98-
	Oinf[objectid][DrawDistance2] = -1;
98+
99
public OnPlayerConnect(playerid)
100-
	return true;
100+
101
	if(IsPlayerNPC(playerid))return 1;
102
	timerupdate[playerid] = SetTimerEx("UpdateObjects", 2000, 1, "i", playerid);
103
	return 1;
104-
	if(IsPlayerNPC(playerid))return true;
104+
105-
	timerupdate[playerid] = SetTimerEx("UpdateObjects", 2000, true, "i", playerid);
105+
106
public OnPlayerDisconnect(playerid, reason)
107
{
108
	if(IsPlayerNPC(playerid)) return 1;
109
	KillTimer(timerupdate[playerid]);
110
	for(new obj = 0;obj < MAX_DYN_OBJECTS;obj++)
111-
	if(IsPlayerNPC(playerid)) return true;
111+
112
		if(Oinf[obj][stream_modelid2] == 0) continue;
113
		if(IsPlayerInRangeOfPoint(playerid,Oinf[obj][stream_DrawDistance2],Oinf[obj][stream_X2],Oinf[obj][stream_Y2],Oinf[obj][stream_Z2]))
114
		{
115-
		if(Oinf[obj][used] == 0) continue;
115+
			if(streamer__CreatedForPlayerFlag[playerid][obj] == 1)
116-
		if(IsPlayerInRangeOfPoint(playerid,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
116+
117
				DestroyPlayerObject(playerid, obj);
118-
			if(Created[playerid][obj] == true)
118+
				streamer__CreatedForPlayerFlag[playerid][obj] = 0;
119
			}
120
		}
121-
				Created[playerid][obj] = false;
121+
		streamer__CreatedForPlayerFlag[playerid][obj] = 0;
122
	}
123
	return 1;
124-
		Created[playerid][obj] = false;
124+