2 /me problems
#1

Hello I am trying to make to make a /me command and used ProxDetector to make it.
My problem is that When i write /me with space it gives me a empty /me
Example:

/me(space) - * Me (space)

Another problem I encountered is that when i have a command that starts with me I get a problem.

Example:
/medic - The right usage is /me;

Can anyone help me?

This is my code:
Код:
  	if(!strcmp(cmdtext, "/me", true, 3))
    {
  		new find = strfind(cmdtext," ",true);
  		if(find == -1 || find >= 30) return SendClientMessage(playerid, COLOR_RED, "Right Usage: \"/me\" [text]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[find+1]);
        ProxDetector(170.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        return 0;
	}
Reply
#2

I don't understand you but i give you a code. Mby you want this.

pawn Код:
if(strcmp(cmd, "/me", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet !");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            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: /me [action]");
                return 1;
            }
            if(PlayerInfo[playerid][pMaskuse] == 1)
            {
                format(string, sizeof(string), "* Stranger %s", result);
            }
            else
            {
                format(string, sizeof(string), "* %s %s", sendername, result);
            }
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            printf("%s", string);
        }
        return 1;
    }
Reply
#3

Код:
if(!strcmp(cmdtext, "/me", true, 3))
    {
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext);
        ProxDetector(170.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        return 0;
    }
Try only with this.
Reply
#4

pawn Код:
if(!strcmp(cmdtext, "/me", true, 3) && cmdtext[3] <= ' ')
    {
        new find = 3;
        while(cmdtext[find] == ' ') find++;
        if(!cmdtext[find]) return SendClientMessage(playerid, COLOR_RED, "Right Usage: \"/me\" [text]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[find]);
        ProxDetector(170.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        return 1;
    }
Reply
#5

Hi, i'm having the same problem and I tried Anzhelov's Code and I got "Server.pwn(128) : error 017: undefined symbol "ProxDetector"". If someone could help me with ProxDetector I woule be grateful :)
Reply
#6

Hah..

pawn Код:
// Top line
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);

// Code
public 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);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(!BigEar[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)))
                    {
                        if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
                        {
                            SendClientMessage(i, col1, string);
                        }
                    }
                    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                    {
                        if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
                        {
                            SendClientMessage(i, col2, string);
                        }
                    }
                    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                    {
                        if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
                        {
                            SendClientMessage(i, col3, string);
                        }
                    }
                    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                    {
                        if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
                        {
                            SendClientMessage(i, col4, string);
                        }
                    }
                    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                    {
                        if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
                        {
                            SendClientMessage(i, col5, string);
                        }
                    }
        }
                else
                {
                    SendClientMessage(i, col1, string);
                }
            }
        }
    }//not connected
    return 1;
}
Reply
#7

Quote:
Originally Posted by meD maN
Посмотреть сообщение
Hi, i'm having the same problem and I tried Anzhelov's Code and I got "Server.pwn(12 : error 017: undefined symbol "ProxDetector"". If someone could help me with ProxDetector I woule be grateful
You just need to add the whole ProxDetector to your script. Search in the forums about a tutorial on how to install proxdetector.
Reply
#8

try using zcmd and sscanf first and
pawn Код:
CMD:me(playerid, params[])
{
       new Reasons[128],str[128],Name[MAX_PLAYER_NAME];
    if(sscanf(params,"s", Reasons)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [Text]");
    GetPlayerName(playerid,Name, sizeof(Name));
    format(str, sizeof(str), "* %s %s", Name, Reasons);
    SendClientMessageToAll(0xFF9900AA, str);
    return 1;
}
Reply
#9

if(!strcmp(cmdtext, "/me", true, 3))

When using STRCMP with short commands never add lenght match (that number 3) coz it will match /,m and e in any command like /medic, /metar, /mexico... Anything that starts with /me
Reply
#10

Thank you Guys so much!
I finally got a decent /me command that looks Good.
Reply
#11

Thanks to all posters It was really helpful! Thank you once again
Reply
#12

Uhh, can someone help me with this Code aswell?
Sorry if I'm being a bit of an Annoyance but i'm a Noob
Here is the Code:
Код:
//if(!strcmp(cmdtext,"/g ",true,3))
//	{
//	new find = strfind(cmdtext,"/g ",true, 2);
//	if(find == -1 || find >= 30) return SendClientMessage(playerid, COLOR_GREY, "Usage: /g [text]");
//	new string[256]; //bite me
//	GetPlayerName(playerid,string,sizeof(string));
//	format(string,sizeof(string),"((Global: %s: %s ))", string, cmdtext[find+1]);
//	return SendClientMessageToAll(COLOR_SEAGREEN, string);
//	}
If someone could get this working like the /me command that would help alot, and explain what each line does?
Reply
#13

@meD maN: i Can Sort the script for you but i cant explain it
Reply
#14

Код:
#define Red 0xFF0000FF
#define Grey 0xAFAFAFAA
#define Green 0x33AA33AA
#define Yellow 0xFFFF00AA
#define White 0xFFFFFFAA
#define Blue 0x0000BBAA
#define Lightblue 0x33CCFFAA
#define Orange 0xFF9900AA
#define Lime 0x10F441AA
#define Magenta 0xFF00FFFFT
#define Navy 0x000080AA
#define Aqua 0xF0F8FFAA
#define Crimson 0xDC143CAA
#define Black 0x000000AA
#define Brown 0XA52A2AAA
#define Gold 0xB8860BAA
#define Limegreen 0x32CD32AA
Put this under #include <a_samp> so it looks like

Код:
#include <a_samp>
#define Red 0xFF0000FF
#define Grey 0xAFAFAFAA
#define Green 0x33AA33AA
#define Yellow 0xFFFF00AA
#define White 0xFFFFFFAA
#define Blue 0x0000BBAA
#define Lightblue 0x33CCFFAA
#define Orange 0xFF9900AA
#define Lime 0x10F441AA
#define Magenta 0xFF00FFFFT
#define Navy 0x000080AA
#define Aqua 0xF0F8FFAA
#define Crimson 0xDC143CAA
#define Black 0x000000AA
#define Brown 0XA52A2AAA
#define Gold 0xB8860BAA
#define Limegreen 0x32CD32AA
then here is ur cmd code there is no SeaGreen By the way only Lime Green xD
Код:
		if(!strcmp(cmdtext, "/g", true, 3))
		{
    		if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /g [text]");
    		new str[128];
    		GetPlayerName(playerid, str, sizeof(str));
    		format(str, sizeof(str), "%s %s", str, cmdtext[4]);
    		SendClientMessageToAll(COLOR_LIMEGREEN, str);
    		return 1;
 		}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)