void Antispam_Initialize()
{
    if(data.players != NULL){
	Plugin_Free(data.players); // just in case, Plugin_Free is safe to be called on unknown pointers and on already freed pointers
    }
    data.maxPlayers = Plugin_GetSlotCount();
    data.players = (userData_t *)Plugin_Malloc(sizeof(userData_t)*data.maxPlayers);
    memset(data.players,0x00,sizeof(userData_t)*data.maxPlayers);
}
示例#2
0
void G_SayCensor_Init()
{
	fileHandle_t file;
	int read;
	badwordsList_t *this;
	qboolean exactmatch;
	char buff[24];
	char line[24];
	char* linept;
	register int i=0;

        Plugin_FS_SV_FOpenFileRead("badwords.txt",&file);
        if(!file){
            Plugin_Printf("Censor_Plugin: Can not open badwords.txt for reading\n");
            return;
        }
        for(i = 0; ;i++){
            read = Plugin_FS_ReadLine(buff,sizeof(buff),file);

            if(read == 0){
                Plugin_Printf("%i lines parsed from badwords.txt\n",i);
                Plugin_FS_FCloseFile(file);
                return;
            }
            if(read == -1){
                Plugin_Printf("Can not read from badwords.txt\n");
                Plugin_FS_FCloseFile(file);
                return;
            }

            Q_strncpyz(line,buff,sizeof(line));
            linept = line;

            if(*linept == '#'){
                exactmatch = qtrue;
                linept++;
            }else{
                exactmatch = qfalse;
            }

            this = Plugin_Malloc(sizeof(badwordsList_t));
            if(this){
                this->next = badwords;
                this->exactmatch = exactmatch;
                Q_strncpyz(this->word,linept,strlen(linept));
            	badwords = this;
	    }
        }
		Plugin_Printf("Censor: init complete.\n");
}
示例#3
0
PCL int OnInit(){	// Funciton called on server initiation

	int size;
	char path[512];
	//char* buffer;
	size_t result;
	char basepath[512];
	Plugin_Cvar_VariableString("fs_basepath", basepath, sizeof(basepath));

	snprintf(path,sizeof(path),"%s/guids.txt",basepath);

	FILE *file = fopen( path, "r" );

	if(!file)
	{
		Plugin_Printf("guids.txt does not exist in this dir: %s\n", basepath);
		return;
	}

	fseek(file, 0, SEEK_END);

	size = ftell(file);

	rewind(file);

	buffer = Plugin_Malloc(sizeof(char) * (size + 1));

	if(buffer == NULL)
	{
		Plugin_Printf("Memory error\n");
		return;
	}

	memset(buffer, 0, sizeof(char) * (size + 1));

	result = fread (buffer,1,size,file);

	if(result != size)
	{
		Plugin_Printf("Reading has resulted an error\n");
		return;
	}

	//Plugin_Printf("Debug from plugin %s", buffer);

	fclose (file);
	return 0;
}