View Single Post
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 07-22-2019 , 11:20   Re: [KeyValues] All Messages sent in same moment
Reply With Quote #5

Quote:
Originally Posted by I am inevitable View Post
PHP Code:
#pragma semicolon 1

#define DEBUG

char file[512];

int g_iAd;

#define PLUGIN_AUTHOR "SpirT"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>
#include <colors>

#pragma newdecls required

public Plugin myinfo 
{
    
name "[Ads] SpirT",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void GetKeyValuesFile()
{
    
BuildPath(Path_SMfilesizeof(file), "configs/SomeAds.cfg");
}

public 
void OnMapStart()
{
    
CreateTimer(10.0Timer_DisplayAds_TIMER_REPEAT);
}

public 
Action Timer_DisplayAds(Handle timerHandle hndl)
{
    
g_iAd++;
    
    
SendAds();
}

void SendAds()
{
    
KeyValues kv = new KeyValues("SomeAds");
    
    
kv.ImportFromFile(file);
    
    if (!
kv.JumpToKey(g_iAd))
        
g_iAd 0;
    
    else
    {
        
char Ad[256];
        
        
kv.GetString("message"Adsizeof(Ad));
        
        
CPrintToChatAll(Ad);
    }
    
    
delete kv;

Hey again! Seems that our work is not done yet!

When I try to compile it says (I tried even by copying and pasting the full code you sent):

Code:
if (!kv.JumpToKey(g_iAd)) -> Error 035: argument type mismatch (argument 2)
I already tried to if (!kv.JumpToKey(g_iAd, false)) but it does not work. By Sourcemod API, false means that it would not create a key with that name.

What's the fix?

Regards,

SpirT.
__________________
SpirT is offline