Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #define MAX_DYN_OBJECTS 1000
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Streamer на Pawn by Caypen v0.1.2");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- new DynObjects;
- enum ObjInf
- {
- modelid2,
- used,
- Float:X2,
- Float:Y2,
- Float:Z2,
- Float:rX2,
- Float:rY2,
- Float:rZ2,
- Float:DrawDistance2
- };
- new Oinf[MAX_DYN_OBJECTS][ObjInf];
- new timerupdate[MAX_PLAYERS];
- CreateDynObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance = 0.0)
- {
- if(DynObjects >= MAX_DYN_OBJECTS-1) return INVALID_OBJECT_ID;
- new rands = AddObject();
- Oinf[rands][modelid2] = modelid;
- Oinf[rands][X2] = X;
- Oinf[rands][Y2] = Y;
- Oinf[rands][Z2] = Z;
- Oinf[rands][rX2] = rX;
- Oinf[rands][rY2] = rY;
- Oinf[rands][rZ2] = rZ;
- Oinf[rands][DrawDistance2] = DrawDistance;
- DynObjects ++;
- return rands;
- }
- new bool:Created[MAX_PLAYERS][MAX_DYN_OBJECTS];
- forward UpdateObjects(player);
- public UpdateObjects(player)
- {
- for(new obj = 0;obj < MAX_DYN_OBJECTS;obj++)
- {
- if(Oinf[obj][used] == 0) continue;
- if(IsPlayerInRangeOfPoint(player,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
- {
- if(Created[player][obj] == false)
- {
- 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]);
- Created[player][obj] = true;
- }
- }
- else
- {
- if(Created[player][obj] == true)
- {
- DestroyPlayerObject(player, obj);
- Created[player][obj] = false;
- }
- }
- }
- return true;
- }
- AddObject()
- {
- for(new rands = 0;rands < MAX_DYN_OBJECTS;rands++)
- {
- if(Oinf[rands][used] == 0)
- {
- Oinf[rands][used] = 1;
- return rands;
- }
- }
- return INVALID_OBJECT_ID;
- }
- stock DestroyDynObject(objectid)
- {
- Oinf[objectid][used] = 0;
- Oinf[objectid][modelid2] = -1;
- Oinf[objectid][X2] = -1;
- Oinf[objectid][Y2] = -1;
- Oinf[objectid][Z2] = -1;
- Oinf[objectid][rX2] = -1;
- Oinf[objectid][rY2] = -1;
- Oinf[objectid][rZ2] = -1;
- Oinf[objectid][DrawDistance2] = -1;
- DynObjects--;
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- if(IsPlayerNPC(playerid))return true;
- timerupdate[playerid] = SetTimerEx("UpdateObjects", 2000, true, "i", playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(IsPlayerNPC(playerid)) return true;
- KillTimer(timerupdate[playerid]);
- for(new obj = 0;obj < MAX_DYN_OBJECTS;obj++)
- {
- if(Oinf[obj][used] == 0) continue;
- if(IsPlayerInRangeOfPoint(playerid,Oinf[obj][DrawDistance2],Oinf[obj][X2],Oinf[obj][Y2],Oinf[obj][Z2]))
- {
- if(Created[playerid][obj] == true)
- {
- DestroyPlayerObject(playerid, obj);
- Created[playerid][obj] = false;
- }
- }
- Created[playerid][obj] = false;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment