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(" Стример на pawn 0.1 by Caypen"); | |
15 | print("--------------------------------------\n"); | |
16 | return 1; | |
17 | } | |
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 | if(rands == INVALID_OBJECT_ID) return INVALID_OBJECT_ID; | |
43 | Oinf[rands][modelid2] = modelid; | |
44 | Oinf[rands][X2] = X; | |
45 | Oinf[rands][Y2] = Y; | |
46 | Oinf[rands][Z2] = Z; | |
47 | Oinf[rands][rX2] = rX; | |
48 | Oinf[rands][rY2] = rY; | |
49 | Oinf[rands][rZ2] = rZ; | |
50 | Oinf[rands][DrawDistance2] = DrawDistance; | |
51 | //CreatePlayerObject(playerid, modelid, X, Y, Z, rX, rY, rZ, DrawDistance) | |
52 | if(DynObjects < 1) { timerupdate = SetTimer("UpdateObjects",2000,1); } | |
53 | DynObjects ++; | |
54 | return rands; | |
55 | } | |
56 | new bool:Created[MAX_PLAYERS][MAX_DYN_OBJECTS]; | |
57 | forward UpdateObjects(); | |
58 | public UpdateObjects() | |
59 | { | |
60 | for(new obj = 0;obj < DynObjects;obj++) | |
61 | { | |
62 | if(Oinf[obj][used] == 0) continue; | |
63 | foreachTriga(player) | |
64 | { | |
65 | if(IsPlayerInRangeOfPoint(player,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2])) | |
66 | { | |
67 | if(Created[player][obj] == false) | |
68 | { | |
69 | 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]); | |
70 | Created[player][obj] = true; | |
71 | } | |
72 | } | |
73 | else | |
74 | { | |
75 | if(Created[player][obj] == true) | |
76 | { | |
77 | DestroyPlayerObject(player, obj); | |
78 | Created[player][obj] = false; | |
79 | } | |
80 | } | |
81 | } | |
82 | } | |
83 | return true; | |
84 | } | |
85 | AddObject() | |
86 | { | |
87 | for(new rands = 0;rands < MAX_DYN_OBJECTS;rands++) | |
88 | { | |
89 | if(Oinf[rands][used] == 0) | |
90 | { | |
91 | Oinf[rands][used] = 1; | |
92 | return rands; | |
93 | } | |
94 | } | |
95 | return INVALID_OBJECT_ID; | |
96 | } | |
97 | stock DestroyDynObject(objectid) | |
98 | { | |
99 | Oinf[objectid][used] = 0; | |
100 | Oinf[objectid][modelid2] = -1; | |
101 | Oinf[objectid][X2] = -1; | |
102 | Oinf[objectid][Y2] = -1; | |
103 | Oinf[objectid][Z2] = -1; | |
104 | Oinf[objectid][rX2] = -1; | |
105 | Oinf[objectid][rY2] = -1; | |
106 | Oinf[objectid][rZ2] = -1; | |
107 | Oinf[objectid][DrawDistance2] = -1; | |
108 | DynObjects--; | |
109 | if(DynObjects < 1) { KillTimer(timerupdate); } | |
110 | return true; | |
111 | } | |
112 | public OnPlayerConnect(playerid) | |
113 | { | |
114 | if(IsPlayerNPC(playerid))return true; | |
115 | Players[players++]=playerid; | |
116 | return 1; | |
117 | } | |
118 | ||
119 | public OnPlayerDisconnect(playerid, reason) | |
120 | { | |
121 | if(IsPlayerNPC(playerid)) return true; | |
122 | for(new i=0;i<players;i++) | |
123 | { | |
124 | if(Players[i]==playerid) | |
125 | { | |
126 | Players[i]=Players[--players]; | |
127 | Players[players]=-1; | |
128 | break; | |
129 | } | |
130 | } | |
131 | for(new obj = 0;obj < DynObjects;obj++) | |
132 | { | |
133 | if(Oinf[obj][used] == 0) continue; | |
134 | if(IsPlayerInRangeOfPoint(playerid,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2])) | |
135 | { | |
136 | if(Created[playerid][obj] == true) | |
137 | { | |
138 | DestroyPlayerObject(playerid, obj); | |
139 | Created[playerid][obj] = false; | |
140 | } | |
141 | } | |
142 | Created[playerid][obj] = false; | |
143 | } | |
144 | return 1; | |
145 | } |