wir haben nach dem Fehler gesucht und ihn eingrenzen können. Es scheint irgendetwas mit den mySQL Befehlen faul zu sein.
Solange ich den MySQL Teil aus dem Script lasse funktioniert alles einwandfrei. Ich habe nun folgendes gemacht und bin nach deinem MySQL R39-3 Tutorial vorgegangen.
Selbes Spiel von vorn.
Hier die Daten:
//Includes
#include <a_samp>
#include <a_mysql>
#include <ocmd>
#include <sscanf2>
#include <crashdetect>
//Globale Variable
new autosOhneMotor[] = {503, 510, 481}; // Fahrräder die keinen Motor benötigen!
new Text:Tacho_Label;
new dbhandle;
// FARB-DEFINITIONEN
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0005FF
#define COLOR_GREEN 0x00FF1EFF
#define COLOR_YELLOW 0xFFFA00FF
#define COLOR_BLUE 0x0005FFFF
//MySQL
#define db_host ""
#define db_user ""
#define db_pass ""
#define db_db ""
//Forwards
forward sekunde(); //Funktionsdeklaration
main()
{
print("\n----------------------------------");
print(" Running Gulasch - by the GulaschCrew\n ");
print("----------------------------------\n");
}
public OnGameModeInit()
{
//MySQL Verbindung
MySQL_SetupConnection();
AddStaticVehicle(451,1062.1882,-1785.8550,13.4800,74.2250, 181, 0);
AddStaticVehicle(451,1062.1998,-1791.7014,13.4933,98.0770,128,0);
AddStaticVehicle(451,1064.8956,-1798.0994,13.5066,112.5939,209,0);
//Zivispawn Map
CreateObject(2942,1087.1000000,-1803.6600000,13.2250000,0.0000000,0.0000000,179.5000000); //object(kmb_atm1) (1)
CreateObject(1233,1084.8000000,-1803.8000000,14.1400000,0.0000000,0.0000000,180.0000000); //object(noparkingsign1) (1)
CreateObject(2745,1079.9000000,-1782.7000000,13.7800000,0.0000000,0.0000000,0.0000000); //object(cj_stat_3) (1)
CreateObject(3462,1089.4000000,-1782.7000000,14.1530000,0.0000000,0.0000000,90.0000000); //object(csrangel_lvs) (1)
CreateObject(1215,1086.4500000,-1803.5601000,13.1000000,0.0000000,0.0000000,0.0000000); //object(airuntest_las) (1)
CreateObject(1215,1087.7000000,-1803.5601000,13.1000000,0.0000000,0.0000000,0.0000000); //object(airuntest_las) (2)
CreateObject(3660,1091.1000000,-1780.7600000,14.5000000,0.0000000,0.0000000,359.8200000); //object(lasairfbed_las) (1)
CreateObject(3660,1071.4650000,-1780.7300000,14.5000000,0.0000000,0.0000000,0.0000000); //object(lasairfbed_las) (2)
CreateObject(3873,1110.0000000,-1795.0000000,29.9490000,0.0000000,0.0000000,6.9900000); //object(silicon04_sfs) (1)
CreateObject(1346,1091.2000000,-1803.3000000,13.8900000,0.0000000,0.0000000,180.0000000); //object(cj_phone_kiosk2) (1)
CreateObject(1215,1092.6000000,-1800.4000000,13.0500000,0.0000000,0.0000000,0.0000000); //object(airuntest_las) (3)
CreateObject(1215,1091.9000000,-1794.1000000,13.0500000,0.0000000,0.0000000,0.0000000); //object(airuntest_las) (4)
CreateObject(1215,1093.3000000,-1787.9000000,13.0800000,0.0000000,0.0000000,0.0000000); //object(airuntest_las) (5)
//Polizeistation
CreateObject(984,1534.6000000,-1688.1000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(fenceshit2) (1)
CreateObject(984,1534.6000000,-1701.0000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(fenceshit2) (2)
CreateObject(984,1534.6000000,-1713.8000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(fenceshit2) (3)
CreateObject(984,1537.5000000,-1670.2998000,13.0500000,0.0000000,0.0000000,0.0000000); //object(fenceshit2) (4)
CreateObject(983,1537.5000000,-1678.3000000,13.1000000,0.0000000,0.0000000,0.0000000); //object(fenceshit3) (4)
CreateObject(984,1534.7000000,-1657.5000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(fenceshit2) (5)
CreateObject(984,1534.7000000,-1644.7000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(fenceshit2) (6)
CreateObject(1214,1535.4000000,-1663.6000000,12.5000000,0.0000000,0.0000000,0.0000000); //object(bollard) (1)
CreateObject(1214,1536.7000000,-1663.6000000,12.5000000,0.0000000,0.0000000,0.0000000); //object(bollard) (2)
CreateObject(1214,1536.7000000,-1681.8000000,12.5000000,0.0000000,0.0000000,0.0000000); //object(bollard) (3)
CreateObject(1214,1535.4000000,-1681.8000000,12.5000000,0.0000000,0.0000000,0.0000000); //object(bollard) (4)
CreateObject(2942,1550.5000000,-1679.5000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(kmb_atm1) (1)
CreateObject(2942,1549.6000000,-1679.5000000,13.2000000,0.0000000,0.0000000,0.0000000); //object(kmb_atm1) (2)
CreateObject(980,1587.9100000,-1637.9004000,15.1990000,0.0000000,358.9000000,0.0000000); //object(airportgate) (1)
CreateObject(2920,1544.7002000,-1630.7002000,13.0700000,0.0000000,0.0000000,0.0000000); //object(police_barrier) (1) polizeischranke geöffnet
CreateObject(3475,1545.1000000,-1620.6000000,14.9000000,0.0000000,0.0000000,180.0000000); //object(vgsn_fncelec_pst) (1)
CreateObject(3475,1545.2000000,-1634.8000000,14.9000000,0.0000000,0.0000000,180.0000000); //object(vgsn_fncelec_pst) (2)
CreateObject(3934,1563.0000000,-1648.8000000,27.4000000,0.0000000,0.0000000,0.0000000); //object(helipad01) (1)
CreateObject(3934,1561.1787100,-1648.0390600,27.2191000,0.0000000,0.0000000,0.0000000); //object(helipad01) (2)
CreateObject(3934,1570.0097700,-1688.7812500,27.2125700,0.0000000,0.0000000,0.0000000); //object(helipad01) (3)
CreateObject(3934,1562.8000000,-1703.0000000,27.4000000,0.0000000,0.0000000,0.0000000); //object(helipad01) (4)
CreateObject(2886,1579.8000500,-1582.3000500,15.7000000,0.0000000,0.0000000,0.0000000); //object(sec_keypad) (1)
CreateObject(2886,1582.5000000,-1637.8000000,14.2000000,0.0000000,0.0000000,178.0000000); //object(sec_keypad) (2)
CreateObject(16360,1553.1000000,-1606.2000000,12.4000000,0.0000000,0.0000000,0.0000000); //object(desn2_tsfuelpay) (1)
CreateObject(1329,1553.1000000,-1609.3000000,12.9000000,0.0000000,0.0000000,0.0000000); //object(binnt13_la) (1)
CreateObject(1331,1574.7000000,-1633.6000000,13.4000000,0.0000000,0.0000000,0.0000000); //object(binnt01_la) (1)
//CreateObject(2920,1544.7002000,-1630.7889000,13.1500000,270.0000000,0.0000000,0.0000000); //object(police_barrier) (2) Polizeischranke geschlossen
//Infosymbol Zivispawn
CreatePickup(1239, 1, 1093.9086,-1791.2839,13.6191, -1);
Create3DTextLabel("Zivispawn", COLOR_WHITE, 1093.9086,-1791.2839,13.6191, 40.0, 0, 0);
//ServerName SAMP Client
SetGameModeText("GulaschCrewReloaded");
//Ausschalten der automatischen Fahrzeugsteuerung
ManualVehicleEngineAndLights();
//Timer
SetTimer("sekunde",500,true);
//Tacho Textdraw
Tacho_Label = TextDrawCreate(503.000000, 389.000000, "");
TextDrawBackgroundColor(Tacho_Label, 255);
TextDrawFont(Tacho_Label, 1);
TextDrawLetterSize(Tacho_Label, 0.500000, 1.000000);
TextDrawColor(Tacho_Label, -1);
TextDrawSetOutline(Tacho_Label, 0);
TextDrawSetProportional(Tacho_Label, 1);
TextDrawSetShadow(Tacho_Label, 1);
TextDrawSetSelectable(Tacho_Label, 0);
//Spielerskins
AddPlayerClass(1, 1093.9086,-1791.2839,13.6191,272.2692, 0, 0, 0, 0, 0, 0);
AddPlayerClass(2, 1093.9086,-1791.2839,13.6191,272.2692, 0, 0, 0, 0, 0, 0);
AddPlayerClass(4, 1093.9086,-1791.2839,13.6191,272.2692, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public sekunde() //Timer
{
new string[128];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(!IsPlayerInAnyVehicle(i)) continue;
format(string,sizeof(string),"%ikm/h",getPlayerSpeed(i));
TextDrawSetString(Tacho_Label, string);
}
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
//Spieler Spawn Position und Blick
SetPlayerPos(playerid,362.5642,-2030.0568,7.8301);
SetPlayerCameraPos(playerid, 365.8514,-2029.9287,7.6719);
SetPlayerCameraLookAt(playerid,362.5642,-2030.0568,7.8301);
SetPlayerFacingAngle(playerid,272.2692);
return 1;
}
public OnPlayerConnect(playerid)
{
//Willkommenstext
new string[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(string,256,"~r~Hello %s\n\n Willkommen auf Gulasch Crew Reloadet!",name);
GameTextForPlayer(playerid,string,10000,6);
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)
{
new vID = GetPlayerVehicleID(playerid);
new vModel = GetVehicleModel(vID);
for( new i = 0; i < sizeof(autosOhneMotor); i++ )
{
if (autosOhneMotor[i] != vModel ) continue;
new tmp_engine,
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
//Motor immer einschalten
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
SetVehicleParamsEx(vID, 1, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
TextDrawShowForPlayer(playerid, Tacho_Label);//Anzeigen des Tachos
}
else
{
TextDrawHideForPlayer(playerid, Tacho_Label);
}
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 1;
}
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;
}
//MySQL
stock MySQL_SetupConnection(ttl = 3)
{
print("[MySQL] Verbindungsaufbau...");
mysql_log(LOG_ERROR | LOG_WARNING); //<- Kommentar vor mysql_log entfernen um den MySQL Debug-Modus zu aktivieren
dbhandle = mysql_connect(db_host, db_user, db_db, db_pass);
//Prüfen und gegebenenfalls wiederholen
if(mysql_errno(dbhandle) != 0)
{
//Fehler im Verbindungsaufbau, prüfe ob ein weiterer Versuch gestartet werden soll
if(ttl > 1)
{
//Versuche erneut eine Verbindung aufzubauen
print("[MySQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.");
printf("[MySQL] Starte neuen Verbindungsversuch (TTL: %d).", ttl-1);
return MySQL_SetupConnection(ttl-1);
}
else
{
//Abbrechen und Server schließen
print("[MySQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.");
print("[MySQL] Bitte prüfen Sie die Verbindungsdaten.");
print("[MySQL] Der Server wird heruntergefahren.");
return SendRconCommand("exit");
}
}
printf("[MySQL] Die Verbindung zur Datenbank wurde erfolgreich hergestellt! Handle: %d", dbhandle);
return 1;
}
//-------Eigene Commands------------------------
getPlayerSpeed(playerid) //Auswertung und Berechnung der aktuellen Geschwindigkeit.
{
new Float:x, Float:y, Float:z, Float:rtn; //Benötigten Variablen
if ( IsPlayerInAnyVehicle(playerid) ) //wenn im Fahrzeug
{
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
}
else //Wenn nicht im Fahrzeug
{
GetPlayerVelocity(playerid, x, y, z);
}
rtn = floatsqroot( x*x + y*y + z*z ); //Berechnen der Geschwindigkeit
return floatround( (rtn * 100 * 1.61) ); // Zurückgeben der Geschw. mit gerundetem FLoatwert und umrechnung in KM/h
}
ocmd:motor(playerid,param[])
{
if( GetPlayerState(playerid) != PLAYER_STATE_DRIVER ) return
SendClientMessage(playerid,COLOR_RED, "Du bist nicht der Fahrer eines Fahrzeugs");
new vID = GetPlayerVehicleID(playerid),
tmp_engine,
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
//Motor an/aus
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_engine == 1) //Wenn schon an mach aus
{
tmp_engine = 0;
}
else //Wenn aus mach an
{
tmp_engine = 1;
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
return 1;
}
ocmd:licht(playerid,param[])
{
if( GetPlayerState(playerid) != PLAYER_STATE_DRIVER ) return
SendClientMessage(playerid,COLOR_RED, "Du bist nicht der Fahrer eines Fahrzeugs");
new vID = GetPlayerVehicleID(playerid),
tmp_engine,
tmp_lights,
tmp_alarm,
tmp_doors,
tmp_bonnet,
tmp_boot,
tmp_objective;
//Motor an/aus
GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_lights == 1) //Wenn schon an mach aus
{
tmp_lights = 0;
}
else //Wenn aus mach an
{
tmp_lights = 1;
}
SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
return 1;
}
ocmd:spawn(playerid,param[])
{
SetPlayerPos(playerid,1093.9086,-1791.2839,13.6191);
SetPlayerFacingAngle(playerid,180);
SendClientMessage(playerid,0x00FF00FF,"ERFOLGREICH! Du befindest dich nun am Zivispawn.");
return 1;
}
Alles anzeigen