/carwhisper bug - sends a message to every vehicle
#1

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)