• 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Library] Advanced lights control
#1
Tech-Lights

[Image: b0365c8ae3.jpg]





[Image: sampctl-Tech_Lights-2f2f2f.svg?style=for-the-badge]



Github: https://github.com/RogueDrifter/Tech_Lights



Read this >>>:

This is an include that allows you to manipulate lights better, this creates lights that only light up when someone is near them within a range you can control.



I would've added a video but i really don't have the time, i created this almost a year ago but deleted it for a reason which i can't remember but it is very helpful, the functions which i love the most are 'BlinkLights' because it gives you the ability to create lights that blink in the streets for an example.



'PointLights' is also very good makes it so easy to have the lights look up/down/left/right, the 'DanceLights' function is fun too because you can have lights moving right/left just like the ones at any party.



'BlinkToDestroy' could also be used to have lights blink until they are broken i guess? And of course the main purpose of why i created this is lights that only light up whenever a player is near them (Can be controlled by functions such as 'KeepLightsOn')



That's why i loved creating this include cuz it just gives you the ability to do so much, hope it is as helpful for you.





Installation



You just include it in the script you want to use the lights in and use the functions as simple as that.

Simply install to your project:



Code:
sampctl package install RogueDrifter/Tech_Lights





Include in your code and begin using the library:



Code:
#include <Tech_Lights>



Testing

Version: 3.0



All can be done through the test.pwn folder which already

contains the include and a simple test use of the functions.



To test, simply run the package:



Code:
sampctl package run



Usage



To get the coords for the lights you can do so using any map editor and the modelid for the object is 18656

https://dev.prineside.com/en/gtasa_samp_...BeamWhite/ is a link of that object's preview.



Picture:

[Image: 18656_b.jpg]





So as you can see within the functions there are 2 parameters, LightID and LightType



The first one (LightID) is put to define the light object in order to destroy it later, so say you created a light using the function CreateLights using id 0, in order to destroy it using DestroyLights you'll need to use the same ID (0) to destroy that light, simple?



The maximum amount of lights to be created is a 100 by default which you can control by using:





Code:
#define MAX_RTLIGHTS (NUMBER)

So yeah make sure your LightID is never below 0 or above the MAX_RTLIGHTS



The second one (LightType) there are currently 3 types and the 4th one will be released soon, the current three ones (ranging from 0 to 2 as in 0,1,2) are white lights, red lights and blue lights in this respective order.

Code:
LightType:

0- Normal white lights

1- Colored lights red

2- Colored lights blue

Almost all of the functions are self explanatory so the last thing here is:



Code:
#define RTL_MAX_PLAYER_RANGE (RANGE)

Which as it says defines the range the player needs to be within the position of the light in order to 'trigger' as in lighten it up.



Quick example (included in test.pwn):

Code:
// generated by "sampctl package generate"



#include "Tech_Lights.inc"



main() {

?? ?CreateLights (0, 0, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0);

}



Contained functions:



Code:
CreateLights (LightType, LightID, Float:PosX, Float:PosY, Float:PosZ, Float:PosRX, Float:PosRY, Float:PosRZ, Float:DrawDistance = 0.0);



DestroyLights (LightID, LightType);



DestroyAllLights (LightType);



HideLights (LightID, LightType);



ShowLights (LightID, LightType);



BlinkLights (LightID, LightType, Toggle);



KeepLightsOn (LightID, LightType, Toggle);



KeepAllLightsOn (LightType, Toggle);



IsLightKeptOn (LightID, LightType);



IsLightValid (LightID, LightType);



IsLightBlinking (LightID, LightType);



IsLightOn (LightID, LightType);



IsPlayerTriggeringLight (playerid, LightID, LightType);



ToggleLightForPlayer (playerid, LightID, LightType, Toggle);



PointLights(LightID, LightType, Direction);



ShowAllLights (LightType);



HideAllLights (LightType);



BlinkToDestroyLights (LightID, LightType); ?



GetLightObjectID(LightID, LightType);



DanceLights(LightID, LightTyp); ?



MoveLights (LightID, LightType, Float:ToX, Float:ToY, Float:ToZ, Float:ToRX, Float:ToRY, Float:ToRZ);



Callbacks:



Code:
OnPlayerTriggerLight(playerid, LightID, LightType);



OnLightGoOff(LightID, LightType);



Updating:



Simply open your project and run the code:



Code:
sampctl package ensure



Example of usage:

Lights_Event: https://github.com/RogueDrifter/Lights_Event
[Image: github.png]
  Reply


Messages In This Thread
Advanced lights control - by RogueDrifter - 2019-11-09, 11:08 PM

Forum Jump: