Hi,
ich brauch ma eure hilfe, mein game mod will er nicht laden und das erst nach einbau von der MySQL register hier ma alles
#define UPDATE_TIME 120 // Updatetimer für Userdb
#define MYSQL_HOST "localhost" // IP
#define MYSQL_USER "linux" // Benutzer
#define MYSQL_PASS "***********" // Passwort
#define MYSQL_DB "sampstunt"
OnGameModInit
samp_mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
samp_mysql_select_db(MYSQL_DB);
public split(const strsrc[], strdest[][], delimiter)
{
new iz, li;
new aNum;
new len;
while(iz <= strlen(strsrc))
{
if(strsrc[iz]==delimiter || iz==strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, iz, 128);
strdest[aNum][len] = 0;
li = iz+1;
aNum++;
}
iz++;
}
return 1;
}
stock MySQLCheck()
{
if(samp_mysql_ping() == 0)
{
return true;
}
else
{
samp_mysql_close();
samp_mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
samp_mysql_select_db(MYSQL_DB);
MySQLCheck();
}
return false;
}
OnGameModExit
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
GetPlayerName(i, PlayerName, sizeof(PlayerName));
if(PlayerInfo[i][Logged] == 1)
{
new playerid;
new Float:X;
new Float:Y;
new Float:Z;
GetPlayerPos(playerid,X,Y,Z);
format(query, sizeof(query), "UPDATE `spieler` SET `admin_level` = '%d',`money` = '%d', `position` = '%d' WHERE `PlayerName` '%s'",PlayerInfo[playerid][Admin], GetPlayerMoney(playerid), X,Y,Z);
samp_mysql_query(query);
}
}
}
OnPlayerConnect
GetPlayerIp(playerid,PlayerIP,20);
PlayerInfo[playerid][Admin] = 0;
PlayerInfo[playerid][Logged] = 0;
PlayerInfo[playerid][FalseLogins] = 0;
ServerInfo[sVisits]++;
if(samp_mysql_ping() != 0)
{
print("MYSQL reagiert nicht.");
print("Verbindung zu MYSQL wurde getrennt.");
format(string, sizeof(string), "Keine Verrbindung zu MySQL!");
SendClientMessage(playerid, COLOR_RED, string);
}
if(MySQLCheckUserExistance(playerid))
{
SendClientMessage(playerid, ADMIN_GREEN, "Dein Account existiert bereits! Du kannst dich nun mit /login <Passwort> einloggen.");
}
else
{
SendClientMessage(playerid,COLOR_ORANGE1, "Gib /register <Passwort> ein, um dir einen Account zu erstellen.");
}
return 1;
}
OnPlayerDisconnect
new str[256];
gActivePlayers[playerid]--;
numplayers--;
new Float:X;
new Float:Y;
new Float:Z;
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerPos(playerid,X,Y,Z);
if(PlayerInfo[playerid][Logged] == 1)
{
format(query, sizeof(query), "UPDATE `spieler` SET `admin_level` = '%d', `money` = '%d', `position` = '%d', WHERE `PlayerName` = '%s'", PlayerInfo[playerid][Admin],GetPlayerMoney(playerid), X,Y,Z);
samp_mysql_query(query);
}
if(reason == 0)
{
format(str, sizeof(str), " %s hat den Server verlassen. Grund: Absturz)", PlayerName);
SendClientMessageToAll(COLOR_GREY, str);
print(str);
ServerInfo[sTimeouts]++;
}
else if(reason == 1)
{
format(str, sizeof(str), " %s hat den Server verlassen. Grund: Keine Lust mehr", PlayerName);
SendClientMessageToAll(COLOR_GREY, str);
print(str);
}
else if(reason == 2)
{
format(str, sizeof(str), " %s hat den Server verlassen. Grund: Regelverstoß)", PlayerName);
SendClientMessageToAll(COLOR_GREY, str);
print(str);
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerState(i) == PLAYER_STATE_SPECTATING && gSpectateID[i] == playerid)
{
}
}
PlayerInfo[playerid][Admin] = 0;
PlayerInfo[playerid][Logged] = 0;
Register
if(strcmp(cmdtext, "/register", true) == 0)
{
new str[256];
new password[14], tmp[128], RPassword[14];
//tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,ADMIN_RED,"Gib /register <Passwort> ein, um dich zu registrieren!");
return 1;
}
password[13] = strval(tmp);
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
if(MySQLCheckUserExistance(playerid))
{
SendClientMessage(playerid,ADMIN_RED,"Dein Nickname ist bereits registriert, bitte log dich mit /login <Passwort> ein!");
return 1;
}
if(strfind(tmp, ">", true) != -1 || strfind(tmp, "<", true) != -1)
{
SendClientMessage(playerid,ADMIN_RED,"Falsches Zeichen im Passwort");
return 1;
}
if(strlen(tmp) > 5)
{
SendClientMessage(playerid,ADMIN_RED,"Dein Passwort kann nicht länger als 5 Zeichen sein!");
return 1;
}
samp_mysql_real_escape_string(tmp, RPassword);
format(query, sizeof(query), "INSERT INTO `spieler` (reg_id) VALUES (0)");
format(query, sizeof(query), "INSERT INTO `spieler` (name) VALUES (%s)",playername);
format(query, sizeof(query), "INSERT INTO `spieler` (password) VALUES (%s)",RPassword);
format(query, sizeof(query), "INSERT INTO `spieler` (admin_level) VALUES (0)");
format(query, sizeof(query), "INSERT INTO `spieler` (IP) VALUES (%s)",PlayerIP);
format(query, sizeof(query), "INSERT INTO `spieler` (money) VALUES (0)");
samp_mysql_query(query);
format(query, sizeof(query), "SELECT `reg_id` FROM `spieler` WHERE `PlayerName` = '%s'", PlayerName);
samp_mysql_query(query);
samp_mysql_store_result();
if(samp_mysql_num_rows() == 0)
{
format(str, sizeof(str), "Kann nicht in die Datenbank %s schreiben", MYSQL_DB);
SendClientMessage(playerid, COLOR_RED, str);
return 1;
}
SendClientMessage(playerid,ADMIN_GREEN,"Du hast dich erfolgreich registriert. Gib /login <Passwort> ein.");
return 1;
}
Login
if(strcmp(cmdtext, "/login", true) == 0)
{
new str[256];
new password[14], tmp[128];
//tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,ADMIN_RED,"Gib /login <Passwort> ein, um dich zu einzuloggen!");
return 1;
}
password[13] = strval(tmp);
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
if(PlayerInfo[playerid][Logged] == 1)
{
SendClientMessage(playerid,ADMIN_YELLOW,"Du bist bereits eingeloggt!");
return 1;
}
if(!MySQLCheckUserExistance(playerid))
{
SendClientMessage(playerid,ADMIN_RED,"Du bist noch nicht registriert, bitte registriere dich mit /register <Passwort>.");
return 1;
}
format(query, sizeof(query), "SELECT * FROM `spieler` WHERE `PlayerName` = '%s'", PlayerName);
samp_mysql_query(query);
samp_mysql_store_result();
samp_mysql_fetch_row(line);
new passwd[14];
samp_mysql_get_field("password", passwd);
if(strcmp(tmp, passwd, true) != 0)
{
if(PlayerInfo[playerid][FalseLogins] < 3)
{
PlayerInfo[playerid][FalseLogins] = PlayerInfo[playerid][FalseLogins] + 1;
format(str, sizeof(str), "Fehler: %s ist das falsche Passwort für den Account %s! (Warnung: Falsches Passwwort %d/3)", tmp, PlayerName, PlayerInfo[playerid][FalseLogins]);
SendClientMessage(playerid, ADMIN_RED, str);
}
else
{
PlayerInfo[playerid][FalseLogins] = 3;
format(str, sizeof(str), "Fehler: %s ist das falsche Passwort für den Account %s! (3/3 Warnung: Falsches Passwort voll)", tmp, PlayerName);
SendClientMessage(playerid, ADMIN_RED, str);
SendClientMessage(playerid, ADMIN_RED,"KICK: 3 falsche Loginversuche");
Kick(playerid);
}
return 1;
}
SendClientMessage(playerid,ADMIN_GREEN,"Du hast dich erfolgreich eingeloggt.");
PlayerInfo[playerid][Logged] = 1;
samp_mysql_get_field("position", str);
SetPlayerScore(playerid, strval(str));
samp_mysql_get_field("money", str);
GivePlayerMoney(playerid, strval(str));
samp_mysql_get_field("admin_level", str);
PlayerInfo[playerid][Admin] = strval(str);
samp_mysql_get_field("times_logged", str);
PlayerInfo[playerid][TimesLogged] = strval(str);
PlayerInfo[playerid][TimesLogged] += 1;
new smail[60];
samp_mysql_get_field("email", smail);
format(query, sizeof(query), "UPDATE `spieler` SET `times_logged` = '%d' WHERE `PlayerName` = '%s'", PlayerInfo[playerid][TimesLogged], PlayerName);
samp_mysql_query(query);
return 1;
}
wer kann mir nun weiter helfen?