SA-MP Forums Archive
[Include] Easy Doors - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Easy Doors (/showthread.php?tid=598375)



Easy Doors - Gigi-The-Beast - 11.01.2016

[WIP] Easy Doors v0.1


Description

WORK IN PROGRESS
This include provides an easy way to implement interactive doors in your gamemode. After creation of a door, it is possible to open and close it easily, check when a player in near a door, or check if a player is near any door.
With every created object, the script also creates a dynamic area that provides an easy way of checking if a player is near the door.




List Of Functions

CreateDoor(modelid, Float: x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
* Function creates a door object with invisible area (if debug is active, it creates 4 debug objects on corners of area)
modelid - the ID of the model for the door object (See restrictions)
x - coordinate X
y - coordinate Y
z - coordinate Z
rx - coordinate of rotation X
ry - coordinate of rotation Y
rz - coordinate of rotation Z
Returns door ID or 0 if door could not be created


DestroyDoor(doorid)
* Function destroys a door
doorid - ID of a door (createdoor returns door id)
Returns 1 on success or 0 if door could not be destroyed


MoveDoor(doorid, doorstate, Float: speed = 1.0)
* Function opens or closes a door depending on the state
doorid - the ID of the door
doorstate - DS_DOOR_CLOSE to close the door or DS_DOOR_OPEN to open it
speed - default is 1.0 and it is instant, if you want to open/close it slowly, use 0.01 to 0.001
Returns 1 on success or 0 if function failed to execute


IsPlayerInDoorZone(playerid, doorid)
* Function checks if player is in a door zone. A door zone is an invisible zone with 1.5 units width and length on both sides of door (too see it, uncomment DS_DEBUG)
playerid - the id of the player that you want to check
doorid - the id of the door
Returns 1 if player is in the zone, or 0 if player is not in the zone


IsPlayerInAnyDoorZone(playerid)
* Function check if player is in any door zone.
playerid - the id of the player for check
Returns ID of the zone the player is in, or 0 if player is not in any zone



Installation

To install this include, you must have Streamer Plugin by Incognito.
Add file "doors.inc" to the Pawno folder and then include it in your gamemode.
To activate/deactivate debug mode, simply comment/uncomment DS_DEBUG row.
To increase max number of doors, change MAX_DOORS to the desired value.



Limitations

Currently only these door modelids are supported: 1504, 1505, 1506, 1507
Soon other doors will be supported too.



Download

http://pastebin.com/aGE5MnPN



Changelog
Код:
v0.1 - 11.01.2016
- Created the code



Re: Easy Doors - Crayder - 11.01.2016

Yeah uhh... Where does MoveDoor move the door to? And where is the support for different types of doors? Rotating doors, sliding doors, 2 in 1's...


Re: Easy Doors - Abagail - 11.01.2016

To be honest, you should allow the include user to decide how/where the object moves rather than having it hard coded. You should also give an example script so people will know how it works.


Re: Easy Doors - Gigi-The-Beast - 11.01.2016

@Crayder & @Abagail - Interesting suggestions, it will be added in the next version.


Re: Easy Doors - [eLg]elite - 12.01.2016

This is quite good besides the issues pointed out above. Is it well tested? What are the known bugs?