Guten Abend ich möchte in meinem Spawnvehicle befehl es verhindern wenn ein Trailer angekoppelt ist das er dann spawn
wie mach ich das am besten ?
for(new v=0; v<MAX_VEHICLES; v++)
{
if(!IsVehicleEmpty(v))continue;
{
SetVehicleToRespawn(v);
}
}
Guten Abend ich möchte in meinem Spawnvehicle befehl es verhindern wenn ein Trailer angekoppelt ist das er dann spawn
wie mach ich das am besten ?
for(new v=0; v<MAX_VEHICLES; v++)
{
if(!IsVehicleEmpty(v))continue;
{
SetVehicleToRespawn(v);
}
}
So am besten:
for(new v=GetVehiclePoolSize(); v!=0; v--)
{
if(IsTrailerAttachedToVehicle(v) || IsTrailer(v)) continue; //Wenn Trailer dran ist, wird das Fahrzeug übersprungen (oder wenn es ein Trailer ist :D)
SetVehicleToRespawn(v);
}
//Schreib unten die Funktion noch hin:
stock IsTrailer(v)
{
switch(GetVehicleModel(v)) {
case 435,450,569,570,584,590,591,606,607,608,610,611: return 1;
}
return 0;
}
Alles anzeigen
Mit "GetVehiclePos" kann man ja die Fahrzeugpositionen herausfinden, wenn man im Fahrzeug ist.
Ich möchte aber das beim Timer alle Fahrzeugpositionen abspeichert, egal ob man im Fahrzeug sitzt oder nicht.
Brauche ich dafür eine Schleife?
Brauchst du nicht, solltest du aber so machen. Ohne eine Schleife wäre es bischen viel schreibarbeit:
new Float:x,Float:y,Float:z;
GetVehiclePos(1,x,y,z);
//speichern
GetVehiclePos(2,x,y,z);
//speichern
GetVehiclePos(3,x,y,z);
// speichern ... bis MAX_VEHICLES - 1
Brauchst du nicht, solltest du aber so machen. Ohne eine Schleife wäre es bischen viel schreibarbeit:
new Float:x,Float:y,Float:z;GetVehiclePos(1,x,y,z);//speichernGetVehiclePos(2,x,y,z);//speichernGetVehiclePos(3,x,y,z);// speichern ... bis MAX_VEHICLES - 1
Ahhhh ja kk das wäre wirklich schreibarbeit...
Wenn ich jetzt eine Schleife machen würde ginge es eventuell so?
for(new x = 0; x < MaxVeh; x++)
{
new Float: X, Float: Y, Float: Z;
GetVehiclePos(/* Was müsste ich hier einsetzen? */, X, Y, Z);
format(query, sizeof(query), "UPDATE fahrzeuge (PosX, PosY, PosZ) VALUES ('%f', '%f', '%f') WHERE Name ='%s');", X, Y, Z, SpielerName(playerid))
mysql_function_query(dbhandle, query, false, "", "");
}
for(new i = 0; i < MaxVeh; i++)
{
new Float: X, Float: Y, Float: Z;
GetVehiclePos(i, X, Y, Z);
format(query, sizeof(query), "UPDATE fahrzeuge SET PosX = '%f', PosY = '%f', PosZ = '%f' WHERE id ='%i';", X, Y, Z, i)
mysql_function_query(dbhandle, query, false, "", "");
}
for(new i = 0; i < MaxVeh; i++){ new Float: X, Float: Y, Float: Z; GetVehiclePos(i, X, Y, Z); format(query, sizeof(query), "UPDATE fahrzeuge SET PosX = '%f', PosY = '%f', PosZ = '%f' WHERE id ='%i';", X, Y, Z, i) mysql_function_query(dbhandle, query, false, "", "");}
Ich habe diesbezüglich ein Problem @Jeffry.
Es wird nicht gespeichert...
Folgendes hat der Printer ausgeschrieben:
[12:31:02] UPDATE fahrzeuge SET PosX = '0.000000', PosY = '0.000000', PosZ = '0.000000' WHERE CarModel = '0'
[12:31:02] UPDATE fahrzeuge SET PosX = '1461.199951', PosY = '-2224.800048', PosZ = '13.300000' WHERE CarModel = '1'
[12:31:02] UPDATE fahrzeuge SET PosX = '1457.800048', PosY = '-2224.699951', PosZ = '13.300000' WHERE CarModel = '2'
[12:31:02] UPDATE fahrzeuge SET PosX = '1454.500000', PosY = '-2224.699951', PosZ = '13.300000' WHERE CarModel = '3'
Diese "1,2,3" sind komisch, denn in der Datenbank sind die Spalten "ID, Carmodel" nicht auf 1-3.
Das verwirrt mich gerade etwas ...
Wie sieht deine Datenbank aus (Screenshot) und wie lädst du die Fahrzeuge aus der Datenbank (Code)?
Ich habe mal paar Spalten gerade umbenannt, sonst verwecksle ich was
Screenshot:
Screenshot (185).png
Ladefunktion:
Function OnPlayerCarLogin(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
for(new x = 0; x < num_rows; x++)
{
if(!Dtc_PlayerHaveCar[playerid][x])
{
Dtc_PlayerHaveCar[playerid][x] = 1;
//Dtc_PlayerKey[playerid];
PlayerCar[playerid][x][CarId] = cache_get_field_content_int(x,"CarId",dbhandle);
PlayerCar[playerid][x][CarModel] = cache_get_field_content_int(x,"CarModel",dbhandle);
PlayerCar[playerid][x][CarPos_x] = cache_get_field_content_float(x,"CarPos_x",dbhandle);
PlayerCar[playerid][x][CarPos_y] = cache_get_field_content_float(x,"CarPos_y",dbhandle);
PlayerCar[playerid][x][CarPos_z] = cache_get_field_content_float(x,"CarPos_z",dbhandle);
PlayerCar[playerid][x][CarRotate] = cache_get_field_content_float(x,"CarRotate",dbhandle);
PlayerCar[playerid][x][CarNitro] = cache_get_field_content_int(x,"CarNitro",dbhandle);
PlayerCar[playerid][x][CarHyd] = cache_get_field_content_int(x,"CarHyd",dbhandle);
PlayerCar[playerid][x][CarAusp] = cache_get_field_content_int(x,"CarAusp",dbhandle);
PlayerCar[playerid][x][CarSideL] = cache_get_field_content_int(x,"CarSideL",dbhandle);
PlayerCar[playerid][x][CarSideR] = cache_get_field_content_int(x,"CarSideR",dbhandle);
PlayerCar[playerid][x][CarFB] = cache_get_field_content_int(x,"CarFB",dbhandle);
PlayerCar[playerid][x][CarRB] = cache_get_field_content_int(x,"CarRB",dbhandle);
PlayerCar[playerid][x][CarSpoiler] = cache_get_field_content_int(x,"CarSpoiler",dbhandle);
PlayerCar[playerid][x][CarRoof] = cache_get_field_content_int(x,"CarRoof",dbhandle);
PlayerCar[playerid][x][CarHood] = cache_get_field_content_int(x,"CarHood",dbhandle);
PlayerCar[playerid][x][CarVents] = cache_get_field_content_int(x,"CarVents",dbhandle);
PlayerCar[playerid][x][CarLamps] = cache_get_field_content_int(x,"CarLamps",dbhandle);
PlayerCar[playerid][x][CarPJ] = cache_get_field_content_int(x,"CarPJ",dbhandle);
PlayerCar[playerid][x][CarC1] = cache_get_field_content_int(x,"CarC1",dbhandle);
PlayerCar[playerid][x][CarC2] = cache_get_field_content_int(x,"CarC2",dbhandle);
PlayerCar[playerid][x][CarArrest] = cache_get_field_content_int(x,"CarArrest",dbhandle);
PlayerCar[playerid][x][CarPreis] = cache_get_field_content_int(x,"CarPreis",dbhandle);
PlayerCar[playerid][x][CarDiesel] = cache_get_field_content_int(x,"CarDiesel",dbhandle);
PlayerCar[playerid][x][CarBenzin] = cache_get_field_content_int(x,"CarBenzin",dbhandle);
PlayerCar[playerid][x][CarSuperDiesel] = cache_get_field_content_int(x,"CarSuperDiesel",dbhandle);
cache_get_field_content(x, "Plate", PlayerCar[playerid][x][Plate], dbhandle, 25);
PlayerCarSpawn(playerid,x);
}
}
return 1;
}
Alles anzeigen
Poste bitte noch dein PlayerCarSpawn.
Function PlayerCarSpawn(playerid,Slot)
{
if(IsPlayerConnected(playerid))
{
if(Dtc_PlayerHaveCar[playerid][Slot])
{
PlayerCar[playerid][Slot][CarId] = CreateVehicle(PlayerCar[playerid][Slot][CarModel],PlayerCar[playerid][Slot][CarPos_x],PlayerCar[playerid][Slot][CarPos_y],PlayerCar[playerid][Slot][CarPos_z],PlayerCar[playerid][Slot][CarRotate],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2], 60000);/*vehicle spawn*/
SetVehicleNumberPlate(PlayerCar[playerid][Slot][CarId], PlayerCar[playerid][Slot][Plate]);
ChangeVehicleColor(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2]);
if(PlayerCar[playerid][Slot][CarPJ] >= 0) {ChangeVehiclePaintjob(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarPJ]);}
if(PlayerCar[playerid][Slot][CarNitro] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarNitro]);}
if(PlayerCar[playerid][Slot][CarHyd] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHyd]);}
if(PlayerCar[playerid][Slot][CarWheel] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarWheel]);}
if(PlayerCar[playerid][Slot][CarAusp] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarAusp]);}
if(PlayerCar[playerid][Slot][CarSideL] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideL]);}
if(PlayerCar[playerid][Slot][CarSideR] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideR]);}
if(PlayerCar[playerid][Slot][CarFB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarFB]);}
if(PlayerCar[playerid][Slot][CarRB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRB]);}
if(PlayerCar[playerid][Slot][CarSpoiler] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSpoiler]);}
if(PlayerCar[playerid][Slot][CarRoof] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRoof]);}
if(PlayerCar[playerid][Slot][CarHood] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHood]);}
if(PlayerCar[playerid][Slot][CarVents] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarVents]);}
if(PlayerCar[playerid][Slot][CarLamps] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarLamps]);}
if(Dtc_LockOnSpawn)
{
Dtc_Carlock[PlayerCar[playerid][Slot][CarId]] = 1;
Dtc_LockCar(PlayerCar[playerid][Slot][CarId]);
}
//SetVehicleNumberPlate(PlayerCar[playerid][Slot][CarId], PlayerCar[playerid][Slot][Plate]);
//SetVehicleToRespawn(PlayerCar[playerid][Slot][CarId]);
}
}
}
Alles anzeigen
Füge beim OnPlayerCarLogin das ein: PlayerCar[playerid][x][id] = cache_get_field_content_int(x,"id",dbhandle);
Im Enum zu PlayerCar: id,
Und das Speichern dann so:
for(new i = 0; i < MaxVeh; i++)
{
new Float: X, Float: Y, Float: Z;
GetVehiclePos(PlayerCar[playerid][i][CarId], X, Y, Z);
format(query, sizeof(query), "UPDATE fahrzeuge SET PosX = '%f', PosY = '%f', PosZ = '%f' WHERE id ='%i';", X, Y, Z, PlayerCar[playerid][i][id])
mysql_function_query(dbhandle, query, false, "", "");
}
Hi ich habe ein Radio System gemacht, und wollte jetzt wissen wie ich es machen kann wenn man aus dem Fahrzeug Aussteigt und wieder ein, das die selbe Musik/Radiostream kommt
und wie kann ich denn gewählten Stream wieder Streamen?
Poste mal dein Befehl dann ist es nämlich einfacher dir zu helfen.
COMMAND:radio(playerid,params[])
{
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,ROT,"Du bist in keinem Fahrzeug!");
if(GetPlayerVehicleSeat(playerid) != 0)return SendClientMessage(playerid,ROT,"Nicht der Fahrer des Fahrzeugs.");
{
new mainstring[1000];
new string[200];
for(new i=0;i<sizeof(Radio);i++)
{
format(string,sizeof(string),"{FFFFFF}%s\n",Radio[i][urlname]);
strcat(mainstring,string);
}
strcat(mainstring,"{FFFFFF}Radio Aus");
ShowPlayerDialog(playerid,DIALOG_RADIO,DIALOG_STYLE_LIST,"{FFFFFF}Radio",mainstring,"Auswählen","Abbrechen");
}
return 1;
}
Schick bitte noch den dazugehörigen Teil bei OnDialogResponse.
if(dialogid == DIALOG_RADIO)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(response == 0)return 1;
else
{
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,ROT,"Du sitzt in keinem Fahrzeug.");
if(listitem > sizeof(Radio)-1)
{
ForEachPlayer(i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
if(IsPlayerInVehicle(i,GetPlayerVehicleID(playerid)))
{
StopAudioStreamForPlayer(i);
}
}
}
}
}
return format(VehicleRadioStream[vehicleid],128,"NONE");
}
ForEachPlayer(i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
if(IsPlayerInVehicle(i,GetPlayerVehicleID(playerid)))
{
StopAudioStreamForPlayer(playerid);
PlayAudioStreamForPlayer(i,Radio[listitem][url]);
format(VehicleRadioStream[vehicleid],128,Radio[listitem][url]);
}
}
}
}
}
}
return 1;
}
welches Mysql Plugin brauche ich hier ?