Jump to content
  • 0

Ajutor comanda /leaders


Mister

Question

Problema intalnita (descriere): Am un gm pe mysql si nu stiu cum sa fac o comanda sa afiseze liderii factiunilor(chiar daca sunt offline sau online)
Ero(area / rile) / warning-(ul / urile):
Liniile de cod / sursa / script-ul(obligatoriu):

if(strcmp(cmd, "/offmakeleader", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] > 5)
            {
                 new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "{00FF00}Folosire:{FFFFFF} /offmakeleader [NUMELE-EXACT]");
                    return 1;
                }
                new Query[256];
                   format(Query, sizeof(Query), "SELECT `username` FROM `players` WHERE username = '%s' AND Leader > 0 LIMIT 1", (result));
                mysql_query(Query);
                mysql_store_result();
                if(!mysql_num_rows())
                {
                    format(string, sizeof(string), "Nu este nimeni cu numele %s inregistrat/cu factiune!", (result));
                    mysql_free_result();
                    return SendClientMessage(playerid, 0xDC0C0CFF, string);
                }
                else if(mysql_num_rows() != 0)
                {
                    format(Query, sizeof(Query), "UPDATE `players` SET `Leader` = 0 WHERE username = '%s'", (result));
                    mysql_query(Query);
                    mysql_store_result();
                    format(string, sizeof(string), "{1580EA}[Info:] {FFFFFF}%s nu mai este lider!", (result));
                    ABroadCast(0xa9c4e4FF, string, 1);
                    mysql_free_result();
                }
            }
        }
    }

Comanda de face un leader offline.

 

 

Comanda care am incercat sa o fac si da eroare

   if (strcmp(cmd, "/leaders", true) == 0)
    {

        new Query[256];


        format(Query, sizeof(Query), "SELECT * FROM `players` WHERE `Leader` = '%d'", PlayerInfo[playerid][pMember]);
        mysql_query(MySQLCon, Query, "", "");
        new numrows = cache_get_rows();
        new username[MAX_PLAYER_NAME], string[128];
        if(numrows > 0)
        {
             for(new i; i < numrows; i++)
             {
                   cache_get_field_content(i, "Username", username, 1, sizeof(username));
                   if(ReturnUser(username))
                   {
                        format(string, sizeof(string), "%s[ONLINE]", username);
                        return SendClientMessage(playerid, -1, string);
                   }
                   format(string, sizeof(string), "%s[OFFLINE]", username);
                   SendClientMessage(playerid, -1, string);
             }
        }
    }

Imagini / Video (optional):
Ati incercat sa rezolvati singur?: am tot cautat pe net comenzi si am incercat sa le modific cu datele mele dar nu a mers.

 

    __  ____      __           
   /  |/  (_)____/ /____  _____
  / /|_/ / / ___/ __/ _ \/ ___/
 / /  / / (__  ) /_/  __/ /    
/_/  /_/_/____/\__/\___/_/     
SERVICII SCRIPTING DE CALITATE
Pagina     Scripting     pawn
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Poftim aici :

CMD:leaders( playerid, params [ ] )
{
	new szString[ 1200 ];
	format( szString, sizeof( szString ), "{FFFFFF}LSPD - Lider: %s (%s) - Membri: %d/10n", GetFactionLeader( 1 ), IsOnline( GetFactionLeader( 1 ) ), GetFactionMembers( 1 ) );
         //// ETC
	ShowPlayerDialog( playerid, 3434, DIALOG_STYLE_MSGBOX, "Lista Factiunilor", szString, "Ok", "" );
	return 1;
}
stock IsOnline( szName[ ] )
{
	new szState[ 40 ];
    if( IsPlayerConnected( ReturnUserEx( szName ) ) )
	{
		format( szState, 40, "{C0FF00}Online{FFFFFF}" );
	}
	else format( szState, 40, "{FF0000}Offline{FFFFFF}" );
	return szState;
}

stock GetFactionLeader( FactionID )
{
	new szString[ 128 ], Cache: Result, Get[ 2 ], szLeaderName[ MAX_PLAYER_NAME ];
	format( szString, sizeof( szString ), "SELECT `Name` FROM `users` WHERE `Leader` = %d LIMIT 1;", FactionID );// Aici modifici tu cum ai in baza de date !!
    Result = mysql_query( SQL, szString );
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
    if( !Get[ 0 ] ) szLeaderName = "NO-ONE";
   	 else cache_get_field_content( 0, "Name", szLeaderName, SQL, sizeof( szLeaderName ) );
    cache_delete( Result );
	return ( szLeaderName );
}

stock GetFactionMembers( FactionID )
{
	new szString[ 128 ], Cache: Result, Get[ 2 ];
	format( szString, sizeof( szString ), "SELECT `Member` FROM `users` WHERE `Member` = %d", FactionID );// Aici modifici tu cum ai in baza de date !!
    Result = mysql_query( SQL, szString );
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
    cache_delete( Result );
	return Get[ 0 ];
}
Link to comment
Share on other sites

  • 0

pai nu ma pricep cu mysql cu pawno stiu destul de bine zic eu, dar nu inteleg ce e cu alea de la mysql queri si toate alea.

 

    __  ____      __           
   /  |/  (_)____/ /____  _____
  / /|_/ / / ___/ __/ _ \/ ___/
 / /  / / (__  ) /_/  __/ /    
/_/  /_/_/____/\__/\___/_/     
SERVICII SCRIPTING DE CALITATE
Pagina     Scripting     pawn
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.