SA-MP Forums Archive
strcmp & arrays - 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: strcmp & arrays (/showthread.php?tid=280197)



strcmp & arrays - ScottCFR - 30.08.2011

Okay, so I got a couple things to ask about.

First, I'm making a "tag ban" script. When I use strcmp, set the length to 4, no matter who joins it will kick them if they have [ & ] & A & A in they're name. Here's the code:
Код:
    if(strcmp(pName, "[HB]", false, 4))
    {
        if(!GetPVarInt(playerid, "Admin"))
        {
			SendClientMessage(playerid, COLOR_RED, "The tag [HB] is admin only!");
			Kick(playerid);
        }
    }
Second, I want to create an array of commands. That array will be the commands that doesn't show up in admin see all, I'm not good with arrays and am not sure if you can just compare the string right off. Can someone explain how this can be achieved?

Thanks,
Scott


Re: strcmp & arrays - FireCat - 30.08.2011

Try
pawn Код:
if(strcmp(pName, "[HB]") == 0)
    {
        if(!GetPVarInt(playerid, "Admin"))
        {
            SendClientMessage(playerid, COLOR_RED, "The tag [HB] is admin only!");
            Kick(playerid);
        }
    }



Re: strcmp & arrays - Kar - 30.08.2011

pawn Код:
if(strfind(pName, "[HB]", true) != -1)
    {
        if(!GetPVarInt(playerid, "Admin"))
        {
            SendClientMessage(playerid, COLOR_RED, "The tag [HB] is admin only!");
            Kick(playerid);
        }
    }