[Include] WinDoSi.inc (Vehicle Windows/Doors/Siren Control)
#1

Description

This include will ease the control of vehicle's doors, windows and siren states. There is nothing special, just new definitions of different states, new functions to open/close vehicle's door/window, new functions to install/remove vehicle's siren... (for more details see Functions section), which are easier to use.

Features
  • Opening/closing vehicle's doors with one line
  • Opening/closing vehicle's windows with one line
  • Getting state of windows/doors with one line
  • Installing/removing siren from a vehicle at ANY TIME with one line
Definitions

Code:
#define WDS_MAX_VEHICLE_DOORS 4 // Amount of doors (Just to avoid using literals)
Doors:
Code:
#define FL_DOOR 	0 // Front Left (Driver's door)
#define FR_DOOR 	1 // Front Right (Passenger's door)
#define BL_DOOR 	2 // Back Left
#define BR_DOOR 	3 // Back Right
Door's states:
Code:
#define WDS_DOOR_STATE_OPENED		1 // Opened state
#define WDS_DOOR_STATE_CLOSED		0 // Closed state
#define WDS_DOOR_STATE_NOT_SET	   -1 // Not set
Window's states:
Code:
#define WDS_WINDOW_STATE_OPENED		0 // Opened state
#define WDS_WINDOW_STATE_CLOSED		1 // Closed state
#define WDS_WINDOW_STATE_NOT_SET   -1 // Not set
Siren's states:
Code:
#define WDS_SIREN_STATE_ON 				 1 // On 
#define WDS_SIREN_STATE_OFF				 0 // Off
#define WDS_SIREN_STATE_NOT_INSTALLED 	-1 //  Not installed - means, that the siren was not set in AddStaticVehicleEx/CreateVehicle functions (parameter addsiren = 0).
Functions:
  • SetVehicleWindowState(vehicleid, door, newstate) - sets a new vehicle's window state
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
      * newstate - new state of vehicle's window (see Definitions -> Window states)
    • Returns 1, if succeeded, otherwise 0.
  • SetVehicleDoorState(vehicleid, door, newstate) - sets a new vehicle's door state
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
      * newstate - new state of vehicle window (see Definitions -> Door states)
    • Returns 1, if succeeded, otherwise 0.
  • SetVehicleSirenState(vehicleid, newstate) - sets a new vehicle's siren state.
    Note: it can be used only to install/uninstall siren. There is no possibility to turn siren on/off yet.
    • Parameters:
      * vehicleid - vehicle's ID
      * newstate - new state for the siren (see Definitions -> Siren states)
    • Returns 1, if succeeded, otherwise 0.
  • GetVehicleWindowState(vehicleid, door) - gets a current state of vehicle's window
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns current state of the window (see Definitions -> Window states)
  • OpenVehicleDoor(vehicleid, door) - opens a vehicle's door
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns 1, if succeeded, otherwise 0.
  • CloseVehicleDoor(vehicleid, door) - closes a vehicle's door
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns 1, if succeeded, otherwise 0.
  • IsVehicleDoorOpened(vehicleid, door) - checks, whether a door is opened or not
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns true, if opened, otherwise false.
  • IsVehicleDoorClosed(vehicleid, door) - checks, whether a door is closed or not
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns true, if closed, otherwise false.
  • OpenVehicleWindow(vehicleid, door) - opens a vehicle's window
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns 1, if succeeded, otherwise 0.
  • OpenVehicleWindow(vehicleid, door) - opens a vehicle's window
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns 1, if succeeded, otherwise 0.
  • IsVehicleWindowOpened(vehicleid, door) - checks, whether a window is opened or not
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns true, if opened, otherwise false.
  • IsVehicleWindowClosed(vehicleid, door) - checks, whether a window is closed or not
    • Parameters:
      * vehicleid - vehicle's ID
      * door - vehicle's door ID (see Definitions -> Doors)
    • Returns true, if closed, otherwise false.
  • InstallVehicleSiren(vehicleid) - intalles a siren on a vehicle
    • Parameters:
      * vehicleid - vehicle's ID
    • Returns 1, if succeeded, otherwise 0.
  • UninstallVehicleSiren(vehicleid) - removes a siren from a vehicle
    • Parameters:
      * vehicleid - vehicle's ID
    • Returns 1, if succeeded, otherwise 0.
  • GetVehicleSirenState(vehicleid) - gets a current state of vehicle's siren
    • Parameters:
      * vehicleid - vehicle's ID
    • Returns current state of the siren (see Definitions -> Siren states)
  • IsVehicleSirenOn(vehicleid) - checks, whether a siren is on or not
    • Parameters:
      * vehicleid - vehicle's ID
    • Returns true, if turned on, otherwise false.
  • IsVehicleSirenOff(vehicleid) - checks, whether a siren is off or not
    • Parameters:
      * vehicleid - vehicle's ID
    • Returns true, if turned off, otherwise false.
Bugs
GetVehicleDoorState, IsVehicleDoorOpened, IsVehicleDoorClosed are not working properly. Despite the fact that the door is opened or closed, always returns -1. I guess there is a problem with GetVehicleParamsCarDoors/SetVehicleParamsCarDoors (didn't confirmed).

Installation
Put windosi.inc to your pawn/include/ folder. Then, wherever you want to use this include, write #include <windosi> at the top of your script (after #include <a_samp>) and then compile it.

Download links
GitHub
Pastebin
Examples (GitHub)

Please, let me know about grammar or any other mistakes I've done in this thread and documentation.
Reply
#2

Quote:
Originally Posted by valych
View Post
Bugs
GetVehicleDoorState, IsVehicleDoorOpened, IsVehicleDoorClosed are not working properly. Despite the fact that the door is opened or closed, always returns -1. I guess there is a problem with GetVehicleParamsCarDoors/SetVehicleParamsCarDoors (didn't confirmed).
https://sampforum.blast.hk/showthread.php?tid=571441
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)