peace-maker / smrpg

A generic RPG plugin for SourceMod
88 stars 40 forks source link

SMRPG_AddClientExperience always returning false #339

Closed The-Doggy closed 4 years ago

The-Doggy commented 4 years ago

Sourcemod version: 1.11.0.6522 Metamod version: 1.11.0-dev+1130 Game: Half-Life 2: Deathmatch OS: Linux CentOS 7

Hi, I've been having issues with a plugin I made using smrpg not being able to use the SMRPG_AddClientExperience native because it's always returning false.

Here's the code I'm using to reproduce:

#include <smrpg>
#include <sdktools>

public void OnPluginStart()
{
    HookEntityOutput("npc_zombie", "OnDeath", NPC_Death);
    HookEntityOutput("npc_poisonzombie", "OnDeath", NPC_Death);
    HookEntityOutput("npc_headcrab", "OnDeath", NPC_Death);
    HookEntityOutput("npc_headcrab_black", "OnDeath", NPC_Death);
    HookEntityOutput("npc_headcrab_fast", "OnDeath", NPC_Death);
}

public void OnClientPutInServer(int Client)
{
    ServerCommand("z_enabled 1");
}

void NPC_Death(const char[] output, int caller, int activator, float delay)
{
    if(activator < 1 || activator > MaxClients || !IsClientInGame(activator)) return;

    char class[256];
    GetEntityClassname(caller, class, sizeof(class));
    ReplaceString(class, sizeof(class), "npc_", "", false);
    ReplaceString(class, sizeof(class), "poisonzombie", "poison zombie", false);
    ReplaceString(class, sizeof(class), "headcrab_black", "poison headcrab", false);
    ReplaceString(class, sizeof(class), "headcrab_fast", "fast headcrab", false);

    PrintToChat(activator, "You killed a %s", class);

    char reason[256];
    Format(reason, sizeof(reason), "Killing a %s", class);

    int exp = 20;
    if(!SMRPG_AddClientExperience(activator, exp, reason, true))
        PrintToServer("asdf");
}

Everytime I kill one of the NPC's I get the "You killed a (something npc)" message in chat but the native also returns false and "asdf" is always printed to the server console as well.

I have no errors in logs except for this one from chat_processor L 04/07/2020 - 16:45:32: [chat-processor.smx] Error parsing the flag message formatting config for game 'hl2mp', please verify its integrity.

Any help with this issue would be great, thanks!

The-Doggy commented 4 years ago

Err, sorry not sure why github doesn't like my code... I put it on pastebin so that it's somewhat readable lol https://pastebin.com/tyVaQDjf

peace-maker commented 4 years ago

Are you the only one on your test server? Try setting these convars to 0 smrpg_need_enemies and smrpg_enemies_not_afk. I got hung up on that a few times as well when testing new features 😅

You need to use 3 "`" on a separate line for larger code blocks.

The-Doggy commented 4 years ago

Ahh yes it was the convars messing it up 😛 Thanks for the help and the tip about code blocks 👍