SA-MP Forums Archive
[HELP] Creating Varibles For Admins [Rep+] - 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: [HELP] Creating Varibles For Admins [Rep+] (/showthread.php?tid=301884)



[HELP] Creating Varibles For Admins [Rep+] - xMichaelx - 06.12.2011

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


Re: [HELP] Creating Varibles For Admins [Rep+] - T0pAz - 06.12.2011

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.


Re: [HELP] Creating Varibles For Admins [Rep+] - xMichaelx - 06.12.2011

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


Re: [HELP] Creating Varibles For Admins [Rep+] - T0pAz - 06.12.2011

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 );



Re: [HELP] Creating Varibles For Admins [Rep+] - xMichaelx - 06.12.2011

Thank you very much.


Re: [HELP] Creating Varibles For Admins [Rep+] - xMichaelx - 06.12.2011

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


Re: [HELP] Creating Varibles For Admins [Rep+] - T0pAz - 06.12.2011

what error does it gave?


Re: [HELP] Creating Varibles For Admins [Rep+] - THE_KNOWN - 06.12.2011

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