Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------------------------------------------------
- Rmarkers Created by Killa[DGZ]
- RMarkers Use Fallout's Object Streamer Created by: Fallout v0.5
- Special thanks to fallout for permission to use his Streamer
- Double-O-Icons by Double-O-Seven for file size reduction from 1Mb to 156K?,
- and i have no idea what else it does but it seems works better with it!
- ------------------------------------------------------------------------------*/
- #define FILTERSCRIPT
- #include <a_samp>
- #include <Double-O-Icons> // < dont ask why this is here but leave it
- #define GREY 0xAFAFAFAA
- #define RED 0xAA3333AA
- #if defined FILTERSCRIPT
- #define F_MAX_OBJECTS 1000
- #define UpdateTime 300 //update time in ms (milliseconds).
- #define ObjectsToStream 300
- #define StreamRange 350.0
- #pragma dynamic 30000
- #define MAX_REDMARKERS 1000
- #define MAX_FLASHMARKERS 1000
- forward F_ObjectUpdate(bool:DontCheckDistance);
- forward F_StartUpdate();
- enum redSpot
- {
- Redmarker,
- Float:redmX,
- Float:redmY,
- Float:redmZ,
- rmObject,
- };
- new Markcord[MAX_REDMARKERS][redSpot];
- enum flashSpot
- {
- Flashmarker,
- Float:flamX,
- Float:flamY,
- Float:flamZ,
- flObject,
- };
- new Markcords[MAX_FLASHMARKERS][flashSpot];
- enum OInfo
- {
- ModelID,
- ObjectID[MAX_PLAYERS],
- Float:ox,
- Float:oy,
- Float:oz,
- Float:orox,
- Float:oroy,
- Float:oroz,
- Float:ovdist,
- bool:ObjectCreated[MAX_PLAYERS],
- };
- new ObjectInfo[F_MAX_OBJECTS][OInfo];
- new bool:ObjectUpdatetRunning;
- new bool:CantCreateMore;
- new bool:RefreshObjects[MAX_PLAYERS];
- new Float:OldX[MAX_PLAYERS], Float:OldY[MAX_PLAYERS], Float:OldZ[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" RMarkers By Killa[DGZ] ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, RED,"* RMarkers, Type: /markerhelp for more info *");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp(cmdtext,"/markerhelp",true) == 0)
- {
- SendClientMessage(playerid, RED," * Red Markers *");
- SendClientMessage(playerid, GREY,"* Type: /redmarker or /rm to place a red marker *");
- SendClientMessage(playerid, GREY,"* Type: /deleteclosestredmarker or /dcrm to delete the red marker closest to you *");
- SendClientMessage(playerid, GREY,"* Type: /deleteallredmarkers or /dallrm to delete all red markers *");
- SendClientMessage(playerid, RED," * Flash Markers *");
- SendClientMessage(playerid, GREY,"* Type: /flashmarker or /fm to place a flash marker *");
- SendClientMessage(playerid, GREY,"* Type: /deleteclosestflashmarker or /dcfm to delete the flash marker closest to you *");
- SendClientMessage(playerid, GREY,"* Type: /deleteallflashmarkers or /dallfm to delete all flash markers *");
- SendClientMessage(playerid, GREY,"* Type: /markercredits for the Filterscript credits *");
- return 1;
- }
- if (strcmp(cmdtext,"/markercredits",true) == 0)
- {
- SendClientMessage(playerid, RED," * Marker Credits *");
- SendClientMessage(playerid, GREY,"* RMarkers Was Created By Killa[DGZ] 16-09-2010 *");
- SendClientMessage(playerid, GREY,"* This [FS] uses Fallout's Object Streamer Created by Fallout *");
- SendClientMessage(playerid, GREY,"* This [FS] uses Double-O-Icons by Double-O-Seven *");
- return 1;
- }
- if(strcmp(cmdtext, "/redmarker", true) == 0 || strcmp(cmdtext, "/rm", true) == 0)
- {
- new Float:plocx,Float:plocy,Float:plocz;
- GetPlayerPos(playerid, plocx, plocy, plocz);
- CreateRMarker(plocx,plocy,plocz);
- return 1;
- }
- if(strcmp(cmdtext, "/deleteclosestredmarker", true) == 0 || strcmp(cmdtext, "/dcrm", true) == 0)
- {
- DeleteClosestRMarker(playerid);
- return 1;
- }
- if(strcmp(cmdtext, "/deleteallredmarkers", true) == 0 || strcmp(cmdtext, "/dallrm", true) == 0)
- {
- DeleteAllRMarker();
- return 1;
- }
- if(strcmp(cmdtext, "/flashmarker", true) == 0 || strcmp(cmdtext, "/fm", true) == 0)
- {
- new Float:plocx,Float:plocy,Float:plocz;
- GetPlayerPos(playerid, plocx, plocy, plocz);
- CreateFMarker(plocx,plocy,plocz);
- return 1;
- }
- if(strcmp(cmdtext, "/deleteclosestflashmarker", true) == 0 || strcmp(cmdtext, "/dcfm", true) == 0)
- {
- DeleteClosestFMarker(playerid);
- return 1;
- }
- if(strcmp(cmdtext, "/deleteallflashmarkers", true) == 0 || strcmp(cmdtext, "/dallfm", true) == 0)
- {
- DeleteAllFMarker();
- return 1;
- }
- return 0;
- }
- public F_StartUpdate()
- {
- SetTimer("F_ObjectUpdate", UpdateTime, 1);
- }
- stock F_CreateObject(modelid, Float:x, Float:y, Float:z, Float:rox, Float:roy, Float:roz, Float:vdist=0.0)
- {
- if(ObjectUpdatetRunning == false)
- {
- SetTimer("F_StartUpdate", F_MAX_OBJECTS/2, 0);
- ObjectUpdatetRunning = true;
- }
- new objectid;
- if(CantCreateMore == false)
- {
- for(new i; i<F_MAX_OBJECTS; i++)
- {
- if(i == F_MAX_OBJECTS-1)
- {
- printf("Only the first %i objects could be created - object limit exceeded.", F_MAX_OBJECTS);
- CantCreateMore = true;
- }
- if(ObjectInfo[i][ModelID] == 0)
- {
- objectid = i;
- break;
- }
- }
- }
- else
- {
- return -1;
- }
- if(modelid == 0)
- {
- printf("Invalid modelid for object %i", objectid);
- return -1;
- }
- ObjectInfo[objectid][ModelID] = modelid;
- ObjectInfo[objectid][ox] = x;
- ObjectInfo[objectid][oy] = y;
- ObjectInfo[objectid][oz] = z;
- ObjectInfo[objectid][orox] = rox;
- ObjectInfo[objectid][oroy] = roy;
- ObjectInfo[objectid][oroz] = roz;
- ObjectInfo[objectid][ovdist] = vdist;
- return objectid;
- }
- stock F_IsValidObject(objectid)
- {
- if(ObjectInfo[objectid][ModelID] == 0 || objectid == -1)
- {
- return 0;
- }
- return 1;
- }
- stock F_DestroyObject(objectid)
- {
- if(F_IsValidObject(objectid))
- {
- for(new playerid; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid) && ObjectInfo[objectid][ObjectCreated][playerid] == true)
- {
- DestroyPlayerObject(playerid, ObjectInfo[objectid][ObjectID][playerid]);
- ObjectInfo[objectid][ObjectCreated][playerid] = false;
- }
- }
- ObjectInfo[objectid][ModelID] = 0;
- return 1;
- }
- return 0;
- }
- stock F_MoveObject(objectid, Float:x, Float:y, Float:z, Float:speed)
- {
- if(F_IsValidObject(objectid))
- {
- new time;
- for(new playerid; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid) && ObjectInfo[objectid][ObjectCreated][playerid] == true)
- {
- time = MovePlayerObject(playerid, ObjectInfo[objectid][ObjectID][playerid], x, y, z, speed);
- }
- }
- return time;
- }
- return 0;
- }
- stock F_StopObject(objectid)
- {
- if(F_IsValidObject(objectid))
- {
- for(new playerid; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid) && ObjectInfo[objectid][ObjectCreated][playerid] == true)
- {
- StopPlayerObject(playerid, ObjectInfo[objectid][ObjectID][playerid]);
- }
- }
- return 1;
- }
- return 0;
- }
- stock F_SetObjectPos(objectid, Float:x, Float:y, Float:z)
- {
- if(F_IsValidObject(objectid))
- {
- ObjectInfo[objectid][ox] = x;
- ObjectInfo[objectid][oy] = y;
- ObjectInfo[objectid][oz] = z;
- for(new playerid; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid) && ObjectInfo[objectid][ObjectCreated][playerid] == true)
- {
- SetPlayerObjectPos(playerid, ObjectInfo[objectid][ObjectID][playerid], x, y, z);
- }
- }
- return 1;
- }
- return 0;
- }
- stock F_GetObjectPos(objectid, &Float:x, &Float:y, &Float:z)
- {
- if(F_IsValidObject(objectid))
- {
- x = ObjectInfo[objectid][ox];
- y = ObjectInfo[objectid][oy];
- z = ObjectInfo[objectid][oz];
- return 1;
- }
- else
- {
- return 0;
- }
- }
- stock F_SetObjectRot(objectid, Float:rox, Float:roy, Float:roz)
- {
- if(F_IsValidObject(objectid))
- {
- ObjectInfo[objectid][orox] = rox;
- ObjectInfo[objectid][oroy] = roy;
- ObjectInfo[objectid][oroz] = roz;
- for(new playerid; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid) && ObjectInfo[objectid][ObjectCreated][playerid] == true)
- {
- SetPlayerObjectRot(playerid, ObjectInfo[objectid][ObjectID][playerid], rox, roy, roz);
- }
- }
- return 1;
- }
- return 0;
- }
- stock F_GetObjectRot(objectid, &Float:rox, &Float:roy, &Float:roz)
- {
- if(F_IsValidObject(objectid))
- {
- rox = ObjectInfo[objectid][orox];
- roy = ObjectInfo[objectid][oroy];
- roz = ObjectInfo[objectid][oroz];
- return 1;
- }
- else
- {
- return 0;
- }
- }
- stock F_RefreshObjects(playerid)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
- {
- RefreshObjects[playerid] = true;
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- F_PlayerObjectUpdate(playerid, x, y, z);
- return 1;
- }
- return 0;
- }
- stock F_Streamer_OnPlayerConnect(playerid)
- {
- for(new objectid; objectid<F_MAX_OBJECTS; objectid++)
- {
- ObjectInfo[objectid][ObjectCreated][playerid] = false;
- }
- OldX[playerid] = 999999999.99;
- OldY[playerid] = 999999999.99;
- OldZ[playerid] = 999999999.99;
- RefreshObjects[playerid] = false;
- return 1;
- }
- public F_ObjectUpdate(bool:DontCheckDistance)
- {
- new Float:ObjDistance[F_MAX_OBJECTS];
- new Closest[ObjectsToStream];
- new ObjectArr[F_MAX_OBJECTS];
- new nr;
- new bool:Firstloop;
- new bool:DontDestroy[F_MAX_OBJECTS];
- for(new playerid; playerid<MAX_PLAYERS; playerid++)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
- {
- if(!IsPlayerInRangeOfPoint(playerid, 1.0, OldX[playerid], OldY[playerid], OldZ[playerid]) || DontCheckDistance)
- {
- GetPlayerPos(playerid, OldX[playerid], OldY[playerid], OldZ[playerid]);
- nr = 0;
- for(new objectid; objectid<F_MAX_OBJECTS; objectid++)
- {
- if(F_IsValidObject(objectid))
- {
- ObjDistance[objectid] = floatsqroot(floatpower(floatsub(ObjectInfo[objectid][ox],OldX[playerid]),2)+floatpower(floatsub(ObjectInfo[objectid][oy],OldY[playerid]),2)+floatpower(floatsub(ObjectInfo[objectid][oz],OldZ[playerid]),2));
- if(floatcmp(ObjDistance[objectid], StreamRange) == -1)
- {
- ObjectArr[nr] = objectid;
- nr++;
- }
- }
- }
- Closest = "";
- if(nr > ObjectsToStream)
- {
- for(new loop; loop<ObjectsToStream; loop++)
- {
- Firstloop = true;
- for(new objectid; objectid<nr; objectid++)
- {
- if((ObjDistance[ObjectArr[objectid]] != 999999999.99) && ((floatcmp(ObjDistance[ObjectArr[objectid]], ObjDistance[Closest[loop]]) == -1) || Firstloop))
- {
- Firstloop = false;
- Closest[loop] = ObjectArr[objectid];
- }
- }
- ObjDistance[Closest[loop]] = 999999999.99;
- }
- }
- else
- {
- for(new objectid; objectid<nr; objectid++)
- {
- Closest[objectid] = ObjectArr[objectid];
- }
- }
- for(new objectid; objectid<F_MAX_OBJECTS; objectid++) { DontDestroy[objectid] = false; }
- for(new objectid; objectid<ObjectsToStream && objectid<nr; objectid++)
- {
- DontDestroy[Closest[objectid]] = true;
- }
- for(new objectid; objectid<F_MAX_OBJECTS; objectid++)
- {
- if(ObjectInfo[objectid][ObjectCreated][playerid] == true && DontDestroy[objectid] == false)
- {
- DestroyPlayerObject(playerid, ObjectInfo[objectid][ObjectID][playerid]);
- ObjectInfo[objectid][ObjectCreated][playerid] = false;
- }
- }
- for(new loop; loop<ObjectsToStream && loop<nr; loop++)
- {
- if(ObjectInfo[Closest[loop]][ObjectCreated][playerid] == false)
- {
- ObjectInfo[Closest[loop]][ObjectID][playerid] = CreatePlayerObject(playerid, ObjectInfo[Closest[loop]][ModelID], ObjectInfo[Closest[loop]][ox], ObjectInfo[Closest[loop]][oy], ObjectInfo[Closest[loop]][oz], ObjectInfo[Closest[loop]][orox], ObjectInfo[Closest[loop]][oroy], ObjectInfo[Closest[loop]][oroz], ObjectInfo[Closest[loop]][ovdist]);
- ObjectInfo[Closest[loop]][ObjectCreated][playerid] = true;
- }
- }
- }
- }
- }
- }
- stock F_ObjectUpdateForAll()
- {
- F_ObjectUpdate(true);
- }
- stock F_PlayerObjectUpdate(playerid, Float:x, Float:y, Float:z)
- {
- if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
- {
- OldX[playerid] = x;
- OldY[playerid] = y;
- OldZ[playerid] = z;
- new nr;
- new Float:ObjDistance[F_MAX_OBJECTS];
- new ObjectArr[F_MAX_OBJECTS];
- for(new objectid; objectid<F_MAX_OBJECTS; objectid++)
- {
- if(F_IsValidObject(objectid))
- {
- ObjDistance[objectid] = floatsqroot(floatpower(floatsub(ObjectInfo[objectid][ox],x),2)+floatpower(floatsub(ObjectInfo[objectid][oy],y),2)+floatpower(floatsub(ObjectInfo[objectid][oz],z),2));
- if(floatcmp(ObjDistance[objectid], StreamRange) == -1)
- {
- ObjectArr[nr] = objectid;
- nr++;
- }
- }
- }
- new Closest[ObjectsToStream];
- if(nr > ObjectsToStream)
- {
- for(new loop; loop<ObjectsToStream; loop++)
- {
- new bool:Firstloop = true;
- for(new objectid; objectid<nr; objectid++)
- {
- if((ObjDistance[ObjectArr[objectid]] != 999999999.99) && ((floatcmp(ObjDistance[ObjectArr[objectid]], ObjDistance[Closest[loop]]) == -1) || Firstloop))
- {
- Firstloop = false;
- Closest[loop] = ObjectArr[objectid];
- }
- }
- ObjDistance[Closest[loop]] = 999999999.99;
- }
- }
- else
- {
- for(new objectid; objectid<nr; objectid++)
- {
- Closest[objectid] = ObjectArr[objectid];
- }
- }
- new bool:DontDestroy[F_MAX_OBJECTS];
- for(new objectid; objectid<ObjectsToStream && objectid<nr; objectid++)
- {
- DontDestroy[Closest[objectid]] = true;
- }
- for(new objectid; objectid<F_MAX_OBJECTS; objectid++)
- {
- if(ObjectInfo[objectid][ObjectCreated][playerid] == true && (DontDestroy[objectid] == false || RefreshObjects[playerid] == true))
- {
- DestroyPlayerObject(playerid, ObjectInfo[objectid][ObjectID][playerid]);
- ObjectInfo[objectid][ObjectCreated][playerid] = false;
- }
- }
- RefreshObjects[playerid] = false;
- for(new loop; loop<ObjectsToStream && loop<nr; loop++)
- {
- if(ObjectInfo[Closest[loop]][ObjectCreated][playerid] == false)
- {
- ObjectInfo[Closest[loop]][ObjectID][playerid] = CreatePlayerObject(playerid, ObjectInfo[Closest[loop]][ModelID], ObjectInfo[Closest[loop]][ox], ObjectInfo[Closest[loop]][oy], ObjectInfo[Closest[loop]][oz], ObjectInfo[Closest[loop]][orox], ObjectInfo[Closest[loop]][oroy], ObjectInfo[Closest[loop]][oroz], ObjectInfo[Closest[loop]][ovdist]);
- ObjectInfo[Closest[loop]][ObjectCreated][playerid] = true;
- }
- }
- }
- }
- #define SetPlayerPos F_SetPlayerPos
- stock F_SetPlayerPos(playerid, Float:x, Float:y, Float:z)
- {
- F_PlayerObjectUpdate(playerid, x, y, z);
- SetPlayerPos(playerid, x, y, z);
- }
- stock CreateRMarker(Float:x,Float:y,Float:z)
- {
- for(new i = 0; i < sizeof(Markcord); i++)
- {
- if(Markcord[i][Redmarker] == 0)
- {
- Markcord[i][Redmarker]=1;
- Markcord[i][redmX]=x;
- Markcord[i][redmY]=y;
- Markcord[i][redmZ]=z-0.7;
- Markcord[i][rmObject] = F_CreateObject(1213, x, y, z-1.0,0,0,300);//red marker
- return 1;
- }
- }
- return 0;
- }
- stock DeleteAllRMarker()
- {
- for(new i = 0; i < sizeof(Markcord); i++)
- {
- if(Markcord[i][Redmarker] == 1)
- {
- Markcord[i][Redmarker]=0;
- Markcord[i][redmX]=0.0;
- Markcord[i][redmY]=0.0;
- Markcord[i][redmZ]=0.0;
- F_DestroyObject(Markcord[i][rmObject]);
- }
- }
- return 0;
- }
- stock DeleteClosestRMarker(playerid)
- {
- for(new i = 0; i < sizeof(Markcord); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.0, Markcord[i][redmX], Markcord[i][redmY], Markcord[i][redmZ]))
- {
- if(Markcord[i][Redmarker] == 1)
- {
- Markcord[i][Redmarker]=0;
- Markcord[i][redmX]=0.0;
- Markcord[i][redmY]=0.0;
- Markcord[i][redmZ]=0.0;
- F_DestroyObject(Markcord[i][rmObject]);
- return 1;
- }
- }
- }
- return 0;
- }
- stock CreateFMarker(Float:x,Float:y,Float:z)
- {
- for(new i = 0; i < sizeof(Markcords); i++)
- {
- if(Markcords[i][Flashmarker] == 0)
- {
- Markcords[i][Flashmarker]=1;
- Markcords[i][flamX]=x;
- Markcords[i][flamY]=y;
- Markcords[i][flamZ]=z-0.7;
- Markcords[i][flObject] = F_CreateObject(3526, x, y, z-1.05,0,0,300);//flashing marker
- return 1;
- }
- }
- return 0;
- }
- stock DeleteAllFMarker()
- {
- for(new i = 0; i < sizeof(Markcords); i++)
- {
- if(Markcords[i][Flashmarker] == 1)
- {
- Markcords[i][Flashmarker]=0;
- Markcords[i][flamX]=0.0;
- Markcords[i][flamY]=0.0;
- Markcords[i][flamZ]=0.0;
- F_DestroyObject(Markcords[i][flObject]);
- }
- }
- return 0;
- }
- stock DeleteClosestFMarker(playerid)
- {
- for(new i = 0; i < sizeof(Markcords); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.0, Markcords[i][flamX], Markcords[i][flamY], Markcords[i][flamZ]))
- {
- if(Markcords[i][Flashmarker] == 1)
- {
- Markcords[i][Flashmarker]=0;
- Markcords[i][flamX]=0.0;
- Markcords[i][flamY]=0.0;
- Markcords[i][flamZ]=0.0;
- F_DestroyObject(Markcords[i][flObject]);
- return 1;
- }
- }
- }
- return 0;
- }
- #endif
Add Comment
Please, Sign In to add comment