Erstellst du die Fahrzeuge bei OnGameModeInit?
Wenn ja, poste das bitte mal.
Beiträge von Jeffry
-
-
Hast du mal versucht den Range etwas zu erhöhen, anstatt 5?
Ändere außerdem:
return 0;
zu:
return -1;
Sowie
if(i == 0) return SendClientMessage(playerid,ROT,"Du bist nicht an einem Jobfahrzeug.");
zu:
if(i == -1) return SendClientMessage(playerid,ROT,"Du bist nicht an einem Jobfahrzeug.");Da es ja einen Index mit der 0 gibt.
-
Also geladen werden die Werte aus der Datenbank korrekt.
Das heißt, irgendwo zwischen dem Laden und dem Setzen ans Fahrzeug gehen die Daten verloren. Überschreibst du die Werte irgendwo oder setzt sie zu 0 zurück?
-
if(IsPlayerInVehicle(playerid, traktor[0]) || IsPlayerInVehicle(playerid, traktor[1]) || IsPlayerInVehicle(playerid, traktor[2]))
-
Da haben wir den Fehler. Du schreibst die Anzahl der Mitglieder per String in einen Integer. Das geht nicht.
Mache es so:
Function _GetMemberCount(fid)
{
new rows, fields;
cache_get_data(rows, fields);
format(fData[fid][fMemberInt] = rows;
return 1;
}Function _GetFracCarCount(fid)
{
new rows, fields;
cache_get_data(rows, fields);
fData[fid][fCarInt] = rows;
return 1;
} -
Kannst du bitte darauf verzichten, den gesamten Post mit Code zu zitieren? Das macht keinen Sinn und sieht einfach nur abartig aus. Danke.
Poste bitte, was der Server Log so ausgibt:
public LoadGangAutos()
{
new string[128];
mysql_free_result();
for(new i = 0; i < sizeof(GangAutoInfo); i++)
{
format(string, sizeof(string),"SELECT * FROM `gangautos` WHERE `SlotID` = '%d'", i);
mysql_query(string);
mysql_store_result();
if(mysql_num_rows() != 0)
{
new val[ 512 ];
mysql_fetch_field("CarID", val); GangAutoInfo[i][cID] = strval( val );
mysql_fetch_field("OwnerID", val); GangAutoInfo[i][cOwner] = strval( val );
mysql_fetch_field("TypID", val); GangAutoInfo[i][cTyp] = strval( val );
mysql_fetch_field("PosX", val); GangAutoInfo[i][cPosX] = floatstr( val );
mysql_fetch_field("PosY", val); GangAutoInfo[i][cPosY] = floatstr( val );
mysql_fetch_field("PosZ", val); GangAutoInfo[i][cPosZ] = floatstr( val );
mysql_fetch_field("Rotation", val); GangAutoInfo[i][cRot] = floatstr( val );
mysql_fetch_field("Farbe1", val); GangAutoInfo[i][cColor1] = strval( val );
mysql_fetch_field("Farbe2", val); GangAutoInfo[i][cColor2] = strval( val );
mysql_fetch_field("Status", val); GangAutoInfo[i][cStatus] = strval( val );
mysql_fetch_field("Tank", val); GangAutoInfo[i][cTank] = strval( val );
mysql_fetch_field("ReSpawnTime", val); GangAutoInfo[i][cReSpawnTime] = strval( val );
mysql_fetch_field("Tuning0", val); GangAutoInfo[i][cTuning][0] = strval ( val );
mysql_fetch_field("Tuning1", val); GangAutoInfo[i][cTuning][1] = strval ( val );
mysql_fetch_field("Tuning2", val); GangAutoInfo[i][cTuning][2] = strval ( val );
mysql_fetch_field("Tuning3", val); GangAutoInfo[i][cTuning][3] = strval ( val );
mysql_fetch_field("Tuning4", val); GangAutoInfo[i][cTuning][4] = strval ( val );
mysql_fetch_field("Tuning5", val); GangAutoInfo[i][cTuning][5] = strval ( val );
mysql_fetch_field("Tuning6", val); GangAutoInfo[i][cTuning][6] = strval ( val );
mysql_fetch_field("Tuning7", val); GangAutoInfo[i][cTuning][7] = strval ( val );
mysql_fetch_field("Tuning8", val); GangAutoInfo[i][cTuning][8] = strval ( val );
mysql_fetch_field("Tuning9", val); GangAutoInfo[i][cTuning][9] = strval ( val );
mysql_fetch_field("Tuning10", val); GangAutoInfo[i][cTuning][10] = strval ( val );
mysql_fetch_field("Tuning11", val); GangAutoInfo[i][cTuning][11] = strval ( val );
mysql_fetch_field("Tuning12", val); GangAutoInfo[i][cTuning][12] = strval ( val );
mysql_fetch_field("Tuning13", val); GangAutoInfo[i][cTuning][13] = strval ( val );
for(new j = 0; j <= 13; j++) printf("Fahrzeug %d: Tuning %d: %d", i, j, GangAutoInfo[i][cTuning][j]);
}
else
{
GangAutoInfo[i][cID] = -1;
GangAutoInfo[i][cOwner] = -1;
GangAutoInfo[i][cTyp] = -1;
GangAutoInfo[i][cPosX] = 0;
GangAutoInfo[i][cPosY] = 0;
GangAutoInfo[i][cPosZ] = 0;
GangAutoInfo[i][cRot] = 0;
GangAutoInfo[i][cColor1] = -1;
GangAutoInfo[i][cColor2] = -1;
GangAutoInfo[i][cStatus] = -1;
GangAutoInfo[i][cTank] = 50;
GangAutoInfo[i][cReSpawnTime] = 1800;
GangAutoInfo[i][cStandTime] = 0;
GangAutoInfo[i][cTuning][0] = 0;
GangAutoInfo[i][cTuning][1] = 0;
GangAutoInfo[i][cTuning][2] = 0;
GangAutoInfo[i][cTuning][3] = 0;
GangAutoInfo[i][cTuning][4] = 0;
GangAutoInfo[i][cTuning][5] = 0;
GangAutoInfo[i][cTuning][6] = 0;
GangAutoInfo[i][cTuning][7] = 0;
GangAutoInfo[i][cTuning][8] = 0;
GangAutoInfo[i][cTuning][9] = 0;
GangAutoInfo[i][cTuning][10] = 0;
GangAutoInfo[i][cTuning][11] = 0;
GangAutoInfo[i][cTuning][12] = 0;
GangAutoInfo[i][cTuning][13] = 0;
}
}
mysql_free_result();
return 1;
} -
Kannst du bitte mal dein GetFracMemberInt und das dazugehörige public posten?
Möglicherweise hängt es damit zusammen.Mir scheint es nach den Prints so, als wird der Wert irgendwo überschrieben.
-
Dann kannst du in deinem Befehl einfach die Werte von z.B.
pInfo[playerid][pBankGeld]
nutzen, du musst nicht auf die Datenbank zugreifen. Das wäre nicht zu empfehlen. -
Du hattest das mysql_free_result in der Schleife drin.
Versuche es so:
public LoadGangAutos()
{
new string[128];
mysql_free_result();
for(new i = 0; i < sizeof(GangAutoInfo); i++)
{
format(string, sizeof(string),"SELECT * FROM `gangautos` WHERE `SlotID` = '%d'", i);
mysql_query(string);
mysql_store_result();
if(mysql_num_rows() != 0)
{
new val[ 512 ];
mysql_fetch_field("CarID", val); GangAutoInfo[i][cID] = strval( val );
mysql_fetch_field("OwnerID", val); GangAutoInfo[i][cOwner] = strval( val );
mysql_fetch_field("TypID", val); GangAutoInfo[i][cTyp] = strval( val );
mysql_fetch_field("PosX", val); GangAutoInfo[i][cPosX] = floatstr( val );
mysql_fetch_field("PosY", val); GangAutoInfo[i][cPosY] = floatstr( val );
mysql_fetch_field("PosZ", val); GangAutoInfo[i][cPosZ] = floatstr( val );
mysql_fetch_field("Rotation", val); GangAutoInfo[i][cRot] = floatstr( val );
mysql_fetch_field("Farbe1", val); GangAutoInfo[i][cColor1] = strval( val );
mysql_fetch_field("Farbe2", val); GangAutoInfo[i][cColor2] = strval( val );
mysql_fetch_field("Status", val); GangAutoInfo[i][cStatus] = strval( val );
mysql_fetch_field("Tank", val); GangAutoInfo[i][cTank] = strval( val );
mysql_fetch_field("ReSpawnTime", val); GangAutoInfo[i][cReSpawnTime] = strval( val );
mysql_fetch_field("Tuning0", val); GangAutoInfo[i][cTuning][0] = strval ( val );
mysql_fetch_field("Tuning1", val); GangAutoInfo[i][cTuning][1] = strval ( val );
mysql_fetch_field("Tuning2", val); GangAutoInfo[i][cTuning][2] = strval ( val );
mysql_fetch_field("Tuning3", val); GangAutoInfo[i][cTuning][3] = strval ( val );
mysql_fetch_field("Tuning4", val); GangAutoInfo[i][cTuning][4] = strval ( val );
mysql_fetch_field("Tuning5", val); GangAutoInfo[i][cTuning][5] = strval ( val );
mysql_fetch_field("Tuning6", val); GangAutoInfo[i][cTuning][6] = strval ( val );
mysql_fetch_field("Tuning7", val); GangAutoInfo[i][cTuning][7] = strval ( val );
mysql_fetch_field("Tuning8", val); GangAutoInfo[i][cTuning][8] = strval ( val );
mysql_fetch_field("Tuning9", val); GangAutoInfo[i][cTuning][9] = strval ( val );
mysql_fetch_field("Tuning10", val); GangAutoInfo[i][cTuning][10] = strval ( val );
mysql_fetch_field("Tuning11", val); GangAutoInfo[i][cTuning][11] = strval ( val );
mysql_fetch_field("Tuning12", val); GangAutoInfo[i][cTuning][12] = strval ( val );
mysql_fetch_field("Tuning13", val); GangAutoInfo[i][cTuning][13] = strval ( val );
}
else
{
GangAutoInfo[i][cID] = -1;
GangAutoInfo[i][cOwner] = -1;
GangAutoInfo[i][cTyp] = -1;
GangAutoInfo[i][cPosX] = 0;
GangAutoInfo[i][cPosY] = 0;
GangAutoInfo[i][cPosZ] = 0;
GangAutoInfo[i][cRot] = 0;
GangAutoInfo[i][cColor1] = -1;
GangAutoInfo[i][cColor2] = -1;
GangAutoInfo[i][cStatus] = -1;
GangAutoInfo[i][cTank] = 50;
GangAutoInfo[i][cReSpawnTime] = 1800;
GangAutoInfo[i][cStandTime] = 0;
GangAutoInfo[i][cTuning][0] = 0;
GangAutoInfo[i][cTuning][1] = 0;
GangAutoInfo[i][cTuning][2] = 0;
GangAutoInfo[i][cTuning][3] = 0;
GangAutoInfo[i][cTuning][4] = 0;
GangAutoInfo[i][cTuning][5] = 0;
GangAutoInfo[i][cTuning][6] = 0;
GangAutoInfo[i][cTuning][7] = 0;
GangAutoInfo[i][cTuning][8] = 0;
GangAutoInfo[i][cTuning][9] = 0;
GangAutoInfo[i][cTuning][10] = 0;
GangAutoInfo[i][cTuning][11] = 0;
GangAutoInfo[i][cTuning][12] = 0;
GangAutoInfo[i][cTuning][13] = 0;
}
}
mysql_free_result();
return 1;
} -
Und da liegt mein Problem., Wollte ja die MySQL Sachen auslesen :'DD
Poste bitte dann ein Beispiel von deinem Login, wo du die Daten aus der Datenbank ausliest.
-
Dann liegt es daran, dass alle Tuning IDs auf 0 sind.
Wie sieht es denn in deiner Tabelle in der Datenbank aus (Screenshot)?
-
Sprich dann könnte ich mit deiner Methode auch die MySQL Daten auslesen?
Nein, die liest du ja auch dem Cache aus, und dieser muss erst separat aufgebaut werden, daher verlinkt man das in eine public-Funktion.
Da du hier aber nur einen Dialog anzeigst (nichts mit MySQL), ist das nicht notwendig. -
Aber dann hab ich doch umsonst ein Public und Forward erstellt oder irre ich mich.
Genau, das brauchst du hier nicht, das wäre nur unnötiger Aufwand.
-
Versuche es so:
// Command //
CMD:stats(playerid,params[])
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[Stats von %s]\nNickname: %s\nScore: %d\n Geld: %d", name, name, GetPlayerScore(playerid), GetPlayerMoney(playerid));
ShowPlayerDialog(playerid, DIALOG_STYLE_MSGBOX, DIALOG_STATS, name, string, "Weiter", "");
return 1;
} -
Dann musst du es so machen:
new traktor[2];traktor[0] = AddStaticVehicle(532,-72.7906,-74.4635,4.0844,44.5379,0,0);
traktor[1] = AddStaticVehicle(532,-64.5483,-61.9884,4.0948,64.5425,0,0); -
Wie sieht deine traktor Funktion aus?
-
Das liegt dann wahrscheinlich daran, dass die Textdraws zu dem Zeitpunkt noch nicht existieren.
Daher das Dummy Textdraw, somit merkst du das nicht. -
Bevor ich das mache, ist es richtig bei GangCarTune mit AddVehicleComponent(GangAutoInfo[h][cID],GangAutoInfo[h][cTuning][0]); ?
Stimmt, gut gesehen! Das habe ich vergessen abzuändern.
Habe es im Post drüber ausgebessert. i stimmt dort natürlich. -
Nimm hier bitte den Timer aus der Schleife raus, sonst wird der so oft gestartet, wie du Fahrzeuge erstellst.
public CreateGangAutos()
{
new string[255];
for(new h = 0; h < sizeof(GangAutoInfo); h++)
{
if(GangAutoInfo[h][cTyp] != -1)
{
if(GangAutoInfo[h][cStatus] == 0)
{
GangAutoInfo[h][cID] = CreateVehicle(GangAutoInfo[h][cTyp],GangAutoInfo[h][cPosX],GangAutoInfo[h][cPosY],GangAutoInfo[h][cPosZ],GangAutoInfo[h][cRot],GangAutoInfo[h][cColor1],GangAutoInfo[h][cColor2],GangAutoInfo[h][cReSpawnTime]);
Gas[GangAutoInfo[h][cID]] = GangAutoInfo[h][cTank];
format(string, sizeof(string), "{FFFF00}GLS-{21DD00}%d", GangAutoInfo[h][cID]);
SetVehicleNumberPlate(GangAutoInfo[h][cID],string);
}
}
}
SetTimer("GangCarTune", 3000, false);
return 1;
}Dann kannst du das hier auch so abändern:
forward GangCarTune();
public GangCarTune()
{
printf("GangCarTune gestartet.");
for(new h = 0; h < sizeof(GangAutoInfo); h++)
{
printf("Führe aus für h = %d", h);
for(new i = 0; i <= 13; i++)
{
if(GangAutoInfo[h][cTuning][i] != 0)
{
printf("Füge hinzu: Slot %d Item %d zu Fahrzeug %d", h, GangAutoInfo[h][cTuning][i], GangAutoInfo[h][cID]);
AddVehicleComponent(GangAutoInfo[h][cID],GangAutoInfo[h][cTuning][i]);
}
}
}
printf("Gangcar Tune ausgeführt.");
return 1;
}Poste dann bitte mal was im Server Log steht.
-
printf("ID: %d", _:JobcenterUnclicked[JobcenterListitem[playerid]]);
Das _: entfernt den Tag, somit kommt keine Warnung, falls eine kommen sollte, und gibt nur die ID ohne Tag weiter (Text: = Tag).