---
title: "Per-player variable system | open.mp"
description: "The per-player variable system (put short, PVar) is a new way of creating player variables in an efficient dynamically created method globally."
canonical: https://omp.itsneufox.com/ar/docs/tutorials/perplayervariablesystem
language: ar
---

# Per-player variable system

The **per-player variable system** (put short, **PVar**) is a new way of creating player variables efficiently and dynamically, meaning that they can be used in server's gamemode and filterscripts at the same time.

They are similar to [SVars](https://omp.itsneufox.com/ar/docs/tutorials/servervariablesystem), but are on a per-player basis.

warning

This system was introduced in SA-MP 0.3a R5 and will not work in earlier versions!

## Advantages

The per-player variable system has several major advantages over creating an array sized `MAX_PLAYERS`.

-   PVars can be shared/accessed across gamemode scripts and filterscripts, making it easier to modularize your code.
    
-   PVars are automatically deleted when a player leaves the server (after [OnPlayerDisconnect](https://omp.itsneufox.com/ar/docs/scripting/callbacks/OnPlayerDisconnect)), meaning you don't have to manually reset variables for the next player who joins.
    
-   No real need for complex enums/player info structures.
    
-   Saves memory by not allocating pawn array elements for playerids which will probably never be used.
    
-   You can easily enumerate and print/store the PVar list. This makes both debugging and player info storage easier.
    
-   Even if a PVar hasn't been created, it still will return a default value of 0.
    
-   PVars can hold very large strings using dynamically allocated memory.
    
-   You can Set, Get, Create PVars ingame.
    

## Drawbacks

-   PVars are several times slower than regular variables. It is generally more favorable to trade in memory for speed, rather than the other way round.

## Related Functions

-   [SetPVarInt](https://omp.itsneufox.com/ar/docs/scripting/functions/SetPVarInt): set an integer for a player variable.
-   [GetPVarInt](https://omp.itsneufox.com/ar/docs/scripting/functions/GetPVarInt): get the previously set integer from a player variable.
-   [SetPVarString](https://omp.itsneufox.com/ar/docs/scripting/functions/SetPVarString): set a string for a player variable.
-   [GetPVarString](https://omp.itsneufox.com/ar/docs/scripting/functions/GetPVarString): get the previously set string from a player variable.
-   [SetPVarFloat](https://omp.itsneufox.com/ar/docs/scripting/functions/SetPVarFloat): set a float for a player variable.
-   [GetPVarFloat](https://omp.itsneufox.com/ar/docs/scripting/functions/GetPVarFloat): get the previously set float from a player variable.
-   [DeletePVar](https://omp.itsneufox.com/ar/docs/scripting/functions/DeletePVar): delete a player variable.
-   [GetPVarsUpperIndex](https://omp.itsneufox.com/ar/docs/scripting/functions/GetPVarsUpperIndex): each PVar has an index or 'id', this returns the highest one.
-   [GetPVarNameAtIndex](https://omp.itsneufox.com/ar/docs/scripting/functions/GetPVarNameAtIndex): get the player variable's name from its index.
-   [GetPVarType](https://omp.itsneufox.com/ar/docs/scripting/functions/GetPVarType): get the [type](https://omp.itsneufox.com/ar/docs/scripting/resources/pvartypes) of the player variable.
