also wie der Titel es schon sagt erhalte ich falsche Informationsrückgabe.
.h
PHP Code:
#pragma once
#include <iostream>
#include <string>
#include <vector>
#define MAX_CHATLINES 300
using namespace std;
struct ChatLines {
char _chatline[256];
};
extern struct ChatLines chatlines[MAX_CHATLINES];
class ChatlogManagement {
public:
// variables
char chatlogPath[350];
int chatlogSize = 0;
vector<string> chatlog;
// prototypes
void CreateChatlogPath();
void LoadChatlogs();
int API_GetChatLine(int line, char *&content);
};
PHP Code:
#include <Windows.h>
#include <Shlobj.h>
#include <fstream>
#include "ChatlogManagement.h"
#include "Memory.h"
extern Memory _Memory;
struct ChatLines chatlines[MAX_CHATLINES];
void ChatlogManagement::CreateChatlogPath() {
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, chatlogPath);
strcat_s(chatlogPath, "\\GTA San Andreas User Files\\SAMP\\chatlog.txt");
}
void ChatlogManagement::LoadChatlogs() {
ifstream filesize(ChatlogManagement::chatlogPath, ifstream::ate | ifstream::binary);
if (filesize.is_open()) {
ChatlogManagement::chatlogSize = (int)filesize.tellg();
filesize.close();
}
ifstream file(ChatlogManagement::chatlogPath);
if (file.is_open()) {
string _line;
while (getline(file, _line)) {
_line = _line.substr(11);
ChatlogManagement::chatlog.push_back(_line);
}
reverse(ChatlogManagement::chatlog.begin(), ChatlogManagement::chatlog.end());
file.close();
}
}
int ChatlogManagement::API_GetChatLine(int line, char *&content) {
if (_Memory.CheckHandles() == 1) {
char _tmpchar[256];
int _tmpsize;
ifstream filesize(chatlogPath, ifstream::ate | ifstream::binary);
if (filesize.is_open()) {
_tmpsize = (int)filesize.tellg();
filesize.close();
}
ifstream file(chatlogPath);
if (file.is_open()) {
if (_tmpsize != chatlogSize) {
file.seekg(chatlogSize, ios_base::beg);
string _line;
while (getline(file, _line)) {
_line = _line.substr(11);
chatlog.insert(chatlog.begin(), _line);
}
}
file.close();
chatlogSize = _tmpsize;
sprintf_s(_tmpchar, "%s", chatlog[line]);
memcpy(content, _tmpchar, sizeof(_tmpchar));
return 1;
}
}
return _Memory.CheckHandlesErrorCode;
}
Jedenfalls Funktioniert es bei ihm nur wenn ich es Abfrage erhalte ich das hier als Rückgabeinformation:
[11:54:32] RivathaX: Test
[11:54:34] (( RivathaX sagt: Last Line: ¸+$ ))
Und so rufe ich die Funktion auf
GetChatLine(0,line)
SendChat("/b Last Line: " . line)
Jedenfalls erhalte ich nicht genau das was in der Zeile zuvor bzw. die Zeile die ich vorgegeben habe 1 zu 1 zurück.
Ich bitte daher um eure Hilfe.