16.06.2011, 18:06
I've been trying to make a car-chat command, where everything said is only visible to people inside the car if you do /cw [TEXT]. And I just haven't been able to do it. Could I get some help?
// Put this somewhere in your FS/GM, aslong its not inside { }
SendCarMessage(color, text[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i) && IsPlayerConnected(i))
{
SendClientMessage(i, color, text);
}
}
return 0;
}
//In your command add this:
SendCarMessage(color, text[])
// Put this somewhere in your FS/GM, aslong its not inside { }
SendCarMessage(carid, color, text[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i, carid) && IsPlayerConnected(i))
{
SendClientMessage(i, color, text);
}
}
return 0;
}
//In your command add this:
SendCarMessage(carid, color, text[])
if(strcmp(cmd,"/cw",true)==0)
{
if(IsSpawned[playerid] == 0) {
SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid)) {
SendClientMessage(playerid, COLOR_ERROR, "You not in any vehicle. You cannot use this command");
return 1;
}
if(strlen(cmdtext) <= 4) {
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /cw (msg)");
return 1;
}
new cwhisperid = GetPlayerVehicleID(playerid);
new output[150];
new pname[24];
GetPlayerName(playerid, pname, 24);
strmid(output,cmdtext,3,strlen(cmdtext));
format(string, sizeof(string), "(CAR WHISPER): %s(%d) %s",pname,playerid,output);
printf("%s", string);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i) == cwhisperid)
{
format(string, sizeof(string), "(CAR WHISPER): %s(%d) %s",pname,playerid,output);
SendClientMessage(i,COLOR_YELLOW,string);
}
}
}
return 1;
}
look in this (Click me) script and you will find it
|