---
title: "SetPVarString | open.mp"
description: "Saves a string into a player variable."
canonical: https://omp.itsneufox.com/docs/scripting/functions/SetPVarString
language: en
---

# SetPVarString

## Description

Saves a string into a player variable.

| Name | Description |
| --- | --- |
| playerid | The ID of the player whose player variable will be set. |
| const pvar\[\] | The name of the player variable. |
| const value\[\] | The string you want to save in the player variable. |
| OPEN\_MP\_TAGS:... | Indefinite number of arguments of any tag. |

## Returns

This function does not return any specific values.

## Examples

```c
public OnPlayerConnect(playerid)
{
    new
        hours,
        minutes,
        seconds,
        string[46];

    gettime(hours, minutes, seconds); // get the time
    format(string, sizeof(string), "Connected on %02d:%02d:%02d", hours, minutes, seconds); // create the string with the connect time
    SetPVarString(playerid, "timeconnected", string); // save the string into a player variable

    // PRO TIP: You don't need `format` in open.mp
    SetPVarString(playerid, "timeconnected", "Connected on %02d:%02d:%02d", hours, minutes, seconds);
    return 1;
}
```

## Notes

note

Variables aren't reset until after [OnPlayerDisconnect](https://omp.itsneufox.com/docs/scripting/callbacks/OnPlayerDisconnect) is called, so the values are still accessible in OnPlayerDisconnect.

## Related Functions

-   [SetPVarInt](https://omp.itsneufox.com/docs/scripting/functions/SetPVarInt): Set an integer for a player variable.
-   [GetPVarInt](https://omp.itsneufox.com/docs/scripting/functions/GetPVarInt): Get the previously set integer from a player variable.
-   [GetPVarString](https://omp.itsneufox.com/docs/scripting/functions/GetPVarString): Get the previously set string from a player variable.
-   [SetPVarFloat](https://omp.itsneufox.com/docs/scripting/functions/SetPVarFloat): Set a float for a player variable.
-   [GetPVarFloat](https://omp.itsneufox.com/docs/scripting/functions/GetPVarFloat): Get the previously set float from a player variable.
-   [DeletePVar](https://omp.itsneufox.com/docs/scripting/functions/DeletePVar): Delete a player variable.
