Need Tutorial
#1

Hello, I need a Tutorial on how to make a VIP/Donater System for an RP Server

I tried Searching...No Luck
Reply
#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
#3

I want one in a tutorial and that uses dcmd
Reply
#4

Quote:
Originally Posted by Bakr
Посмотреть сообщение
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;
}
I think that enumators are better than PVar
Reply
#5

Quote:
Originally Posted by System64
Посмотреть сообщение
I think that enumators are better than PVar
There's no use to create an enumeration to store one value; a simple player variable would be even better. However, with the way people create variables now and use excess memory (though it's not really a problem), I used PVars.

@seanny: I gave you everything you need to get the system you are looking for. I'm not going to just give you the direct code, you need to make an attempt to make it yourself. Don't be lazy and try to work at it, don't just expect answers from me (and hopefully nobody else, either).
Reply
#6

Quote:
Originally Posted by Bakr
Посмотреть сообщение
There's no use to create an enumeration to store one value; a simple player variable would be even better. However, with the way people create variables now and use excess memory (though it's not really a problem), I used PVars.

@seanny: I gave you everything you need to get the system you are looking for. I'm not going to just give you the direct code, you need to make an attempt to make it yourself. Don't be lazy and try to work at it, don't just expect answers from me (and hopefully nobody else, either).
https://sampforum.blast.hk/showthread.php?tid=268499
https://sampforum.blast.hk/showthread.php?tid=161454
Reply
#7

I am trying to make a new VIP System which should replace that Shitty GF VIP System
Reply
#8

Please understand that having one Pvar in your script will not harm anyone. If your worried about the speed difference between Pvars and actual variables, don't. The difference is extremely small, especially when accessing just ONE variable. Creating a separate variable to store one value, that will most likely be created inefficiently, will destroy the purpose of it anyway.

If anyone cares about efficiency in a script besides ******, Slice and all the other big names (the ones who know what they're doing), would be me. I can assure you that using one Pvar function will not kill your script. If you would like to think so, you need to create some tests for yourself.
Reply
#9

How do I remove the Shitty GF One?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)