SA-MP Forums Archive
To check if a slot is available? - 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: To check if a slot is available? (/showthread.php?tid=463970)



To check if a slot is available? - Ahrim - 14.09.2013

Hello,

How to check if a slot is available and if there are none available, how to tell? Using Loop, for example:

pawn Код:
new string[64];
for(new i = 0; i < 5; ++i)
{
    if(Avail[i] == 1)
    {
        format(string, sizeof(string), "SLOT %d IS AVAILABLE", i);
        SCM(playerid, COLOR_WHITE, string);
        break;
    }
    else
    {
        SCM(playerid, COLOR_WHITE, "THERE IS NO MORE SLOT AVAILABLE");
    }
}



Re: To check if a slot is available? - IstuntmanI - 14.09.2013

pawn Код:
new lsString[64], liSlot = -1;
for(new i = 0; i < 5; ++i)
{
    if(Avail[i] == 1)
    {
        liSlot = i;
        break;
    }
}

if(liSlot != -1)
{
    format(lsString, 64, "SLOT %d IS BEING USED", liSlot);
    SCM(playerid, COLOR_WHITE, lsString);
}
else
{
    SCM(playerid, COLOR_WHITE, "There's no slot available");
}



Re: To check if a slot is available? - Ahrim - 14.09.2013

mmkay Thanks