SA-MP Forums Archive
Detect numbers in chat - 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: Detect numbers in chat (/showthread.php?tid=407339)



Detect numbers in chat - Cypress - 13.01.2013

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.


Re: Detect numbers in chat - [HK]Ryder[AN] - 13.01.2013

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


Re: Detect numbers in chat - McDavidson - 13.01.2013

Eh nice but does it not work?


Re: Detect numbers in chat - Cypress - 13.01.2013

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..


Re: Detect numbers in chat - [HK]Ryder[AN] - 13.01.2013

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"


Re: Detect numbers in chat - Cypress - 13.01.2013

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".


Re: Detect numbers in chat - u3ber - 13.01.2013

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!


Re: Detect numbers in chat - mineralo - 13.01.2013

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



Re: Detect numbers in chat - Cypress - 14.01.2013

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.


Re: Detect numbers in chat - [HiC]TheKiller - 14.01.2013

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.