SA-MP Forums Archive
Speeding Coding up. - 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: Speeding Coding up. (/showthread.php?tid=363240)



Speeding Coding up. - MZ5 - 27.07.2012

Hey,

At the current time, I am writing full code:

pawn Код:
if(!strcmp(params, "ammu", false, strlen(params)) || !strcmp(params, "lspd", false, strlen(params)) || !strcmp(params, "sfpd", false, strlen(params)) || !strcmp(params, "sasd", false, strlen(params)) || !strcmp(params, "noose", false, strlen(params)) || !strcmp(params, "bank", false, strlen(params)) || !strcmp(params, "cityhall", false, strlen(params)) || !strcmp(params, "tp", false, strlen(params)))
I was wondering, how would I convert this into a list? If possible of course, like:

pawn Код:
new AntiAdminAbuseTp
{
... Items Here...
}
Could someone explain how this would work ?

Thanks,

-Mike.


Re: Speeding Coding up. - SuperViper - 27.07.2012

pawn Код:
new bool: stringMatch, AntiAdminAbuseTp[][] =
{
    "ammu",
    "lspd",
    "etc",
    "final option"
};

for(new i = 0, sof = sizeof(AntiAdminAbuseTp); i < sof; i++)
{
    if(strcmp(params, AntiAdminAbuseTp[i], true) == 0)
    {
        stringMatch = true;
        break;
    }
}

if(stringMatch == true)
{
    // The params matched an item on the list
}
else
{
    // The params didn't match an item on the list
}



Re: Speeding Coding up. - MZ5 - 27.07.2012

Thanks but what after that? Like on the actual command?


Re: Speeding Coding up. - SuperViper - 27.07.2012

Edited my post.