Jump to content

Recommended Posts

Posted

Salut GTA-MP .

Daca am gresit ceva, astept reply.

Astazi am sa va arat cum sa faceti un sistem de ban offline, adica sa poata bana un jucator offline .

Acesta este primul meu tutorial deci vreau sa ma criticati .

Trebuie sa aveti MySQL In gm-ul dvs.

Avem nevoie de XAMPP sau WAMP . Eu recomand XAMPP

Bun, sa incepem !

zSa6n1T.png

[img width=500 height=400] fKL0BnH.png

[img width=500 height=400] PJNtACC.png

[img width=500 height=400] jQkKfCL.png

Am sa folosesc:

  #include <ZCMD>

  #include <a_mysql> // mysql r34

  #include <sscanf2>

new aHandle ;

new gQuery[ 2000 ] ;

public OnPlayerConnect( playerid )

  [tt]gQuery[ 0 ] = EOS ;

 

  new ConnectedIP[ 24 ];

  GetPlayerIp( playerid, ConnectedIP, 24 );

  format( gQuery, sizeof gQuery, "SELECT * FROM `Banlist` WHERE `IP`='%s' OR `Name`='%s'", ConnectedIP, GetName( playerid ) );

  mysql_tquery( aHandle, gQuery, "CheckBan", "d", playerid );[/tt]

  Explicatie:

  [tt]EOS = End Of String - Opreste string-ul cand propozitia se termina.

  GetPlayerIp( playerid, name[], len ) .

  SELECT * FROM `Banlist` WHERE `IP`='%s' OR `Name`='%s' // Selecteaza din baza de date tabelul `BANLIST` , Name sau IP

  mysql_tquery( connectionHandle, query[], callback[], format[], {Float,_}:... );[/tt]


CMD:banoff( playerid, params[ ] )

{

  [tt]if ( IsPlayerAdmin( playerid ) )

      return SendClientMessage( playerid, "Nu esti administrator RCON !" ) ;

 

  gQuery[ 0 ] = EOS ;

 

  new Player[ 24 ], Reason[ 128 ] ;

 

  if( sscanf( params, "s[24]s[128]", Player, Reason ) )

      return SendClientMessage( playerid, -1, "Foloseste: /banoff <PartOfName> <Reason>" ) ; 

 

  new Security[ 24 ];

 

  mysql_escape_string( Player, Security );

  format( gQuery, sizeof gQuery, "SELECT * FROM `Users` WHERE `Name`='%s'", Security ) ;

  mysql_tquery( aHandle, gQuery, "OnBanOfflineCalled", "ssd", Security, Reason, playerid ) ;

  return ( 1 ) ;

}

  Explicatie:

  sscanf( const data[], const format[], {Float,_}:... ) ;

  s[24] - S = String

  s[128] - S = String (Altele: "u" - User ID or Name, "i" integer, "f" float, "x", Hex number)

  Player, Reason - Parametrii

  SendClientMessage( playerid, color, const message[] )

  mysql_escape_string( const source[], destination[], connectionHandle = 1, max_len = sizeof(destination) ) ;

  mysql_tquery( connectionHandle, query[], callback[], format[], {Float,_}:... ); // in cazul nostru folosim callback-ul OnBanOfflineCalled


forward OnBanOfflineCalled( Security[ ], Reason[ ], playerid, Player ) ;

public OnBanOfflineCalled( Security[ ], Reason[ ], playerid, Player )

{

  gQuery[ 0 ] = EOS ;       

  format( gQuery, sizeof gQuery, "INSERT INTO `Banlist` VALUES(0, 'Banned Offline', '%s', '%s', '%s')", Security, GetName( playerid ), Reason );

  mysql_tquery( aHandle, gQuery, "", "" );

  return ( 1 );

}

  Explicatie:

 

  INSERT INTO `Banlist` VALUES(0, 'Banned Offline', '%s', '%s', '%s') // Insereaza in tabelul `Banlist` Valorile .

  mysql_tquery( connectionHandle, query[], callback[], format[], {Float,_}:... ); // in cazul nostru nu am folosit nici un callback


forward CheckBan( playerid ) ;

public CheckBan( playerid )

{

  new Reason[ 128 ], Admin[ 128 ], Rows, Fields;

  cache_get_data( Rows, Fields, aHandle ) ;

 

  if ( !Rows )

      return ( 1 ) ;

     

  gQuery[ 0 ] = EOS ;

  cache_get_field_content( 0, "Reason", Reason, 1, 128 );

  cache_get_field_content( 0, "Admin", Admin, 1, 128 );

  format( gQuery, sizeof gString, "Numele Adminului: %s", Admin ) ;

  SendClientMessage( playerid, -1, gQuery ) ;

  format( gQuery, sizeof gString, "Motivul Banului: %s", Reason ) ;

  SendClientMessage( playerid, -1, gQuery ) ;

  SetTimerEx( "KickPlayer", 50, false, "i", playerid ) ;

  return ( 1 ) ;

}

  Explicatie:

  cache_get_field_content( row, const field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination) );

  cache_get_data( &num_rows, &num_fields, connectionHandle = 1 );


forward KickPlayer( playerid ) ;

public KickPlayer( playerid )

  return Kick( playerid ) ;


stock GetName( playerid )

{

  new GetPName[ 24 ];

  GetPlayerName( playerid, GetPName, sizeof( GetPName ) ) ;

  return ( GetPName ) ;

}

Multumesc, o sa mai fac tutoriale MySQL, cum sa faci un sistem de inregistrare / logare  etc.

  [/tt]

7bdea99b11.png

rimmon curv.

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.