SA-MP Forums Archive
/carwhisper bug - sends a message to every vehicle - 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: /carwhisper bug - sends a message to every vehicle (/showthread.php?tid=631466)



/carwhisper bug - sends a message to every vehicle - sampEv0 - 29.03.2017

i got most of it working except it sends the message to everybody who is in a vehicle instead of just theirs
i just dont know how to get it to grab the vehicles ID and limit the messages to that vehicle only

Код:
forward SendCarMessage(color, string[]);

public SendCarMessage(color, string[])
{
	for(new i = 0; i < MAX_PLAYERS; i ++)
	{
  	if(IsPlayerConnected(i))
	  {
	    if(IsPlayerInVehicle(i, GetPlayerVehicleID(i)))
			{
		  	SendClientMessage(i, color, string);
			}
	  }
	}
}
Код:
CMD:carwhisper(playerid, params[] )
{
	new string[128];

	if(isnull(params)) return SendClientMessage(playerid,-1,"USAGE: /cw [message]");
	if(IsPlayerInAnyVehicle(playerid) == 0) return SendClientMessage(playerid, -1, "You are not in any vehicle.");
	{
	    if(IsPlayerInAnyVehicle(playerid) == 1) GetPlayerVehicleID(playerid);
		format(string, sizeof(string), "%s whispers: %s", GetName(playerid), params);
		SendCarMessage(COLOR_YELLOW, string);
		format(string, sizeof(string), "%s mutters something.", GetName(playerid));
		SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 5.0, 4000);
	}
	return 1;
}
help is appreciated my mens


Re: /carwhisper bug - sends a message to every vehicle - Toroi - 29.03.2017

Add a playerid parameter to your SendCarMessage function, pass the playerid value from the command and change GetPlayerVehicleID(i) for GetPlayerVehicleID(playerid) in the SendcarMessage function's loop.


Re: /carwhisper bug - sends a message to every vehicle - sampEv0 - 29.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Add a playerid parameter to your SendCarMessage function, pass the playerid value from the command and change GetPlayerVehicleID(i) for GetPlayerVehicleID(playerid) in the SendcarMessage function's loop.
that did it, thank you so much for your help
repped