My /b is Global :S
#1

Hello guys, my /b command show the message global, how i can make it visible only for local chat? here is my current code:

Код:
if(!strcmp(cmdtext, "/b", true, 2))
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_GREY, "USAGE: /b [OOC CHAT]");
        new str[128];
        GetPlayerName(playerid,str, sizeof(str));
        format(str, sizeof(str), "%s ((%s))", str, cmdtext[2]);
        SendClientMessageToAll (COLOR_WHITE, str);
        return 1;
    }
thanks!
Reply
#2

Am.. Get distance between players? or ProxDetector. Use search function.
Reply
#3

Quote:
Originally Posted by Panormitis
Посмотреть сообщение
Hello guys, my /b command show the message global, how i can make it visible only for local chat? here is my current code:

Код:
if(!strcmp(cmdtext, "/b", true, 2))
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_GREY, "USAGE: /b [OOC CHAT]");
        new str[128];
        GetPlayerName(playerid,str, sizeof(str));
        format(str, sizeof(str), "%s ((%s))", str, cmdtext[2]);
        SendClientMessageToAll (COLOR_WHITE, str);
        return 1;
    }
thanks!
Your sending the string to all clients connected within the server. Create a simple function which localizes a set radius which formatted string can be called.
Reply
#4

PHP код:
if(!strcmp(cmdtext"/b"true2))
    {
        if(!
cmdtext[2])return SendClientMessage(playeridCOLOR_GREY"USAGE: /b [OOC CHAT]");
        new 
str[128];
        
GetPlayerName(playerid,strsizeof(str));
        
format(strsizeof(str), "%s ((%s))"strcmdtext[2]);
        
ProxDetector(20.0playeridstr,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
        return 
1;
    }
forward ProxDetectorS(Float:radiplayeridtargetid);
public 
ProxDetectorS(Float:radiplayeridtargetid)
{
    if(
IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
        new 
Float:posxFloat:posyFloat:posz;
        new 
Float:oldposxFloat:oldposyFloat:oldposz;
        new 
Float:tempposxFloat:tempposyFloat:tempposz;
        
GetPlayerPos(playeridoldposxoldposyoldposz);
        
GetPlayerPos(targetidposxposyposz);
        
tempposx = (oldposx -posx);
        
tempposy = (oldposy -posy);
        
tempposz = (oldposz -posz);
        if(((
tempposx radi) && (tempposx > -radi)) && ((tempposy radi) && (tempposy > -radi)) && ((tempposz radi) && (tempposz > -radi)))
        {
            return 
1;
        }
    }
    return 
0;

Reply
#5

Or:

PHP код:
stock SendLocalMessage(playeridcolorstring[], Float:radius)
{
    new 
FloatXYZ;
    
GetPlayerPos(playeridX,Y,Z);
    for(new 
0MAX_PLAYERSi++) {
     if(
IsPlayerInRangeOfPoint(iradiusXYZ))
     
SendClientMessage(i,color,string);
     return 
1;

PHP код:
if(!strcmp(cmdtext"/b"true2))
{
    if(!
cmdtext[2])return SendClientMessage(playeridCOLOR_GREY"USAGE: /b [OOC CHAT]");
     new 
str[128];
      
GetPlayerName(playerid,strsizeof(str));
       
format(strsizeof(str), "%s ((%s))"strcmdtext[2]);
    
SendLocalMessage(playeridCOLOR_WHITEstr30.0);
    return 
1;

Reply
#6

PHP код:
stock SendLocalMessage(playeridcolorstring[], Float:radius)
{
    new 
FloatX,FloatY,Float:Z;   <<<< You need to add all the Floatto Y and Z not only to X
    GetPlayerPos
(playeridX,Y,Z);
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerInRangeOfPoint(iradiusXYZ))
        
SendClientMessage(i,color,string);
     }    <<<<<<< 
You forgot this one
    
return 1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)