Sehr geehrte Community,
ich habe jetzt mal angefangen Scripten zu lernen (Habe irgendwie lust dazu bekommen) ... Weil ich ja absolut keine Ahnung habe, habe ich mir das Tutorial von Jeffry angeschaut: [jTuT] MySQL R41-4 (Installation, XAMPP, Verwendung, Bedienung & Registrations-System)
Nun habe ich das Problem, dass er mein OnUserCheck nicht aufruft. Ich habe extra mit Prints gearbeitet, komme allerdings nur bis "TEST3"...
#include <a_samp>
#include <a_mysql>
//MySQL
#define DBHOST "127.0.0.1"
#define DBUSER ""
#define DBPW ""
#define DBDB ""
new MySQL:handle;
//DEFINES
#define PROJEKTNAME "Lala"
//FORWARDS
forward OnUserCheck(playerid);
//DIALOGE
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
//Globale Variablen
new string[256];
new query[256];
//ENUMS
enum pData{
p_id,
bool:pLoggedIn,
pName[MAX_PLAYER_NAME],
pLevel,
pMoney,
pKills,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pData];
main()
{
print("\n----------------------------------");
printf(" %s Selfmade Script", PROJEKTNAME);
print("----------------------------------\n");
}
public OnGameModeInit()
{
MySQL_ConnectSetup();
SetGameModeText("German Reallife");
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
print("TEST1");
if(!PlayerInfo[playerid][pLoggedIn])
{
print("TEST2");
mysql_format(handle, query, sizeof(query), "SELECT id FROM users WHERE name = '%e'", PlayerInfo[playerid][pName]);
mysql_pquery(handle, query, "OnUserCheck", "d", playerid);
}
print("TEST3");
return 1;
}
public OnPlayerConnect(playerid)
{
ResetPlayerStats(playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 0;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnUserCheck(playerid){
print("TEST 4");
return 1;
}
stock ResetPlayerStats(playerid){
PlayerInfo[playerid][p_id] = 0;
PlayerInfo[playerid][pLoggedIn] = false;
PlayerInfo[playerid][pLevel] = 0;
PlayerInfo[playerid][pMoney] = 0;
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][pDeaths] = 0;
GetPlayerName(playerid, PlayerInfo[playerid][pName], MAX_PLAYER_NAME);
format(string, sizeof(string), "{00D7FF}[SERVER BEITRITT] {FFFFFF}%s hat den Server betreten", SpielerName(playerid));
SendClientMessageToAll(0xFFFFFFFF, string);
return 1;
}
stock MySQL_ConnectSetup(ttl = 3){
print("[MYSQL] Verbindungsaufbau...");
mysql_log();
handle = mysql_connect(DBHOST, DBUSER, DBPW, DBDB);
if(mysql_errno(handle) != 0){
if(ttl > 1){
print("[MYSQL] Verbindung Fehlgeschlagen...");
printf("[MYSQL] Versuche erneute Verbindung. Verbindungsversuch: %d", ttl-1);
return MySQL_ConnectSetup(ttl-1);
}else{
print("[MYSQL] Es konnte keine Verbindung zur Datenbank Hergestellt werden.");
print("[MYSQL] Bitte prüfen Sie die Verbindungsdaten.");
print("[MYSQL] Server wird heruntergefahren.");
return SendRconCommand("exit");
}
}
printf("[MYSQL] Verbindung Erfolgreich! Verbindungsversuche: %d", _:handle);
return 1;
}
stock SpielerName(playerid){
new tmpName[MAX_PLAYER_NAME];
GetPlayerName(playerid, tmpName, sizeof(tmpName));
return tmpName;
}
Ich habe mit absicht die MySQL Daten rausgelassen.
//EDIT Ich benutze Version 0.3DL und MySQL halt R41-4 | Das ganze läuft auf meinem PC (Windows 10)
Mit freundlichen Grüßen
XonarZ