03.12.2011, 18:34
(
Последний раз редактировалось Ash.; 06.08.2012 в 20:03.
)
RemoveBuilding
Good Evening SAMP users!Global "RemoveBuildingForPlayer"
I'd like to present you with "RemoveBuilding".
Introduction
A player on my server recently requested that a map be added (a house modification) that used the RemoveBuildingForPlayer function. I had not yet used that function for my server (though had used it throughout the RC builds) and was wondering what would be the best way to apply this to all players, no matter when they connect or if they're connected at the time. My solution, was this include!
In short: This include removes the need to use RemoveBuildingForPlayer for everyone (for loop) and removes the need of calling such function when the player connects. This include also brings with it a 'RestoreBuilding' function and a 'RemoveSpecificBuilding' function.
The Functions
RemoveBuilding
pawn Код:
RemoveBuilding(modelid, Float:oX, Float:oY, Float:oZ, Float:oRadius = 0.25, Float:orX = 0.0, Float:orY = 0.0, Float:orZ = 0.0)
pawn Код:
RemoveBuilding(modelid, x, y, z);
pawn Код:
new rem_obj = RestoreBuilding(modelid, x, y, z, radius, rx, ry, rz);
RemoveSpecificBuilding
pawn Код:
RemoveSpecificBuilding(modelid)
RestoreBuilding
pawn Код:
RestoreBuilding(slotid)
pawn Код:
new RemoveObjectVar;
public OnFilterScriptInit()
{
RemoveObjectVar = RemoveBuilding(1697, 236.9922, 1835.3438, 23.2344, 0.25, 356.8584, 0.0000, -0.7854);
}
CMD:restore(playerid, params[])
{
#pragma unused params
RestoreBuilding(RemoveObjectVar);
return SendClientMessage(playerid, COLOUR_GREEN, "The static object has been restored."), 1;
}
CountRemovedObjects
pawn Код:
CountRemovedObjects()
Setup
You will need to download the include (and place it in pawno > includes). The download link is available toward the end of this post. Include it (with the name you called it).
pawn Код:
#include <removebuilding> //Example
pawn Код:
#define MAX_REMOVED_OBJECTS 500
#include <removebuilding>
You can then proceed to using "RemoveBuilding" like you would use "RemoveBuildingForPlayer". You will need to change your RemoveBuildingForPlayer lines to RemoveBuilding for this include to be able to handle them correctly.
Bugs/Issues
If you have found an issue/bug with this include, don't hesitate to post it here! (PM'ing me won't get it fixed, and will just get you blacklisted from contacting me.)
Change Log
Код:
06/08/12: - Fixed an issue with RestoreBuilding... (Should've noticed this ages ago tbh...)
Код:
04/12/11: - Added RestoreBuilding; a function for restoring removed buildings. - Added RemoveSpecificBuilding; a function for removing all models on the map; regardless of their location.
Код:
06/12/11: - Removed the hooking of the RemoveBuildingForPlayer native (as this caused errors with RemoveBuilding itself). You will need to convert the RemoveBuildingForPlayer lines yourself.
Код:
14/12/11 - Rescripted part of the RemoveBuilding function to properly assign the fact that a building has been removed.
This is the latest download link from Pastebin: http://pastebin.com/Y2pqCSgF
The old (original) version of this include can be found here: http://pastebin.com/vXR5A3n6 - You can use this version if you do not plan on using the RestoreBuilding or RemoveSpecificBuilding functions.
Please refer to the "Setup" section of this post for help on setting both the updated and old version up.
Conclusion
I have tested this script, and can confirm it has worked fine for me. I haven't yet tested it on a public server, and so it hasn't been under a lot of stress; though it should work perfectly fine. If you have any issues, don't hesitate to ask!