18.07.2011, 09:18
Hello, I need a Tutorial on how to make a VIP/Donater System for an RP Server
I tried Searching...No Luck
I tried Searching...No Luck
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;
}
SetPVarInt( playerid, "VIP", /*level here*/ );
CMD:command( playerid, params[ ] )
{
if( GetPVarInt( playerid, "VIP" ) > 0 )
{
// code here
}
return 1;
}
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 Код:
pawn Код:
pawn Код:
|
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). |