[Include] RemoveBuilding
#1

RemoveBuilding
Global "RemoveBuildingForPlayer"
Good Evening SAMP users!
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)
This operates the same way as RemoveBuildingForPlayer does, though without the "playerid" parameter. It places the object in a global array (within the include) and removes it for all connected players. If a player connects after RemoveBuilding has been called, it removes the static object for that player too. In this include, specifying the radius is optional. You could merely do
pawn Код:
RemoveBuilding(modelid, x, y, z);
and it would work perfectly fine. This function also has the option of supplying the objects rotation co-ordinates. If you do wish to use 'RestoreBuilding' at some point, you will need to specify these. This function returns a 'slotid' which is the array slot of the data being kept after this function is called. If you wish to call RestoreBuilding for this particular static object, you will need to store what this function returns in a variable. Observe:
pawn Код:
new rem_obj = RestoreBuilding(modelid, x, y, z, radius, rx, ry, rz);
To remove a building accurately, you will need to specify the rotation co-ordinates.
RemoveSpecificBuilding
pawn Код:
RemoveSpecificBuilding(modelid)
With this function, you can merely specify a 'modelid' to remove throughout the map. It returns the 'slotid' for that particular object, however you cannot restore objects using this function (as you give no co-ordinates to this function).
RestoreBuilding
pawn Код:
RestoreBuilding(slotid)
This function allows you to restore a particular building that has been removed using RemoveBuilding. You will need to 'slotid' that RemoveBuilding returns to pass to it (hence the 'slotid' parameter). RestoreBuilding will re-create the object using SA-MP's native CreateObject function. A quick demonstration on how this works:
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()
This merely returns how many objects have been 'destroyed' by the RemoveBuilding function.

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
The default "object removal limit" is 100. You can change this by defining it BEFORE you include the file. Example:
pawn Код:
#define MAX_REMOVED_OBJECTS 500
#include <removebuilding>
Remember, the higher this number - the bigger the array, therefore the higher the memory usage.

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.
Download
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!
Reply
#2

good job man really great job i like it
Reply
#3

awesome work! thx funky!
Reply
#4

Quote:
Originally Posted by Mr.Fames
Посмотреть сообщение
good job man really great job i like it
Quote:
Originally Posted by PawnoQ
Посмотреть сообщение
awesome work! thx funky!
Thanks.

I may implement a "RestoreBuilding" at some point too. However, this will use the CreateObject native.
//This has since been implemented.
Reply
#5

what the difference between this and the new native from 0.3d:
pawn Код:
RemoveBuildingForPlayer(playerid, modelid, Float:fX, Float:fY, Float:fZ, Float:fRadius);
Reply
#6

Excellent. I would love to see RemoveCertainBuilding(objectid);! @xkirill: this one is global notjust forone player I think.
Reply
#7

Quote:
Originally Posted by xkirill
Посмотреть сообщение
what the difference between this and the new native from 0.3d:
pawn Код:
RemoveBuildingForPlayer(playerid, modelid, Float:fX, Float:fY, Float:fZ, Float:fRadius);
cant you read ? he said it removes it for all players that connect....
Reply
#8

Great Job!
Reply
#9

Quote:
Originally Posted by xkirill
Посмотреть сообщение
what the difference between this and the new native from 0.3d:
pawn Код:
RemoveBuildingForPlayer(playerid, modelid, Float:fX, Float:fY, Float:fZ, Float:fRadius);
You obviously haven't read the original post thoroughly. This include removes the need for the 'playerid' parameter of the 0.3d native; therefore meaning it can be called anywhere (OnGameModeInit, so you can keep certain map segments separate, for example).

Quote:
Originally Posted by PlayHard
Посмотреть сообщение
Excellent. I would love to see RemoveCertainBuilding(objectid);!
This wouldn't be so difficult with this include. I may add this when I get round to adding the RestoreBuilding function.
//This has since been implemented.

Thanks to everyone that has given me such thankful/nice comments.
Reply
#10

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Код:
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.
Update: Added two new functions. Refer to the original post for more information.
Reply
#11

OMG ash, you're a legend
Reply
#12

If I use RemoveBuilding with a radius of 9999 to remove all instances of a specific model, will this include restore them? I'm pretty sure you'd need to have all the position data for that.
Reply
#13

