Need Tutorial -
seanny - 18.07.2011
Hello, I need a Tutorial on how to make a VIP/Donater System for an RP Server
I tried Searching...No Luck
Re: Need Tutorial -
Bakr - 18.07.2011
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;
}
Re: Need Tutorial -
seanny - 18.07.2011
I want one in a tutorial and that uses dcmd
Re: Need Tutorial -
System64 - 18.07.2011
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
Re: Need Tutorial -
Bakr - 18.07.2011
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).
Re: Need Tutorial -
MoroDan - 18.07.2011
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
Re: Need Tutorial -
seanny - 18.07.2011
I am trying to make a new VIP System which should replace that Shitty GF VIP System
Re: Need Tutorial -
Bakr - 18.07.2011
Quote:
Originally Posted by MoroDan
|
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.
Re: Need Tutorial -
seanny - 18.07.2011
How do I remove the Shitty GF One?