MySQL fetch
#4

Quote:
Originally Posted by dusk
Посмотреть сообщение
Hey, this command should tell players how many admins online are there right? Why dend a query for it?
Yeah I wondered the same. There's no reason for you to update the database when an admin connects or leaves - that's just silly. Make a function instead!

pawn Код:
bool:IsAdminOnline(adminid)
{
    if( !IsPlayerAdmin( adminid )) // If the ID provided isn't an admin, this function should return false.
        return false;
    foreach( Player, i )
    {
        if( adminid == i ) // If the ID provided equals on of the online IDs (which foreach fetches for us) - then the player is online
            return true;
    }
    return false; // All other cases: Return false.
}
Without foreach:

pawn Код:
bool:IsAdminOnline(adminid)
{
    for( new i = 0, j = GetMaxPlayers(); i < j; i ++ )
    {
        if( adminid == i && IsPlayerAdmin( adminid ) && IsPlayerConnected( adminid )) // If the ID provided equals on of the online IDs (which foreach fetches for us) - then the player is online
            return true;
    }
    return false; // All other cases: Return false.
}
Reply


Messages In This Thread
MySQL fetch - by ancezas - 21.03.2013, 20:02
Re: MySQL fetch - by ancezas - 22.03.2013, 04:23
Re: MySQL fetch - by dusk - 22.03.2013, 07:28
Re: MySQL fetch - by LarzI - 22.03.2013, 08:17

Forum Jump:


Users browsing this thread: 3 Guest(s)