Advertisement
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
- new Players[MAX_PLAYERS] = {-1, ...};
- new players;
- #define foreachTriga(%0) for(new ouf, %0=Players[ouf]; ouf <players; %0=Players[++ouf])
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Стример на pawn 0.1 by Caypen");
- 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;
- 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();
- if(rands == INVALID_OBJECT_ID) return INVALID_OBJECT_ID;
- 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;
- //CreatePlayerObject(playerid, modelid, X, Y, Z, rX, rY, rZ, DrawDistance)
- if(DynObjects < 1) { timerupdate = SetTimer("UpdateObjects",2000,1); }
- DynObjects ++;
- return rands;
- }
- new bool:Created[MAX_PLAYERS][MAX_DYN_OBJECTS];
- forward UpdateObjects();
- public UpdateObjects()
- {
- for(new obj = 0;obj < DynObjects;obj++)
- {
- if(Oinf[obj][used] == 0) continue;
- foreachTriga(player)
- {
- 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--;
- if(DynObjects < 1) { KillTimer(timerupdate); }
- return true;
- }
- public OnPlayerConnect(playerid)
- {
- if(IsPlayerNPC(playerid))return true;
- Players[players++]=playerid;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(IsPlayerNPC(playerid)) return true;
- for(new i=0;i<players;i++)
- {
- if(Players[i]==playerid)
- {
- Players[i]=Players[--players];
- Players[players]=-1;
- break;
- }
- }
- for(new obj = 0;obj < DynObjects;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
Advertisement