Problem with Audio Script in vehicle -
cywil - 17.10.2010
Hello everyone. I had problem with my command audio (playing music in car), if I enter to car and left the audio item in car and /audio, I've got error >> "Brak przedmiotu"|"No audio item in car", but this car have got audio item. Sorry for my horrible English, nice day and Thank You much :*
Код:
CMD:audio(playerid, params[])
{
new url[128];
// Odtwarzanie w pojazdach
if(IsPlayerInAnyVehicle(playerid))
{
if(!IsItemInVehicle(playerid, ITEM_AUDIO))
{
ShowPlayerDialog(playerid, DIALOG_INFO, DIALOG_STYLE_MSGBOX, "Brak przedmiotu", "W tym pojeździe nie ma zestawu audio!", "Okej", "Anuluj");
return 1;
}
new itemuid = GetVehicleItemTypeUID(playerid, ITEM_AUDIO);
new itemid = GetItemID(itemuid);
if(sscanf(params, "s[128]", url))
{
if(ItemData[itemid][iUsed] == 1)
{
ItemData[itemid][iUsed] = 0;
new vehicleuid = ItemData[itemid][iValue1];
new vehicleid = GetVehicleID(vehicleuid);
DbVehicles[vehicleuid][vAudio] = 0;
format(DbVehicles[vehicleuid][vAudioURL], 128, "");
foreach(i, MAX_PLAYERS)
{
if(GetPlayerVehicleID(i) == vehicleid) Audio_Stop(i, PlayerData[i][pAudioHandle]);
}
ItemData[itemid][iUsed] = 0;
ItemData[itemid][iValue1] = 0;
ItemData[itemid][iValue2] = 0;
ShowPlayerDialog(playerid, DIALOG_INFO, DIALOG_STYLE_MSGBOX, "System audio", "Odtwarzanie wyłączone.", "Okej", "Anuluj");
return 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_AUDIO_URL, DIALOG_STYLE_INPUT, "Podaj adres URL", "Podaj adres URL muzyki, ktуra ma zostać odtworzona w systemie audio.", "Wybierz", "Anuluj");
return 1;
}
}
if(ItemData[itemid][iUsed] == 1)
{
new vehicleuid = ItemData[itemid][iValue1];
new vehicleid = GetVehicleID(vehicleuid);
DbVehicles[vehicleuid][vAudio] = 0;
format(DbVehicles[vehicleuid][vAudioURL], 128, "");
foreach(i, MAX_PLAYERS)
{
if(GetPlayerVehicleID(i) == vehicleid) Audio_Stop(i, PlayerData[i][pAudioHandle]);
}
ItemData[itemid][iUsed] = 0;
ItemData[itemid][iValue1] = 0;
ItemData[itemid][iValue2] = 0;
ShowPlayerDialog(playerid, DIALOG_INFO, DIALOG_STYLE_MSGBOX, "System audio", "Odtwarzanie wyłączone.", "Okej", "Anuluj");
return 1;
}
else
{
new vehicleid = GetPlayerVehicleID(playerid);
new vehicleuid = VehicleData[vehicleid][vehUID];
if(vehicleuid == INVALID_VEHICLE_ID || vehicleuid == 0)
{
ShowPlayerDialog(playerid, DIALOG_INFO, DIALOG_STYLE_MSGBOX, "System audio", "Nie znajdujesz sie w pojezdzie, lub nie jest to pojazd przypisany.", "Okej", "Anuluj");
return 1;
}
DbVehicles[vehicleuid][vAudio] = 1;
format(DbVehicles[vehicleuid][vAudioURL], 128, "%s", url);
foreach(i, MAX_PLAYERS)
{
if(GetPlayerVehicleID(i) == vehicleid)
{
PlayerData[i][pAudioHandle] = Audio_PlayStreamed(i, url);
}
}
ItemData[itemid][iUsed] = 1;
ItemData[itemid][iValue1] = vehicleuid;
ItemData[itemid][iValue2] = AUDIO_VEHICLE;
ShowPlayerDialog(playerid, DIALOG_INFO, DIALOG_STYLE_MSGBOX, "System audio", "Odtwarzanie włączone.", "Okej", "Anuluj");
return 1;
}
}
}
Код:
stock IsItemInVehicle(vehicleuid, type)
{
foreach(itemid, MAX_ITEMS)
{
if(ItemData[itemid][iPlace] == PLACE_VEHICLE && ItemData[itemid][iVehID] == vehicleuid && ItemData[itemid][iType] == type) return 1;
}
return 0;
}
If I delete if(!IsItemInVehicle(playerid, ITEM_AUDIO), /audio and nothing happens.
Re: Problem with Audio Script in vehicle -
cywil - 17.10.2010
Anybody can help, please?
Re: Problem with Audio Script in vehicle -
Cameltoe - 17.10.2010
Shouldn't : if(!IsItemInVehicle(playerid, ITEM_AUDIO) be if(!IsItemInVehicle(GetPlayerVehicleID(playerid), ITEM_AUDIO) ?? just an thought..
Re: Problem with Audio Script in vehicle -
cywil - 17.10.2010
This same. But Thanks for reply

Any ideas?
Re: Problem with Audio Script in vehicle -
Cameltoe - 17.10.2010
Ive never used foreach but the stock looks wrong to me.