SA-MP Forums Archive
Need help:Music payer in car! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help:Music payer in car! (/showthread.php?tid=407942)



Need help:Music payer in car! - mateo6151 - 16.01.2013

Hi everyone!
Today i am finally allowed to access forum!
Okay, so i am working in pawno for few days, im beginner, i was just changing something renaming CMD-s, making some simple cmd-s and etc...
Im interested how can i make make that when player is only in car to turn some music thats added in pawno:
Код:
CMD:music1(playerid, params[])
    {
    PlayAudioStreamForPlayer(playerid, "http://k006.kiwi6.com/hotlink/lk36f085y3/12.hot_right_now_feat._dj_fresh.mp3");
    SendClientMessage(playerid, COLOR_WHITE, "Now playing: Rita Ora-Hot right now Feat. DJ Fresh");
    return 1;
}
So how can i make script to play music when player is only in car and error when player is not in car
i think its not that complicated but i don't get much that 'if','else'...
Thanks!


Re: Need help:Music payer in car! - RajatPawar - 16.01.2013

pawn Код:
CMD:radioincar(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a car.");
    else if(IsPlayerInAnyVehicle(playerid)) return PlayAudioStreamForPlayer(playerid, "Songhere");
    return 1;
}
Something like this?


Re: Need help:Music payer in car! - mateo6151 - 16.01.2013

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
pawn Код:
CMD:radioincar(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a car.");
    else if(IsPlayerInAnyVehicle(playerid)) return PlayAudioStreamForPlayer(playerid, "Songhere");
    return 1;
}
Something like this?
Thanks!
U helped me!


Re: Need help:Music payer in car! - mateo6151 - 16.01.2013

Oh i forgot..
And when player leave car?


Re: Need help:Music payer in car! - coakiddo - 16.01.2013

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
        // If the player exits a vehicle
	if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) 
	{
	    StopAudioStreamForPlayer(playerid); // Stop the audio stream
	}
	return 1;
}
From Wiki


Re: Need help:Music payer in car! - mateo6151 - 16.01.2013

Quote:
Originally Posted by coakiddo
Посмотреть сообщение
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
        // If the player exits a vehicle
	if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) 
	{
	    StopAudioStreamForPlayer(playerid); // Stop the audio stream
	}
	return 1;
}
From Wiki
Thanks!