[HELP] Creating Varibles For Admins [Rep+]
#1

Hey,

I am currently using MySQL and was wondering how i would create a varible for admin players still using MySQL, Any help is highly appreciated. Also will Rep+ You for help!

Thanks,

-Michael
Reply
#2

You will get more likely answer if you post it on the right section

Proper Section: https://sampforum.blast.hk/showthread.php?tid=187229

Edit: Please try to elaborate.
Reply
#3

Well it's very simple, I need to find a way of detecting if the player is an administrator or not, this would be using mysql_query i would imagine, however i need to find a way of turning this into a variable or an enum, like i said any help would be most appreciated.

I hope this is enough information, if not let me know.

Thanks

-Michael

pawn Код:
format(query2,sizeof(query2),"SELECT `Admininistrator` FROM PlayerInfo WHERE `Administrator` = '%d'",level);
            if(mysql_query(query2))
            {
                gPlayerInfo[playerid][pAdmin] = level;
            }
Tryed that but still didn't work
Reply
#4

pawn Код:
// On Top
enum pInfo
{
    pAdminLevel
}
new
    PlayerInfo[MAX_PLAYERS][pInfo]
;

// On Player Connect
new
    strAdminQuery[256],
    strPName[MAX_PlAYER_NAME]
;
GetPlayerName( playerid, strPName, sizeof( strPName ) );
format( strAdminQuery, sizeof( strAdminQuery ), "INSERT INTO players( name, admin_level ) VALUES( '%s', 0 )",
    strPName
);
mysql_query( strAdminQuery );
new
    strQuery[256],
    strPlayerName[MAX_PlAYER_NAME],
    strSavedString[80]
;
GetPlayerName( playerid, strPlayerName, sizeof( strPlayerName ) );
format( strQuery, sizeof( strQuery ), "SELECT * FROM players WHERE name='%s'", strPlayerName );
mysql_query( strQuery );
mysql_store_result();
while( mysql_fetch_row_format( strQuery,"|" ) )
{
    mysql_fetch_field_row( strSavedString, "admin_level" ); PlayerInfo[playerid][pAdminLevel] = strval( strSavedString );
}
mysql_free_result();

// On Player Disconnect
new
    strQueryz[256],
    strPzName[MAX_PlAYER_NAME],
;
GetPlayerName( playerid, strPzName, sizeof( strPzName ) );
format( strQueryz, sizeof( strQueryz ), "UPDATE players SET admin_level=%d WHERE name='%s'", PlayerInfo[playerid][pAdminLevel], strPzName );
mysql_query( strQueryz );
Reply
#5

Thank you very much.
Reply
#6

Didn't work.. Just gave me errors at the mysql_fetch_field_row part
Reply
#7

what error does it gave?
Reply
#8

change onplayerconnect code to

GetPlayerName( playerid, strPlayerName, sizeof( strPlayerName ) );
format( strQuery, sizeof( strQuery ), "SELECT * FROM players WHERE name='%s'", strPlayerName );
mysql_query( strQuery );
mysql_store_result();
while( mysql_fetch_row_format( strQuery,"|" ) )
{
sscanf( strQuery, "p<|>i",strSavedString ); PlayerInfo[playerid][pAdminLevel] = strSavedString;
}
mysql_free_result();


should work now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)