/me & /g
#1

Ok so I got a main problem, I'm using these simple commands, /g is my giobal chat and /me is the RP-action command. The problem is if you I type /me and just space it still works other than returning the message like it does when you just type /me, it also works if you use /meeeeeeeeeeeeee, and same with /g, except it doesn't work with /gggggggggggggg but it does work if you type /g and space, I want it to be avoided, - I'm a new scripter so I require your help, plus I tried copying these commands from advanced gamemodes but I fail with errors and warnings, so any of your help will be appreciated, these are the cmds:



/g

if(!strcmp(cmdtext,"/g ",true,2))
{
new find = strfind(cmdtext," ",true);
if(find == -1 || find >= 30) return SendClientMessage(playerid, COLOR_RED, "Right 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);
}

/me

if(!strcmp(cmdtext, "/me", true, 3))
{
if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
ProxDetector(170.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
return 0;
}
Reply
#2

I didn't really understand. So your problem is that in the /me command, you can do /meeeeeeeeee instead of /me, and in /g you can't?
Reply
#3

Use sscanf
pawn Код:
new text[256];
if(sscanf(params, "s[256]", text)) SendClientMessage(Playerid, 0xFF0000, "lol");
else
{
//Your function here.... use text as params ;)
}
Reply
#4

pawn Код:
CMD:me(playerid, params[])
{
    new name[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, name, sizeof(name));
    if(isnull(params))
        return SendClientMessage(playerid,COLOR_LIGHTBLUE -1,"[SYNTAX]: /me [Action]");
    format(str,sizeof(str),"%s %s",name, params);
    ProxDetector(30.0, playerid, str, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
    return 1;
}
pawn Код:
CMD:g(playerid, params[])
{
    new sendername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    strreplace(sendername, '_', ' ');
    format(string, sizeof(string), "((Global)) %s: %s", sendername, params);
    SendClientMessageToAll(COLOR_SAEGREEN, string);
    return 1;
}
Reply
#5

@mean - my problem is that I want to avoid players being able to use /meeeeeeeeeeeee or just /me with space, useless texts that cause spam without a reason.
@thimo - I didn't really get it but I'll try something.
@ good day - I'm getting errors like: "symbol is never used "CMD", "undefined symbol "params", undefined symbol "me", "undefined symbol "isnull".
Reply
#6

pawn Код:
if(!strcmp(cmdtext,"/g",true,2))
{
    if(!cmdtext[3]) return SendClientMessage(playerid, COLOR_RED, "Right Usage: \"/g\" [text]");
    new string[150]; //you don't need 256
    GetPlayerName(playerid,string,sizeof(string));
    format(string,sizeof(string),"((Global: %s: %s ))", string, cmdtext[3]);
    return SendClientMessageToAll(COLOR_SEAGREEN, string), 1;
}


if(!strcmp(cmdtext, "/me", true, 3))
{
    if(!cmdtext[4]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    new str[150];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
    ProxDetector(170.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
Reply
#7

Your problem is that you are using this:

pawn Код:
strfind(cmdtext," ",true)
strfind will search the string until it finds what you're looking for, in this case, a space. Therefore, your player's can do an unlimited amount of this /meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee until they add a space- which will then allow the second part of the command to be processed.
Reply
#8

All the scripts you gave me have the exact same problem and I can't understand Realcop's version, sorry, I still don't get it, I think I'll get it if you can give me proper fixed /me & /g commands please.
Reply
#9

I tried this:

CMD:me(playerid, params[])
{
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof(name));
if(isnull(params))
return SendClientMessage(playerid,COLOR_LIGHTBLUE -1,"[SYNTAX]: /me [Action]");
format(str,sizeof(str),"%s %s",name, params);
ProxDetector(30.0, playerid, str, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE, COLOR_LIGHTBLUE);
return 1;
}

I get errors of undefined symbol "me" - undefined symbol "params" - undefined symbol "insull"
Reply
#10

if you are new in scripting, learn the basics and dont start a RP script as first O.o
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)