Msg for ppl in same car only - 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: Msg for ppl in same car only (
/showthread.php?tid=489391)
Msg for ppl in same car only -
Lajko1 - 22.01.2014
How can I make if a player write for example /carwhisper so only players/passengers will get message?
Thanks for help in advance.
Re: Msg for ppl in same car only -
Threshold - 22.01.2014
ZCMD (WITH foreach include [RECOMMENDED]):
pawn Код:
CMD:carwhisper(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You must be in a vehicle to use this command.");
if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carwhisper [message]");
new vehicleid = GetPlayerVehicleID(playerid), fstr[150], Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
foreach(Player, i)
{
if(!IsPlayerInVehicle(i, vehicleid)) continue;
format(fstr, sizeof(fstr), "[CAR WHISPER] %s: %s", Name, params);
SendClientMessage(i, 0xFFFF00FF, fstr);
}
return 1;
}
ZCMD (WITHOUT foreach include):
pawn Код:
CMD:carwhisper(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You must be in a vehicle to use this command.");
if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carwhisper [message]");
new vehicleid = GetPlayerVehicleID(playerid), fstr[150], Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(!IsPlayerInVehicle(i, vehicleid)) continue;
format(fstr, sizeof(fstr), "[CAR WHISPER] %s: %s", Name, params);
SendClientMessage(i, 0xFFFF00FF, fstr);
}
return 1;
}
'
Download the foreach include here:
https://sampforum.blast.hk/showthread.php?tid=92679
Download zcmd here:
https://sampforum.blast.hk/showthread.php?tid=91354
Re: Msg for ppl in same car only -
Lajko1 - 22.01.2014
Ty