SA-MP Forums Archive
Help whith /whisper - 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: Help whith /whisper (/showthread.php?tid=307201)



Help whith /whisper - CaTaLinU - 29.12.2011

Can some one give me the code for /w , /whisper

I have a whisper that i can whisper something to someone only if i am near him

i want it to work even if i am in LS and he its in SF

Sorry for my english, i hope you understand me..


Re: Help whith /whisper - Sasoft - 29.12.2011

Can you show me your current /w command? Then i'll be able to change it for you.


Re: Help whith /whisper - CaTaLinU - 29.12.2011

i have 2 commands

/whisper - /w -> i dont know if it works, i have added it now
and
/whisper2 - /w2 -> default gm command with distance

PHP код:
// Whisper
if(strcmp(cmd, "/whisper", true) == 0 || strcmp(cmd, "/w", true) == 0)
    {
      if(
IsPlayerConnected(playerid))
      {
        if(
gPlayerLogged[playerid] == 0)
        {
          
SendClientMessage(playerid, COLOR_GREY, "  You havent logged in yet !");
          return 
1;
        }
            
tmp = strtok(cmdtext, idx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/w)hisper [playerid/PartOfName] [whisper text]");
                return 
1;
            }
            
giveplayerid = ReturnUser(tmp);
            if (
IsPlayerConnected(giveplayerid))
            {
              if(
giveplayerid != INVALID_PLAYER_ID)
              {
                if(
HidePM[giveplayerid] > 0)
                {
                  
SendClientMessage(playerid, COLOR_GREY, "  That player is blocking Whispers !");
                  return 
1;
                }
                    
GetPlayerName(playerid, sendername, sizeof(sendername));
                    
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    if(
giveplayerid == playerid)
                    {
                        
format(string, sizeof(string), "* %s sopteste ceva.", sendername);
                        
ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    new 
length = strlen(cmdtext);
                    while ((
idx < length) && (cmdtext[idx] <= ' '))
                    {
                        
idx++;
                    }
                    new 
offset = idx;
                    new 
result[64];
                    while ((
idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                    {
                        
result[idx - offset] = cmdtext[idx];
                        
idx++;
                    }
                    
result[idx - offset] = EOS;
                    if(!
strlen(result))
                    {
                        
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/w)isper [playerid/PartOfName] [whisper text]");
                        return 
1;
                    }
                    
format(string, sizeof(string), "%s(ID: %d) sopteste: %s", sendername, playerid, (result));
                    
SendClientMessage(giveplayerid, COLOR_BLUE, string);
                    
format(string, sizeof(string), "Mesaj trimis catre %s(ID: %d).", giveplayer, giveplayerid);
                    
SendClientMessage(playerid, COLOR_BLUE, string);
                    
SBizzInfo[2][sbTill] += txtcost / 2;
                    
ExtortionSBiz(2, txtcost / 2);
                    return 
1;
                }
            }
            else
            {
                    
format(string, sizeof(string), "  %d is not an active player.", giveplayerid);
                    
SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 
1;
    }
//----------------------------------[Whisper]-----------------------------------------------
    
if(strcmp(cmd, "/whisper2", true) == 0 || strcmp(cmd, "/w2", true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
gPlayerLogged[playerid] == 0)
            {
                
SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet!");
                return 
1;
            }
            
tmp = strtok(cmdtext, idx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/w)hisper [playerid/PartOfName] [whisper text]");
                return 
1;
            }
            if (
PlayerInfo[playerid][pLevel] == 1)
            {
                
SendClientMessage(playerid, COLOR_GRAD2, "Nu ai level 2 !");
                return 
1;
            }
            
giveplayerid = ReturnUser(tmp);
            if (
IsPlayerConnected(giveplayerid))
            {
                if(
giveplayerid != INVALID_PLAYER_ID)
                {
                    new 
Float:x, Float:y, Float:z;
                       
GetPlayerPos(giveplayerid,x,y,z);
                    if(
PlayerToPoint(5, playerid, x, y, z))
                    {
                        
GetPlayerName(playerid, sendername, sizeof(sendername));
                        
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        if(
giveplayerid == playerid)
                        {
                            
format(string, sizeof(string), "* %s mutters something to himself.", sendername);
                            
ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        }
                        else
                        {
                            
format(string, sizeof(string), "* %s whispers something to %s", sendername, giveplayer);
                            
ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        }
                        new 
length = strlen(cmdtext);
                        while ((
idx < length) && (cmdtext[idx] <= ' '))
                        {
                            
idx++;
                        }
                        new 
offset = idx;
                        new 
result[64];
                        while ((
idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                        {
                            
result[idx - offset] = cmdtext[idx];
                            
idx++;
                        }
                        
result[idx - offset] = EOS;
                        if(!
strlen(result))
                        {
                            
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/w)isper [playerid/PartOfName] [whisper text]");
                            return 
1;
                        }
                        
format(string, sizeof(string), "%s sopteste: %s", sendername, (result));
                        
SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                        
format(string, sizeof(string), "%s sopteste: %s", sendername, (result));
                        
SendClientMessage(playerid,  COLOR_YELLOW, string);
                        return 
1;
                    }
                    else
                    {
                        
SendClientMessage(playerid,  COLOR_GREY, "    Player is not near you !");
                        return 
1;
                    }
                }
            }
            else
            {
                    
format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                    
SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 
1;
    }