View difference between Paste ID: UTLj3FCV and 2xySi7Xw
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
new Players[MAX_PLAYERS] = {-1, ...};
8
new players;
9
#define foreachTriga(%0) for(new ouf, %0=Players[ouf]; ouf <players; %0=Players[++ouf])
10
11
public OnFilterScriptInit()
12
{
13
	print("\n--------------------------------------");
14-
	print(" Blank Filterscript by your name here");
14+
	print(" Стример на pawn 0.1 by Caypen");
15
	print("--------------------------------------\n");
16-
	for(new rands = 0;rands < MAX_DYN_OBJECTS;rands++)
16+
17
}
18-
		CreateDynObject(rands, 2001.195679, 1547.113892, 14.283400, 0, 0, 96);
18+
19
public OnFilterScriptExit()
20
{
21
	return 1;
22
}
23
new DynObjects;
24
enum ObjInf
25
{
26
	modelid2,
27
	used,
28
	Float:X2,
29
	Float:Y2,
30
	Float:Z2,
31
	Float:rX2,
32
	Float:rY2,
33
	Float:rZ2,
34
	Float:DrawDistance2
35
};
36
new Oinf[MAX_DYN_OBJECTS][ObjInf];
37
new timerupdate;
38
CreateDynObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance = 0.0)
39
{
40
	if(DynObjects >= MAX_DYN_OBJECTS-1) return INVALID_OBJECT_ID;
41
	new rands = AddObject();
42
	Oinf[rands][modelid2] = modelid;
43
	Oinf[rands][X2] = X;
44
	Oinf[rands][Y2] = Y;
45
	Oinf[rands][Z2] = Z;
46
	Oinf[rands][rX2] = rX;
47
	Oinf[rands][rY2] = rY;
48
	Oinf[rands][rZ2] = rZ;
49
	Oinf[rands][DrawDistance2] = DrawDistance;
50
	//CreatePlayerObject(playerid, modelid, X, Y, Z, rX, rY, rZ, DrawDistance)
51
	if(DynObjects < 1) { timerupdate = SetTimer("UpdateObjects",2000,1); }
52
	DynObjects ++;
53
	return rands;
54
}
55
new bool:Created[MAX_PLAYERS][MAX_DYN_OBJECTS];
56
forward UpdateObjects();
57
public UpdateObjects()
58
{
59
    for(new obj = 0;obj < DynObjects;obj++)
60
    {
61
        if(Oinf[obj][used] == 0) continue;
62
        foreachTriga(player)
63
        {
64
        	if(IsPlayerInRangeOfPoint(player,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
65
        	{
66
        	    if(Created[player][obj] == false)
67
        	    {
68
        	        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]);
69
        	        Created[player][obj] = true;
70
        	    }
71
        	}
72
        	else
73
        	{
74
    	    	if(Created[player][obj] == true)
75
        	    {
76
        	        DestroyPlayerObject(player, obj);
77
        	        Created[player][obj] = false;
78
        	    }
79
        	}
80
        }
81
    }
82
    return true;
83
}
84
AddObject()
85
{
86
    for(new rands = 0;rands < MAX_DYN_OBJECTS;rands++)
87
    {
88
    	if(Oinf[rands][used] == 0)
89
    	{
90
    	    Oinf[rands][used] = 1;
91
    	    return rands;
92
    	}
93
   	}
94
   	return INVALID_OBJECT_ID;
95
}
96
stock DestroyDynObject(objectid)
97
{
98
    Oinf[objectid][used] = 0;
99
	Oinf[objectid][modelid2] = -1;
100
	Oinf[objectid][X2] = -1;
101
	Oinf[objectid][Y2] = -1;
102
	Oinf[objectid][Z2] = -1;
103
	Oinf[objectid][rX2] = -1;
104
	Oinf[objectid][rY2] = -1;
105
	Oinf[objectid][rZ2] = -1;
106
	Oinf[objectid][DrawDistance2] = -1;
107
	DynObjects--;
108
	if(DynObjects < 1) { KillTimer(timerupdate); }
109
	return true;
110
}
111
public OnPlayerConnect(playerid)
112
{
113
	if(IsPlayerNPC(playerid))return true;
114
	Players[players++]=playerid;
115
	return 1;
116
}
117
118
public OnPlayerDisconnect(playerid, reason)
119
{
120
	if(IsPlayerNPC(playerid)) return true;
121
	for(new i=0;i<players;i++)
122
	{
123
		if(Players[i]==playerid)
124
		{
125
			Players[i]=Players[--players];
126
			Players[players]=-1;
127
			break;
128
		}
129
	}
130
 	for(new obj = 0;obj < DynObjects;obj++)
131
    {
132
        if(Oinf[obj][used] == 0) continue;
133
       	if(IsPlayerInRangeOfPoint(playerid,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
134
       	{
135
  	    	if(Created[playerid][obj] == true)
136
   	    	{
137
	        	DestroyPlayerObject(playerid, obj);
138
 	        	Created[playerid][obj] = false;
139
        	}
140
        }
141
        Created[playerid][obj] = false;
142
    }
143
	return 1;
144
}