SA-MP Forums Archive
radio will stop when you get out from the 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: radio will stop when you get out from the car (/showthread.php?tid=515647)



radio will stop when you get out from the car - hanm13 - 27.05.2014

This is the radio commands
Код:
    if(!strcmp(cmdtext,"/vhradio",true))
	{
	    new list[520];
		if(!IsPlayerInAnyVehicle(playerid))
		{
			SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in a vehicle !");
			return 1;
		}
		for(new i,s=sizeof(radiolist); i <= s; i++)
	    {
			if(i == s) format(list,520,"%s\n \n{FF0000}You stopped the radio",list);
			else format(list,520,"%s\n{FAFAFA}%02d) {FF9900}%s",list,i+1,radiolist[i][1]);
	    }
		ShowPlayerDialog(playerid,DEIALOG_ID,DIALOG_STYLE_LIST,"{00C8C8}Choose station",list,"choose","exit");
  		format(string, sizeof(string), "* %s Turn on the radio", sendername);
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        return 1;
    }

    if(!strcmp(cmdtext,"/vhallradiooff",true) && IsPlayerAdmin(playerid))
    {
        for(new i,m=GetMaxPlayers(); i < m; i++) if(IsPlayerConnected(i) && Radio[i]) StopAudioStreamForPlayer(i),Radio[i] = false;
        return 1;
    }



    if(!strcmp(cmdtext,"/vhradioff",true))
	{
		if(!IsPlayerInAnyVehicle(playerid))
		{
			SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in a vehicle !");
			return 1;
		}
		StopAudioStreamForPlayer(playerid);
		Radio[playerid] = false;
		SendClientMessage(playerid, COLOR_WHITE, "You stopped the radio stream !");
  		format(string, sizeof(string), "* %s Turn off the radio", sendername);
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        return 1;
	}
This is the public :
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if (GetPlayerState(playerid) == 1)
	{
		return 1;
	}
	if(dying[playerid] == 1){TogglePlayerControllable(playerid, 0); ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);}
	AffectVehicleDamageToPlayer(playerid,vehicleid,0);
	if(IsAHarvest(vehicleid))
	{
	    if(FarmerVar[playerid] == 1)
	    {
			SetTimer("FarmerExit", 7000, 0);
			GameTextForPlayer(playerid, "~n~~w~You have ~r~7~w~ seconds~n~to get back on a harvest", 5000, 3);
	    }
	}
	/*if(Radio[playerid]==true)
    {
        new string[256];
		StopAudioStreamForPlayer(playerid);
		Radio[playerid] = false;
		format(string, sizeof(string), "* %s stopped the radio station and get out from the car", GetPlayerNameEx(playerid));
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        //return 1;
	}*/
	if(IsADrugHarvest(vehicleid))
	{
	    if(DrugFarmerVar[playerid] == 1)
	    {
			SetTimer("DrugFarmerExit", 7000, 0);
			GameTextForPlayer(playerid, "~n~~w~You have ~b~7~w~ seconds~n~to get back on a harvest", 5000, 3);
	    }
	}
	if(IsADmv(vehicleid))
	{
	}
	if(IsASmuggleCar(vehicleid))
	{
	    if(SmugglerWork[playerid] == 1)
	    {
	        SetTimer("SmugglerExit", 7000, 0);
	        GameTextForPlayer(playerid, "~n~~w~You have ~r~7~w~ seconds~n~to get back in car", 5000, 3);
		}
	}
	if(gGas[playerid] == 1)
	{
	    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~Left car", 500, 3);
	}
	if (BusrouteEast[playerid][0] != 0 || BusrouteWest[playerid][0] != 0)
	{
		BusrouteEnd(playerid, vehicleid);
	}
	if (IsABus(vehicleid))
	{
		for (new i=0; i<=PLAYERS; i++)
		{
			if (IsPlayerConnected(i))
			{
				if (BusrouteEast[i][0] != 0 && BusrouteEast[i][1] == vehicleid)
				{
					//BusrouteEast[i][2] --;
					GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~g~Passenger Left The Bus", 5000, 3);
				}
				else if (BusrouteWest[i][0] != 0 && BusrouteWest[i][1] == vehicleid)
				{
					//BusrouteWest[i][2] --;
					GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~g~Passenger Left The Bus", 5000, 3);
				}
			}
		}
	}
	if(SeatBelt[playerid]==true)
    {
        new string[256];
    	SeatBelt[playerid]=false;
    	format(string, sizeof(string), "* %s unbuckles his/her seat belt", GetPlayerNameEx(playerid));
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
	}
	return 1;
}
The if
Код:
	if(Radio[playerid]==true)
    {
        new string[256];
		StopAudioStreamForPlayer(playerid);
		Radio[playerid] = false;
		format(string, sizeof(string), "* %s stopped the radio station and get out from the car", GetPlayerNameEx(playerid));
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        //return 1;
	}
