Skip to content
This repository has been archived by the owner. It is now read-only.
"Player-Arrays" in which the proper slot gets reset to a default value on rejoin
Pawn
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
.gitattributes
.gitignore
LICENSE
README.md
pawn.json
ptvar.inc

README.md

ptvar

sampctl

Introduces pretty syntax to declare variables in a "player array" format which get reset to the specified initializer (which must be explicitly set) when a player rejoins, useful for unimportant data that's only needed while the player is online.

Depends on y_hooks and y_amx from YSI-Includes

Installation

Simply install to your project:

sampctl package install AGraber/ptvar

Include in your code and begin using the library:

#include <ptvar>

Usage

A simple example to define

// Woah[playerid] gets set to INVALID_PLAYER_ID when playerid connects to the server.
ptvar Woah[MAX_PLAYERS] = INVALID_PLAYER_ID;

If ptvar is already defined in your script you can define DONT_USE_PRETTY_PTVAR and use an alternative macro:

#define DONT_USE_PRETTY_PTVAR
#include <ptvar>

PTVAR__ Woah[MAX_PLAYERS] = INVALID_PLAYER_ID;

You can use (for example) Woah as a normal variable after that, simple as that. The include will take care of resetting the variable to INVALID_PLAYER_ID on every join (specifically, a hook )

Credits

You can’t perform that action at this time.