Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Mysql selecting all players that have certain variable

$
0
0
I want to print all members from certain faction. This what I will post works but it prints only one player from database. I think callback CheckOrgPlayers isn't working properly.

PHP Code:

YCMD:members(playeridparams[], help)
{
    
#pragma unused help
    
new string[50];

    if(
PlayerInfo[playerid][pMember] < 1) return SendClientMessage(playeridCOLOR_ERROR"You are not in faction.");

    new 
teamnumber;
    if(
PlayerInfo[playerid][pMember] != 0teamnumber PlayerInfo[playerid][pMember];
    
SendClientMessage(playerid0x00FF00FF"List of faction members:");

    new 
DB_Query[250];
    
mysql_format(DatabaseDB_Querysizeof(DB_Query), "SELECT * FROM `PLAYERS` WHERE `Member` = %d LIMIT 1"teamnumber);
    
mysql_tquery(DatabaseDB_Query"CheckOrgPlayers""ii"playeridteamnumber);
     
    return 
1;


PHP Code:

forward public CheckOrgPlayers(playeridteamnumber);
public 
CheckOrgPlayers(playeridteamnumber)
{
    if(
cache_num_rows() > 0)
    {

        for(new 
icache_num_rows(); i++)
        {
            new 
string[50];
            new 
Nick[24], RankStatus;
            
cache_get_value(0"Name"Nick24);
            
cache_get_value_int(0"Rank"Rank);
            
cache_get_value_int(0"LoggedIn"Status);

            if(
Status == 0)
            {
                
format(stringsizeof(string), "    %s (%d) OFFLINE"NickRank);
                
SendClientMessage(playerid, -1string);
            }
            else if(
Status == 1)
            {
                
format(stringsizeof (string),"    %s (%d) ONLINE"NickRank);
                
SendClientMessage(playerid, -1string);
            }

           
         }
  
    }    
    else
    {
        print(
"Couldn't find anything.");
    }
    return 
1;



Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>