Doesnt working...
Its not close the radio and dont write the text..

Someone can help me to fix that
When you get our from the car the radio will stop and its will write to you.
But if the radio = 0 its not write to you nothing


Re: radio will stop when you get out from the car - ball - 27.05.2014

Код:
/*if(Radio[playerid]==true)
    {
        new string[256];
		StopAudioStreamForPlayer(playerid);
		Radio[playerid] = false;
		format(string, sizeof(string), "* %s stopped the radio station and get out from the car", GetPlayerNameEx(playerid));
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        //return 1;
	}*/
Why this code is commented? Remove /* and */


Re: radio will stop when you get out from the car - hanm13 - 27.05.2014

Quote:
Originally Posted by ball
Посмотреть сообщение
Код:
/*if(Radio[playerid]==true)
    {
        new string[256];
		StopAudioStreamForPlayer(playerid);
		Radio[playerid] = false;
		format(string, sizeof(string), "* %s stopped the radio station and get out from the car", GetPlayerNameEx(playerid));
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        //return 1;
	}*/
Why this code is commented? Remove /* and */
Becuase it dont work so I locked the code


Re: radio will stop when you get out from the car - YoungKris - 27.05.2014

Under OnPlayerExitVehicle
pawn Код:
for(new i,m=GetMaxPlayers(); i < m; i++) if(IsPlayerConnected(i) && Radio[i]) StopAudioStreamForPlayer(i),Radio[i] = false;
format(string, sizeof(string), "* %s turns off the radio.", sendername);
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);



Re: radio will stop when you get out from the car - hanm13 - 27.05.2014

Quote:
Originally Posted by YoungKris
Посмотреть сообщение
Under OnPlayerExitVehicle
pawn Код:
for(new i,m=GetMaxPlayers(); i < m; i++) if(IsPlayerConnected(i) && Radio[i]) StopAudioStreamForPlayer(i),Radio[i] = false;
format(string, sizeof(string), "* %s turns off the radio.", sendername);
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
error 017: undefined symbol "string"
error 017: undefined symbol "string"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

This is the line
format(string, sizeof(string), "* %s turns off the radio.", sendername);
and its need to be if the radio on


Re: radio will stop when you get out from the car - YoungKris - 27.05.2014

this should work

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    for(new i,m=GetMaxPlayers(); i < m; i++)
    {
         if(IsPlayerConnected(i) && Radio[i])
         {
              new string[128],
                   pName[MAX_PLAYER_NAME];
              GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
              StopAudioStreamForPlayer(i);
              Radio[i] = false;
              format(string, sizeof(string), "* %s turns off the radio.", pName);
              ProxDetector(15.0, playerid, string,
    COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
         }
    }
    return 1;
}



Re: radio will stop when you get out from the car - hanm13 - 27.05.2014

Quote:
Originally Posted by YoungKris
Посмотреть сообщение
this should work

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    for(new i,m=GetMaxPlayers(); i < m; i++)
    {
         if(IsPlayerConnected(i) && Radio[i])
         {
              new string[128],
                   pName[MAX_PLAYER_NAME];
              GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
              StopAudioStreamForPlayer(i);
              Radio[i] = false;
              format(string, sizeof(string), "* %s turns off the radio.", pName);
              ProxDetector(15.0, playerid, string,
    COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
         }
    }
    return 1;
}
Why ..
pawn Код:
for(new i,m=GetMaxPlayers(); i < m; i++)
    {
         if(IsPlayerConnected(i
...


Re: radio will stop when you get out from the car - YoungKris - 27.05.2014

Quote:
Originally Posted by hanm13
Посмотреть сообщение
Why ..
pawn Код:
for(new i,m=GetMaxPlayers(); i < m; i++)
    {
         if(IsPlayerConnected(i
...
You should ask yourself that
I actually copied it from your code (look above)


Re: radio will stop when you get out from the car - hanm13 - 27.05.2014

Quote:
Originally Posted by YoungKris
Посмотреть сообщение
You should ask yourself that
I actually copied it from your code (look above)
This my code
and its not working
pawn Код:
if(Radio[playerid]==true)
    {
        new string[256];
        StopAudioStreamForPlayer(playerid);
        Radio[playerid] = false;
        format(string, sizeof(string), "* %s stopped the radio station and get out from the car", GetPlayerNameEx(playerid));
        ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        //return 1;
    }
Your code dont working
I tried ...


Re: radio will stop when you get out from the car - Jefff - 27.05.2014

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate != PLAYER_STATE_DRIVER && Radio[playerid])
    {
        new string[128];
        Radio[playerid] = false;
        format(string, sizeof(string), "* %s stopped the radio station and get out from the car", GetPlayerNameEx(playerid));
        ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        StopAudioStreamForPlayer(playerid);
    }
    return 1;
}