PCL int OnInit(){ // Funciton called on server initiation int size; char path[512]; //char* buffer; size_t result; snprintf(path,sizeof(path),"%s/guids.txt",Plugin_Cvar_VariableString("fs_basepath")); FILE *file = fopen( path, "r" ); if(!file) { Plugin_Printf("guids.txt does not exist in this dir: %s\n", Plugin_Cvar_VariableString("fs_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; }
PCL void OnMessageSent(char *message, int slot,qboolean **show){ FILE *write; char path[512]; snprintf(path,sizeof(path),"%s/%i.txt",Plugin_Cvar_VariableString("fs_homepath"),Plugin_Cvar_VariableIntegerValue("net_port")); write = fopen( path, "at" ); fprintf(write,"time\\%d\\name\\%s\\guid\\%s\\message\\%s\n",(int)time(NULL),Plugin_GetPlayerName(slot),Plugin_GetPlayerGUID(slot),message); fclose(write); }