Need Tutorial
#2

It's quite simple; You can use PVars to store and set the players VIP rank and save it to a file. When they enter the server, set their VIP level to that in the file.
pawn Код:
public OnPlayerConnect( playerid )
{
   new name[ MAX_PLAYER_NAME ], file[ MAX_PLAYER_NAME + 9 ], File: h;
   GetPlayerName( playerid, name, MAX_PLAYER_NAME );
   format( file, sizeof( file ), "VIP/%s.ini", name );
   if( fexists( file ) )
   {
      h = fopen( file, io_read );
      fread( h, file ); // we re-use the 'file' variable as it won't be used anymore, and ther'es no need to create another
      new pos = strfind( file, "=", true );
      SetPVarInt( playerid, "VIP", strval( file[ pos + 1 ] ) );
      fclose( h );
   }
   return 1;
}

public OnPlayerDisconnect( playerid, reason )
{
   new name[ MAX_PLAYER_NAME ], file[ MAX_PLAYER_NAME + 9 ], File: h;
   GetPlayerName( playerid, name, MAX_PLAYER_NAME );
   format( file, sizeof( file ), "VIP/%s.ini", name );
   h = fopen( file, io_write );
   format( file, sizeof( file ), "VIP=%i", GetPVarInt( playerid, "VIP" ) ); // Once again re-using 'file' variable
   fwrite( h, file );
   fclose( h );
   return 1;
}
Now that it is saved and loaded, you can set the player's level like so:
pawn Код:
SetPVarInt( playerid, "VIP", /*level here*/ );
You can also access the variable inside of commands, for example, to see if they can use it or not.
pawn Код:
CMD:command( playerid, params[ ] )
{
   if( GetPVarInt( playerid, "VIP" ) > 0 )
   {
      // code here
   }
   return 1;
}
Reply


Messages In This Thread
Need Tutorial - by seanny - 18.07.2011, 09:18
Re: Need Tutorial - by Bakr - 18.07.2011, 09:29
Re: Need Tutorial - by seanny - 18.07.2011, 09:30
Re: Need Tutorial - by System64 - 18.07.2011, 09:32
Re: Need Tutorial - by Bakr - 18.07.2011, 09:35
Re: Need Tutorial - by MoroDan - 18.07.2011, 09:37
Re: Need Tutorial - by seanny - 18.07.2011, 09:38
Re: Need Tutorial - by Bakr - 18.07.2011, 09:42
Re: Need Tutorial - by seanny - 18.07.2011, 10:13

Forum Jump:


Users browsing this thread: 2 Guest(s)