Quote:
Originally Posted by MP2
Посмотреть сообщение
If I use RemoveBuilding with a radius of 9999 to remove all instances of a specific model, will this include restore them? I'm pretty sure you'd need to have all the position data for that.
Yes, I would. This is why, you have to supply the rotation parameters if you wish to be able to restore a building. I may be able to get some of this data by pulling the data from the ide files, though I'm not promising anything.
Reply
#14

hi there im trying to use your include it works fine until i join the server and then the server crashes do you no why thx
Reply
#15

Quote:
Originally Posted by scottygraham1990
Посмотреть сообщение
hi there im trying to use your include it works fine until i join the server and then the server crashes do you no why thx
The server doesn't crash when I use this include. Could you show the RemoveBuilding, and - if used, the Restore Building lines?
Reply
#16

Quote:
Originally Posted by funky1234
Посмотреть сообщение
The server doesn't crash when I use this include. Could you show the RemoveBuilding, and - if used, the Restore Building lines?
here is the code and i dnt use the restore building

Код:
RemoveBuilding(3865, -2063.2422, 258.7500, 35.7422, 0.25);
RemoveBuilding(3869, -2123.2891, 269.5313, 41.8516, 0.25);
RemoveBuilding(3869, -2126.2109, 231.9766, 41.6875, 0.25);
RemoveBuilding(3869, -2116.6797, 131.0078, 42.1484, 0.25);
RemoveBuilding(3865, -2063.0156, 247.9453, 35.7422, 0.25);
RemoveBuilding(3865, -2057.7500, 249.9531, 35.5938, 0.25);
RemoveBuilding(3865, -2057.7031, 229.8047, 35.3516, 0.25);
RemoveBuilding(3865, -2059.5313, 256.5234, 37.0078, 0.25);
RemoveBuilding(3888, -2128.1797, 171.4609, 42.4297, 0.25);
RemoveBuilding(3888, -2066.3594, 301.9141, 42.1719, 0.25);
RemoveBuilding(3887, -2066.3594, 301.9141, 42.1719, 0.25);
RemoveBuilding(3887, -2128.1797, 171.4609, 42.4297, 0.25);
RemoveBuilding(3866, -2116.6797, 131.0078, 42.1484, 0.25);
RemoveBuilding(3864, -2082.5391, 153.5469, 40.1016, 0.25);
RemoveBuilding(3872, -2079.8203, 159.6719, 40.8906, 0.25);
RemoveBuilding(3864, -2111.8828, 172.4688, 40.1953, 0.25);
RemoveBuilding(3872, -2116.7500, 177.0781, 40.9844, 0.25);
RemoveBuilding(3872, -2064.2109, 210.1406, 41.2578, 0.25);
RemoveBuilding(3872, -2107.0313, 226.0391, 40.8438, 0.25);
RemoveBuilding(10984, -2126.1563, 238.6172, 35.2656, 0.25);
RemoveBuilding(3864, -2102.2109, 230.7031, 40.0547, 0.25);
RemoveBuilding(3866, -2126.2109, 231.9766, 41.6875, 0.25);
RemoveBuilding(10986, -2130.0547, 275.5625, 35.3750, 0.25);
RemoveBuilding(10987, -2137.8203, 264.2813, 35.7813, 0.25);
RemoveBuilding(3866, -2123.2891, 269.5313, 41.8516, 0.25);
RemoveBuilding(3864, -2113.3125, 268.5078, 40.5703, 0.25);
RemoveBuilding(3872, -2118.1328, 263.8438, 41.3594, 0.25);
RemoveBuilding(10985, -2099.2734, 292.9141, 35.0703, 0.25);
RemoveBuilding(3864, -2059.3438, 205.5313, 40.4688, 0.25);
RemoveBuilding(3872, -2048.4531, 265.0938, 41.6563, 0.25);
RemoveBuilding(3864, -2041.7500, 265.1016, 40.8672, 0.25);
Reply
#17

Quote:
Originally Posted by scottygraham1990
Посмотреть сообщение
here is the code and i dnt use the restore building

