Coder Social home page Coder Social logo

kristoisberg / samp-screen-colour-fader Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 4.0 19 KB

Library for fading players' screens between colours for open.mp and SA-MP.

Pawn 100.00%
sa-mp sa-mp-library pawn pawn-package screen color colors colour colours fade fader

samp-screen-colour-fader's Introduction

SA-MP Screen Colour Fader

sampctl

Notice: This repository is not being actively maintained anymore. If anyone wishes to continue the development of the project, please create a fork of the repository and release future versions there.

This library lets you add colour filters to players' screens and fade between them. Until today I was using a modified version of Joe Staff's fader include, but since it was using a separate argument for each part of an RGBA colour and the original was outdated in general, I decided to create my own. Here's what I came up with.

Installation

Simply install to your project:

sampctl package install kristoisberg/samp-screen-colour-fader

Include in your code and begin using the library:

#include <screen-colour-fader>

Functions

native SetPlayerScreenColour(playerid, colour);

Will set the player's screen colour to the specified colour. Can be used during a fade, but the fade will continue after the current step is finished. Returns 1 if the specified player is connected or 0 if not.

native GetPlayerScreenColour(playerid);

Can be used during a fade. Returns the current colour of the player's screen if the player is connected or 0x00000000 if not.

native FadePlayerScreenColour(playerid, colour, time, steps);

Fades the player's screen from the current colour to the colour specified in the function. time specifies the duration of the fade and steps specifies the amount of steps made during the fade. Returns 1 if the specified player is connected and the values of time and steps are valid or 0 if not.

native StopPlayerScreenColourFade(playerid);

Stops the ongoing fade. The colour of the player's screen will remain as it is at the time of the function call. Returns 1 if the specified player is connected and has an ongoing fade or 0 if not.

Callbacks

forward public OnScreenColourFadeComplete(playerid);

Notes

  • Both for the functions and the callback, the American spelling (color instead of colour) is also supported.

Example

The following piece of code (also available in test.pwn) fades the player's screen to red and back to transparent five times.

new bool:reverse, counter;

public OnPlayerConnect(playerid) {
	SetPlayerScreenColour(playerid, 0x00000000);
	FadePlayerScreenColour(playerid, 0xFF0000AA, 1000, 25);
	return 1;
}


public OnScreenColourFadeComplete(playerid) {
	if (++counter == 10) {
		return 1;
	}

	FadePlayerScreenColour(playerid, reverse ? 0xFF0000AA : 0x00000000, 1000, 50);

	reverse = !reverse;

	return 1;
}

Testing

To test, simply run the package:

sampctl package run

And connect to localhost:7777 to test.

samp-screen-colour-fader's People

Contributors

medzvel avatar southclaws avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

samp-screen-colour-fader's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.