Need help:Music payer in car!
#1

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!
Reply
#2

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?
Reply
#3

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!
Reply
#4

Oh i forgot..
And when player leave car?
Reply
#5

Код:
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
Reply
#6

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)