Код:
RemoveBuilding(3865, -2063.2422, 258.7500, 35.7422, 0.25);
RemoveBuilding(3869, -2123.2891, 269.5313, 41.8516, 0.25);
RemoveBuilding(3869, -2126.2109, 231.9766, 41.6875, 0.25);
RemoveBuilding(3869, -2116.6797, 131.0078, 42.1484, 0.25);
RemoveBuilding(3865, -2063.0156, 247.9453, 35.7422, 0.25);
RemoveBuilding(3865, -2057.7500, 249.9531, 35.5938, 0.25);
RemoveBuilding(3865, -2057.7031, 229.8047, 35.3516, 0.25);
RemoveBuilding(3865, -2059.5313, 256.5234, 37.0078, 0.25);
RemoveBuilding(3888, -2128.1797, 171.4609, 42.4297, 0.25);
RemoveBuilding(3888, -2066.3594, 301.9141, 42.1719, 0.25);
RemoveBuilding(3887, -2066.3594, 301.9141, 42.1719, 0.25);
RemoveBuilding(3887, -2128.1797, 171.4609, 42.4297, 0.25);
RemoveBuilding(3866, -2116.6797, 131.0078, 42.1484, 0.25);
RemoveBuilding(3864, -2082.5391, 153.5469, 40.1016, 0.25);
RemoveBuilding(3872, -2079.8203, 159.6719, 40.8906, 0.25);
RemoveBuilding(3864, -2111.8828, 172.4688, 40.1953, 0.25);
RemoveBuilding(3872, -2116.7500, 177.0781, 40.9844, 0.25);
RemoveBuilding(3872, -2064.2109, 210.1406, 41.2578, 0.25);
RemoveBuilding(3872, -2107.0313, 226.0391, 40.8438, 0.25);
RemoveBuilding(10984, -2126.1563, 238.6172, 35.2656, 0.25);
RemoveBuilding(3864, -2102.2109, 230.7031, 40.0547, 0.25);
RemoveBuilding(3866, -2126.2109, 231.9766, 41.6875, 0.25);
RemoveBuilding(10986, -2130.0547, 275.5625, 35.3750, 0.25);
RemoveBuilding(10987, -2137.8203, 264.2813, 35.7813, 0.25);
RemoveBuilding(3866, -2123.2891, 269.5313, 41.8516, 0.25);
RemoveBuilding(3864, -2113.3125, 268.5078, 40.5703, 0.25);
RemoveBuilding(3872, -2118.1328, 263.8438, 41.3594, 0.25);
RemoveBuilding(10985, -2099.2734, 292.9141, 35.0703, 0.25);
RemoveBuilding(3864, -2059.3438, 205.5313, 40.4688, 0.25);
RemoveBuilding(3872, -2048.4531, 265.0938, 41.6563, 0.25);
RemoveBuilding(3864, -2041.7500, 265.1016, 40.8672, 0.25);
There seemed to be a problem with hooking the native callback. Removing it solved the issue.
Re-download the include from this link: http://pastebin.com/L7ECMRbh

You can find that in the main post aswell, along with the changelog.
Reply
#18

Quote:

C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(16) : error 025: function heading differs from prototype
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(6 : warning 235: public function lacks forward declaration (symbol "OnPlayerConnect")
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : error 017: undefined symbol "RemoveBuildingForPlayer"
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : warning 215: expression has no effect
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : warning 215: expression has no effect
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : warning 215: expression has no effect
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : warning 215: expression has no effect
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : warning 215: expression has no effect
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : warning 215: expression has no effect
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : error 001: expected token: ";", but found ")"
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : error 029: invalid expression, assumed zero
C:\Users\Orlando\Desktop\pawno\include\removebuild ing.inc(72) : fatal error 107: too many error messages on one line

Why am I getting these errors?
Reply
#19

Quote:
Originally Posted by Orlandino
Посмотреть сообщение
Why am I getting these errors?
Are you including this file before or after a_samp?

The errors you're having seem to be related to the lack of RemoveBuildingForPlayer and OnPlayerConnect, which are defined in a_samp.inc.

Your includes should look a little something like this:
pawn Код:
#include <a_samp>
#include <removebuilding>
//And any others should go under a_samp too.
Reply
#20

sorry, you can leave the steps specified to place your include, for example:
1 - Insert the include statement in the include (I guess)
2 - inside gm place incluide name (I guess)
3 - within the gm place the code in publicOnPlayerConnec
4 - copilot

If so I do not work the copilot, please Can you help me?

line pawn:

Quote:

#include <a_samp>
#include <removebuilding>

public OnGameModeInit()

RemoveBuildingForPlayer(playerid, 3976, 1571.6016, -1675.7500, 35.6797, 0.25);

>>>>>>>>>>>>>>>>I get errors
Quote:

C:\pawno\include\removebuilding.inc(73) : error 017: undefined symbol "RemoveBuildingForPlayer"
C:\gamemodes\lspd.pwn(1146 : error 017: undefined symbol "RemoveBuildingForPlayer"

2 Errors.

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)