Command issue
#1

I was trying to make a /me command, but it doesn't work, no warnings, when I type /me and the message nothing happens, what I want is that players that in a close Radius of a guy who is about to say something on /me would be able to see it, can you check the script and correct, I don't want that to be Global to the whole server.
PHP код:
new cmd[256],idx;
    new 
tmp[256];
    
cmd strtok(cmdtext,idx);
 if(
strcmp(cmd,"/Me",true)==0)
{
new 
string[256];
new 
name[24];
new 
Players LimitGlobalChatRadius(10);
tmp strrest(cmdtext,idx);
if(!
strlen(tmp)) return SendClientMessage(playerid,0xFF66FFAA," /Me [Text]");
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string)," [Me] %s : %s",name,tmp);
SendClientMessage(Players,0xFFFF00AA,string);
 return 
1;

And this placed in the bottom of the script :
PHP код:
public OnPlayerClickPlayer(playeridclickedplayeridsource)
{
    return 
1;
}
stock strrest(const string[],index)
{
    new 
length strlen(string),offset index,result[256];
    while((
index length) && ((index offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index offset] = string[index],index++;
    
result[index offset] = EOS;
    if(
result[0] == ' ' && string[0] != ' 'strdel(result,0,1);
    return 
result;

Reply
#2

You choosed wrong function

LimitGlobalChatRadius(10); is to limit how far each other player can see others chat,

Better use
pawn Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(/me cmd maker,x,y,z);

for(..
if(IsPlayerInRangeOfPoint(i,Your Radiuss,x,y,z))
{
SendClientMessage(..
}
Reply
#3

use this

pawn Код:
stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        foreach(Player, i)
        {
            GetPlayerPos(i, posx, posy, posz);
            tempposx = (oldposx -posx);
            tempposy = (oldposy -posy);
            tempposz = (oldposz -posz);
            if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
            {
                SendClientMessage(i, col1, string);
            }
            else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
            {
                SendClientMessage(i, col2, string);
            }
            else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
            {
                SendClientMessage(i, col3, string);
            }
            else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
            {
                SendClientMessage(i, col4, string);
            }
            else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
            {
                SendClientMessage(i, col5, string);
            }
        }
    }
    return 1;
}
Example of use for /me

pawn Код:
new
    string[128],
    name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name, MAX_PLAYER_NAME);
    format(string,sizeof(string),"* %s %s ",name,params);
    ProxDetector(20.0, playerid, string,COLOR1,COLOR2,COLOR3,COLOR4,COLOR5); // 20 = radius

i make example for ZCMD and foreach you will need to RE-Edit
Reply
#4

This looks better?
foreach, zcmd and sscanf
pawn Код:
stock ProxDetector(Float:radi, playerid, string[], color)
{
    new Float:posx, Float:posy, Float:posz;
    GetPlayerPos(playerid, posx, posy, posz);
    foreach (Player, i)
    {
        if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
        {
            if(IsPlayerInRangeOfPoint(i,radi,posx, posy, posz))
            {
                SendClientMessage(i, color, string);
            }
        }
    }
}
stock SendDoingMessage(playerid, doing[])
{
    new Float: emoteX, Float: emoteY, Float: emoteZ, playerName[MAX_PLAYER_NAME], msg[128];
    GetPlayerPos(playerid, emoteX, emoteY, emoteZ);
    GetPlayerName(playerid, playerName, sizeof(playerName));
   
    format(msg, sizeof(msg), "* %s %s", playerName, doing);
    ProxDetector(30.0, playerid, msg, COLOR_PURPLE);
    return 1;
}

CMD:me(playerid, params[])
{
    new result[128];
    if(sscanf(params, "s[128]", result)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /me [text]");
    return SendDoingMessage(playerid, result);
}
Reply
#5

These are the warnings :
PHP код:
es\RP.pwn(505) : error 017undefined symbol "strrest"
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(505) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(800) : warning 203symbol is never used"me" 
And this is the onplayercommand current script :
PHP код:
new cmd[256],idx;
    new 
tmp[256];
    
cmd strtok(cmdtext,idx);
 if(
strcmp(cmd,"/Me",true)==0)
{
new 
string[256];
new 
name[24];
new 
Players LimitGlobalChatRadius(10);
tmp strrest(cmdtext,idx);
if(!
strlen(tmp)) return SendClientMessage(playerid,0xFF6C6CFF,"Usage: /me [action]");
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string)," [Me] %s : %s",name,tmp);
SendClientMessage(Players,0xFFFF00AA,string);
 return 
1;

And this is the script in the bottom of this whole script :
PHP код:
stock ProxDetector(Float:radiplayeridstring[], color)
{
    new 
Float:posxFloat:posyFloat:posz;
    
GetPlayerPos(playeridposxposyposz);
    foreach (
Playeri)
    {
        if(
GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
        {
            if(
IsPlayerInRangeOfPoint(i,radi,posxposyposz))
            {
                
SendClientMessage(icolorstring);
            }
        }
    }
}
stock SendDoingMessage(playeriddoing[])
{
    new 
FloatemoteXFloatemoteYFloatemoteZplayerName[MAX_PLAYER_NAME], msg[128];
    
GetPlayerPos(playeridemoteXemoteYemoteZ);
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    
format(msgsizeof(msg), "* %s %s"playerNamedoing);
    
ProxDetector(30.0playeridmsgCOLOR_PURPLE);
    return 
1;
}
CMD:me(playeridparams[])
{
    new 
result[128];
    if(
sscanf(params"s[128]"result)) return SendClientMessage(playeridCOLOR_GRAD2"USAGE: /me [action]");
    return 
SendDoingMessage(playeridresult);

Reply
#6

Try just this
Код:
        if(!strcmp(cmdtext, "/me", true, 3))
        {
        if(!cmdtext[3])return SendClientMessage(playerid, YELLOW, "USAGE: /me [msg]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
        SendClientMessage(YELLOW, str);
        return 1;
}
Under OnPlayerCommandText
Reply
#7

PHP код:
\RP.pwn(505) : error 035argument type mismatch (argument 2)
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(797) : warning 203symbol is never used"me" 
PHP код:
 if(!strcmp(cmdtext"/me"true3))
        {
        if(!
cmdtext[3])return SendClientMessage(playerid0xFFFFFFAA"USAGE: /me [msg]");
        new 
str[128];
        
GetPlayerName(playeridstrsizeof(str));
        
format(strsizeof(str), "* %s %s"strcmdtext[4]);
       
line 505  SendClientMessage(0xFFFFFFAAstr);
        return 
1;

And the "me" Doesn't appear, there is nothing in line 797.
Plus do I need to use this :
I did use it if yes where should I put it ?
PHP код:
new
    
string[128],
    
name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,nameMAX_PLAYER_NAME);
    
format(string,sizeof(string),"* %s %s ",name,params);
    
ProxDetector(20.0playeridstring,COLOR1,COLOR2,COLOR3,COLOR4,COLOR5); // 20 = radius 
Reply
#8

Here, this should do it.

Notice, this command uses ZCMD and SSCANF2. Change the colors.

pawn Код:
command(me, playerid, params[])
{
    new Message[128], string[128];
    if( sscanf( params, "s[128]", Message) )
    {
        SendClientMessage( playerid, COLOR_WHITE, "SYNTAX: /me [action]" );
    }
    else
    {
        format( string, sizeof( string ), "* %s %s", GetPlayerNameEx( playerid ), Message);
        NearByMessage( playerid, COLOR_PURPLE, string);
    }
    return 1;
}
This is the custom function to make it work.

pawn Код:
forward NearByMessage(playerid, color, String[]);
public NearByMessage( playerid, color, String[])
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ, string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected( i ))
        {
            GetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ);
            if(IsPlayerInRangeOfPoint(i, 12, PlayerX, PlayerY, PlayerZ) )
            {
                if(GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( i ) && GetPlayerInterior( playerid ) == GetPlayerInterior( i ) )
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
    return 1;
}

forward NearByMessageEx(playerid, color, String[], Float: range);
public NearByMessageEx( playerid, color, String[], Float: range)
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ, string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected( i ) )
        {
            GetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ);
            if(IsPlayerInRangeOfPoint(i, range, PlayerX, PlayerY, PlayerZ) )
            {
                if(GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( i ) )
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
}

stock GetPlayerNameEx(playerid)
{
    new str[24], String[128];
    GetPlayerName(playerid,String,24);
    strmid(str,String,0,strlen(String),24);
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if (str[i] == '_') str[i] = ' ';
    }
    return str;
}
Reply
#9

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Here, this should do it.

Notice, this command uses ZCMD and SSCANF2. Change the colors.

pawn Код:
command(me, playerid, params[])
{
    new Message[128], string[128];
    if( sscanf( params, "s[128]", Message) )
    {
        SendClientMessage( playerid, COLOR_WHITE, "SYNTAX: /me [action]" );
    }
    else
    {
        format( string, sizeof( string ), "* %s %s", GetPlayerNameEx( playerid ), Message);
        NearByMessage( playerid, COLOR_PURPLE, string);
    }
    return 1;
}
This is the custom function to make it work.

pawn Код:
forward NearByMessage(playerid, color, String[]);
public NearByMessage( playerid, color, String[])
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ, string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected( i ))
        {
            GetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ);
            if(IsPlayerInRangeOfPoint(i, 12, PlayerX, PlayerY, PlayerZ) )
            {
                if(GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( i ) && GetPlayerInterior( playerid ) == GetPlayerInterior( i ) )
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
    return 1;
}

forward NearByMessageEx(playerid, color, String[], Float: range);
public NearByMessageEx( playerid, color, String[], Float: range)
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ, string[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected( i ) )
        {
            GetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ);
            if(IsPlayerInRangeOfPoint(i, range, PlayerX, PlayerY, PlayerZ) )
            {
                if(GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( i ) )
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    }
}

stock GetPlayerNameEx(playerid)
{
    new str[24], String[128];
    GetPlayerName(playerid,String,24);
    strmid(str,String,0,strlen(String),24);
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if (str[i] == '_') str[i] = ' ';
    }
    return str;
}
This is my code
Reply
#10

Quote:
Originally Posted by Scriptissue
Посмотреть сообщение
This is my code
The error is not in this code.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)