Symbol blocker
#1

Hello, how can I block symbols like ~ > < § $ ?

Like when I type "/announce This is an ~ example" it should block the announce because it contains a ~
The announce command:

pawn Код:
dcmd_announce(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid))
    {
        if(!strlen(params)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /announce [Text]") &&
        SendClientMessage(playerid, orange, "Function: Will Announce the specified Message in screen");
        SendCommandToAdmins(playerid,"Announce");
        return GameTextForAll(params,4000,3);
    }
    else return ErrorMessages(playerid, 7);
}
Reply
#2

strfind
Reply
#3

Schurman is correct, use the function strfind. Here's an example of how to use strfind in your case.

pawn Код:
if( strfind( params, "~>~", true ) )
    return SendClientMessage(playerid, LIGHTBLUE2, "Usage: Your announcement includes illegal characters.")
Reply
#4

Thanks, but now it just shows me "Usage: Your announcement includes illegal characters." when I type /announce (without text)
Reply
#5

Ah, thanks for pointing that out. There was a flaw in my code.

pawn Код:
if( strfind( params, "~>~", true ) != -1)
    return SendClientMessage(playerid, LIGHTBLUE2, "Usage: Your announcement includes illegal characters.")
Reply
#6

Ok, that works, thank you
Reply
#7

Код:
dcmd_announce(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid)) {
    	if(!strlen(params)) return SendClientMessage(playerid,red,"USAGE: /announce <text>");
    	CMDMessageToAdmins(playerid,"ANNOUNCE");
		return GameTextForAll(params,4000,3);
    } else return SendClientMessage(playerid,red,"ERROR: You need to be level 2 to use this command");
}
Ladmin4v2 Announce
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)