Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < a_samp >
- #include < a_mysql >
- #include < zcmd >
- //#include < sscanf2 >
- #define DB_SERVER "127.0.0.1"
- #define DB_USER "root"
- #define DB_PASS ""
- #define DB_DB "samp"
- new
- pLevel [ MAX_PLAYERS ] ,
- pName [ 24 char ] ,
- dbHandle ,
- gQuery [ 356 char ] ;
- public OnGameModeInit ( )
- {
- dbHandle = mysql_connect ( DB_SERVER , DB_USER , DB_DB , DB_PASS ) ;
- mysql_tquery ( dbHandle , "CREATE TABLE IF NOT EXISTS admin (username varchar(40),pAdminlevel int(6)" ) ;
- }
- public OnPlayerConnect ( playerid )
- {
- GetPlayerName(playerid, pName , 24 ) ;
- format ( gQuery , 128 , "SELECT * FROM admin WHERE username='%s'" , pName ) ;
- mysql_function_query ( dbHandle , gQuery , 356 , "getPlayerData" , "i" , playerid ) ;
- new localString [ 128 char ] ;
- if ( pLevel [ playerid ] > 0 )
- {
- format ( localString , 128 , "[*Admin MOTD]: Welcome back [%s] *keep on the rules" , pName [ playerid ] ) ;
- SendClientMessage ( playerid , -1 , localString ) ;
- }
- return 1 ;
- }
- public OnPlayerDisconnect ( playerid , reason )
- return pName [ playerid ] = EOS , 1 ;
- COMMAND:makeadmin ( playerid , params [ ] )
- {
- if ( pLevel [ playerid ] <= 0 || pLevel [ playerid ] < 5 || !IsPlayerAdmin ( playerid ) )
- return SendClientMessage ( playerid , -1 , "[Error]: You aren't allowed to use this command!" ) ;
- if ( sscanf ( params , "ud" , params [ 0 ] , params [ 1 ] ) )
- return SendClientMessage ( playerid , -1 , "[Usage]: /MakeAdmin [ID] [Level]" ) ;
- pLevel [ params [ 0 ] ] = params [ 1 ] ;
- format ( gQuery , 356 , "INSERT INTO admin (username,pAdminlevel) VALUES ('%s','%d')" , pName [ playerid ] , params [ 1 ] ) ;
- SendClientMessage ( playerid , -1 , "[*Admin]: Your'e promted this player to Admin Stuff*" ) ;
- SendClientMessage ( params [ 0 ] , -1 , "[*Admin]: Welcome to the admin's stuff* (keep on the rules)" ) ;
- return 1 ;
- }
- COMMAND:aheal ( playerid , params [ ] )
- {
- if ( pLevel [ playerid ] <= 0 )
- return SendClientMessage ( playerid , -1 , "[Error]: You aren't allowed to use this command!" ) ;
- if ( sscanf ( params , "ud" , params [ 0 ] ) )
- return SendClientMessage ( playerid , -1 , "[Usage]: /AHeal [ID]" ) ;
- SetPlayerHealth ( playerid , SetPlayerArmour ( playerid , 100 ) ) ;
- return 1 ;
- }
- forward getPlayerData ( playerid ) ;
- public getPlayerData ( playerid )
- return pLevel [ playerid ] = cache_get_field_content_int ( 0 , "pAdminlevel" , dbHandle ) , 1 ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement