SA-MP Forums Archive
Convert Admin - 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: Convert Admin (/showthread.php?tid=627356)



Convert Admin - Loinal - 27.01.2017

Hello guys i have a command to check admin levels

And its R5 i want to convert to R41-2

PHP код:
CMD:admlevel10(playeridparams[])
{
    
mysql_query("SELECT user FROM playerdata WHERE level = 10");
    
mysql_store_result();
    if(
mysql_num_rows()) {
    new
        
ID,
        
output[800];
    while(
mysql_retrieve_row())
    {
        
ID ++;
        new
            
username[24];
        
mysql_fetch_field_row(username"user");
        
format(outputsizeof(output), "%s"ccwhite"%d. %s\n"outputIDusername);
    }
    
mysql_free_result();
    
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");}
    else {
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");}
    return 
1;




Re: Convert Admin - BiosMarcel - 27.01.2017

Can u please ****** for tutorials / check the R40+ wiki page?

If you encounter problems while converting (meaning you at least tried), then you can come here


Re: Convert Admin - Loinal - 27.01.2017

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Can u please ****** for tutorials / check the R40+ wiki page?

If you encounter problems while converting (meaning you at least tried), then you can come here
if i found anything that i can do to convert why should i come here and post -___-


Re: Convert Admin - Stev - 27.01.2017

Marcel is saying that, Attempted to learn yourself, But if you struggle post your issues and the fellow members will assist you.


Re: Convert Admin - oMa37 - 27.01.2017

This should work, But don't just copy paste.
Next time search before posting.

PHP код:
CMD:admlevel10(playeridparams[]) 
{
    new 
Cache:resultsrows;
    
results mysql_query(connectionHandle"SELECT user FROM playerdata WHERE level = 10");
    
rows cache_num_rows();
    if(
rows) { 
    
        new 
            
ID
            
output[800]; 
        for(new 
irowsi++) {
            
ID ++; 
            new 
                
username[24];
            
cache_get_value_name(i"user"username);
            
format(outputsizeof(output), "%s"ccwhite"%d. %s\n"outputIDusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;




Re: Convert Admin - Loinal - 27.01.2017

Quote:
Originally Posted by oMa37
Посмотреть сообщение
This should work, But don't just copy paste.
Next time search before posting.

PHP код:
CMD:admlevel10(playeridparams[]) 
{
    new 
Cache:resultsrows;
    
results mysql_query(connectionHandle"SELECT user FROM playerdata WHERE level = 10");
    
rows cache_num_rows();
    if(
rows) { 
    
        new 
            
ID
            
output[800]; 
        for(new 
irowsi++) {
            
ID ++; 
            new 
                
username[24];
            
cache_get_value_name(i"user"username);
            
format(outputsizeof(output), "%s"ccwhite"%d. %s\n"outputIDusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;

1- iam not copying and pasting
2- i searched but my problem that for example "Loinal" is in R5 and in R41-2 is "Loinaal" how should i know?? :\


Re: Convert Admin - Loinal - 27.01.2017

Quote:
Originally Posted by oMa37
Посмотреть сообщение
This should work, But don't just copy paste.
Next time search before posting.

PHP код:
CMD:admlevel10(playeridparams[]) 
{
    new 
Cache:resultsrows;
    
results mysql_query(connectionHandle"SELECT user FROM playerdata WHERE level = 10");
    
rows cache_num_rows();
    if(
rows) { 
    
        new 
            
ID
            
output[800]; 
        for(new 
irowsi++) {
            
ID ++; 
            new 
                
username[24];
            
cache_get_value_name(i"user"username);
            
format(outputsizeof(output), "%s"ccwhite"%d. %s\n"outputIDusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;

PHP код:
CMD:admlevel10(playeridparams[])
{
    new 
Cache:resultsrows;
    
results mysql_query(mysql"SELECT user FROM players WHERE Admin = 10");
    
rows cache_num_rows();
    if(
rows) {
        new
            
output[800];
        for(new 
irowsi++) {
            new
                
username[24];
            
cache_get_value_name(i"Username"username);
            
format(outputsizeof(output), "%s %s\n"outputusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;

It says
Код:
No Admins of this level.
and /admins says

Код:
Martex [Level 10] (ServerOwner)



Re: Convert Admin - X337 - 27.01.2017

Quote:
Originally Posted by Loinal
Посмотреть сообщение
PHP код:
CMD:admlevel10(playeridparams[])
{
    new 
Cache:resultsrows;
    
results mysql_query(mysql"SELECT user FROM players WHERE Admin = 10");
    
rows cache_num_rows();
    if(
rows) {
        new
            
output[800];
        for(new 
irowsi++) {
            new
                
username[24];
            
cache_get_value_name(i"Username"username);
            
format(outputsizeof(output), "%s %s\n"outputusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;

It says
Код:
No Admins of this level.
and /admins says

Код:
Martex [Level 10] (ServerOwner)
Change the query to: "SELECT user FROM playerdata WHERE level = 10"

Also you said:
Quote:
Originally Posted by Loinal
Посмотреть сообщение
1- iam not copying and pasting
You are just copy and paste oMa37's code, and you don't even change the query.


Re: Convert Admin - SyS - 27.01.2017

Quote:
Originally Posted by Loinal
Посмотреть сообщение
PHP код:
CMD:admlevel10(playeridparams[])
{
    new 
Cache:resultsrows;
    
results mysql_query(mysql"SELECT user FROM players WHERE Admin = 10");
    
rows cache_num_rows();
    if(
rows) {
        new
            
output[800];
        for(new 
irowsi++) {
            new
                
username[24];
            
cache_get_value_name(i"Username"username);
            
format(outputsizeof(output), "%s %s\n"outputusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;

It says
Код:
No Admins of this level.
and /admins says

Код:
Martex [Level 10] (ServerOwner)

Take a look @ your code (red part)
Код:
CMD:admlevel10(playerid, params[])
{
    new Cache:results, rows;
    results = mysql_query(mysql, "SELECT user FROM players WHERE Admin = 10");

    rows = cache_num_rows();

    if(rows) {

        new
            output[800];

        for(new i; i < rows; i++) {

            new
                username[24];

            cache_get_value_name(i, "Username", username);

            format(output, sizeof(output), "%s %s\n", output, username);
        }
        ShowPlayerDialog(playerid, 1101, DIALOG_STYLE_MSGBOX, "Level 10 Admins", output, "OK", "Cancel");
    }
    else ShowPlayerDialog(playerid, 1101, DIALOG_STYLE_MSGBOX, "Level 10 Admins", "No Admins of this level.", "OK", "Cancel");
    cache_delete(results);
    return 1;
}
Also dont declare variables inside the loop and usage of id variable is not needed use i instead.


PHP код:
CMD:admlevel10(playeridparams[])
{
    static  
Cache:results,
              
rows;
    
results mysql_query(mysql"SELECT user FROM players WHERE Admin = 10");
    
rows cache_num_rows();
    if(
rows) {
        new
            
output[800];          
       static 
username[24];
        for(new 
irowsi++) {
           
            
cache_get_value_name(i"user"username);
            
format(outputsizeof(output), "%s %s\n"outputusername);
        }
        
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins"output"OK""Cancel");
    }
    else 
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Level 10 Admins""No Admins of this level.""OK""Cancel");
    
cache_delete(results);
    return 
1;

Also using strcat would be more perfect than format as it use less memory.


Re: Convert Admin - Loinal - 27.01.2017

Quote:
Originally Posted by X337
Посмотреть сообщение
Change the query to: "SELECT user FROM playerdata WHERE level = 10"

Also you said:

You are just copy and paste oMa37's code, and you don't even change the query.
Iam not copying and also "Admin" is my variable. iam just testing it.