> For the complete documentation index, see [llms.txt](https://qpapel.papelship.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qpapel.papelship.com/documentation/tr-documentation/fonksiyonlar/serverside-string.md).

# Serverside String

Retrieves a secure string value from the server using a 12-digit access ID.

{% hint style="info" %}
Server strings can be public (no license required) or protected (license validation required). They are returned as dynamically allocated buffers from the SDK.
{% endhint %}

## Signature

```cpp
char* FetchString(QPCTX c, 
                  const char* stringId, 
                  const char* licenseKey);
```

## Parameters

| Parameter    | Type          | Description                                                      | Required |
| ------------ | ------------- | ---------------------------------------------------------------- | -------- |
| `c`          | `QPCTX`       | Client context pointer                                           | Yes      |
| `stringId`   | `const char*` | 12-digit access identifier of the server string                  | Yes      |
| `licenseKey` | `const char*` | License key for protected strings (empty string `""` for public) | Yes      |

## Returns

**Type:** `char*`

| Value            | Description                                        |
| ---------------- | -------------------------------------------------- |
| `Non-null char*` | Dynamic string value retrieved from server         |
| `nullptr`        | Access denied, network error, or invalid access ID |

{% hint style="warning" %}
The returned `char*` buffer is dynamically allocated by the SDK. To prevent memory leaks in your application, you **must** release this memory by calling `qpapel::FreeString(value)` when you are done using it.
{% endhint %}

## Basic Usage

### Public String (No License Key Required)

```cpp
#include <iostream>
#include "qPapelLib.h"

void PrintWelcomeMessage(QPCTX ctx) {
    // Fetch a public string (license key parameter is empty "")
    char* welcome = qpapel::FetchString(ctx, "123456789012", "");
    
    if (welcome != nullptr) {
        std::cout << "[Server String]: " << welcome << std::endl;
        
        // Free memory!
        qpapel::FreeString(welcome);
    } else {
        std::cerr << "Failed to fetch welcome message." << std::endl;
    }
}
```

### Protected String (License Key Required)

```cpp
#include <iostream>
#include "qPapelLib.h"

void FetchPremiumConfig(QPCTX ctx, const std::string& licenseKey) {
    // Fetch a protected string (license key parameter is required)
    char* configStr = qpapel::FetchString(ctx, "987654321098", licenseKey.c_str());
    
    if (configStr != nullptr) {
        std::cout << "Premium Config Value: " << configStr << std::endl;
        
        // Free memory!
        qpapel::FreeString(configStr);
    } else {
        char* err = qpapel::GetLastStatus(ctx);
        std::cerr << "Access denied or failed: " << (err ? err : "Unknown Error") << std::endl;
        if (err) qpapel::FreeString(err);
    }
}
```

## Use Cases

### Server-Controlled Feature Flag

```cpp
bool IsBetaEnabled(QPCTX ctx, const std::string& licenseKey) {
    char* betaFlag = qpapel::FetchString(ctx, "beta_flag_id", licenseKey.c_str());
    bool enabled = false;
    
    if (betaFlag != nullptr) {
        if (std::string(betaFlag) == "true") {
            enabled = true;
        }
        qpapel::FreeString(betaFlag);
    }
    return enabled;
}
```

### Server-Side Offsets (Hacking / Integrity)

```cpp
uintptr_t GetGameOffset(QPCTX ctx, const std::string& licenseKey) {
    char* offsetStr = qpapel::FetchString(ctx, "offset_access_id", licenseKey.c_str());
    uintptr_t offset = 0;
    
    if (offsetStr != nullptr) {
        // Example returned string: "0x1A2B3C"
        offset = std::stoull(offsetStr, nullptr, 16);
        qpapel::FreeString(offsetStr);
    }
    return offset;
}
```

## Access Control

| Configuration                 | Access                  | Use Case                                              |
| ----------------------------- | ----------------------- | ----------------------------------------------------- |
| **Force Key Check: Disabled** | Public (no license key) | Welcome messages, version checks, public news         |
| **Force Key Check: Enabled**  | Licensed users only     | Secret API keys, premium offsets, auth server configs |
