SA-MP Forums Archive
Symbol blocker - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Symbol blocker (/showthread.php?tid=260825)



Symbol blocker - Julian12345 - 10.06.2011

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);
}



Re: Symbol blocker - SchurmanCQC - 10.06.2011

strfind


Re: Symbol blocker - Cyanide - 10.06.2011

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



AW: Symbol blocker - Julian12345 - 10.06.2011

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


Re: Symbol blocker - Cyanide - 10.06.2011

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



AW: Symbol blocker - Julian12345 - 10.06.2011

Ok, that works, thank you


Respuesta: Symbol blocker - PiCu - 11.06.2011

Код:
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