Detect numbers in chat
#1

Well I've been trying to make something like detecting numbers after text in chat

Код:
(space)/report x(id) return -  "Don't ask other players to report someone!";
So basically I stuck with a simple thing like this. Help appreciated.
Reply
#2

You can use sscanf
https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#3

Eh nice but does it not work?
Reply
#4

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
Like I didn't knew I could use it.


pawn Код:
public OnPlayerText(playerid, text[])
{
if(strfind(text, "/report", true) != -1 && sscanf(text, "u", text)) return SendErrorMessage(playerid, "Don't ask other players to report someone!"), 0;
return 1;
}
Kinda a fail..
Reply
#5

after the report command you want to detect the playerid and want to report THAT playerid right?
I didn't understand your message of saying "Don't ask other players to report someone"
Reply
#6

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
after the report command you want to detect the playerid and want to report THAT playerid right?
I didn't understand your message of saying "Don't ask other players to report someone"
I don't want to report that player id. I used OnPlayerText cos some players are typing in chat like 'all do /report 1 cheat". I want to detect that they typing '/report' or either 'report' and the id next to report so can find it in string chat and return the "Don't ask other players to report someone".
Reply
#7

y_commands does this B-E-A-U-T-I-F-U-L-L-Y. setting player command restrictions, compatibility with ZCMD style commands etc. hi, click me!
Reply
#8

pawn Код:
new tmp[256];
tmp = strtok(text,1);
new id = strval(tmp);
Reply
#9

Quote:
Originally Posted by arbit
Посмотреть сообщение
y_commands does this B-E-A-U-T-I-F-U-L-L-Y. setting player command restrictions, compatibility with ZCMD style commands etc. hi, click me!
It has nothing to do with commands. All is about OnPlayerText check.
Reply
#10

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pos = strpos(text, "/report", true);
    if(pos != -1 && !(text[pos+9] > '9' || text[pos+9] < '0')) return SendClientMessage(playerid, -1, "Don't ask other players to report someone!"), 0;
    return 1;
}
Something like that should work. I think +9 is the offset (if it's not then just change it up or down 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)