View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-17-2020 , 06:21   Re: [CSGO] Why MY Repeat Timer Stop PrintMessage
Reply With Quote #6

PHP Code:


#include <sdktools>

File myfile;

public 
void OnPluginStart()
{
    
char path[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMpathsizeof(path), "configs/badapple.txt");
    
    if(!
FileExists(path)) SetFailState("Fail: %s"path);
    
    
myfile OpenFile(path"r");
    
    if(
myfile == nullSetFailState("Fail! File is null");


    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{

    if(
client != 0) return Plugin_Handled;

    if(
myfile.EndOfFile())
    {
        
myfile.Seek(0,0);
    }

    
CreateTimer(0.01delayclientTIMER_REPEAT);

    return 
Plugin_Handled;
}


public 
Action delay(Handle timerint client)
{

    if(
myfile.EndOfFile()) return Plugin_Stop;

    
char line[9000];
    
char buffer[9000];
    
int a 0;

    for(
int x 060x++)
    {
        
myfile.ReadLine(linesizeof(line));
        
strlen(line);
        
        if(
0line[a-1]='\0';
        
        
PrintToServer(line);
    }
    
    

    
    
    return 
Plugin_Continue;

Sending to player console will cause buffer overflow errors.
__________________
Do not Private Message @me
Bacardi is offline