28.01.2015, 12:20
alguem tem a base de um sistema de setar vip por dia? zcmd?
/*------------------------------------------------------------------------------
* Sistema Vip
By _ mau.tito ( Mauricio Moraes)
--------------------------------------------------------------------------------*/
#include a_samp
#include DOF2
#include zcmd
#include sscanf2
// -----------------------------------------------------------------------------
#define CallBack::%0(%1) forward %0(%1);\
public %0(%1)
//------------------------------------------------------------------------------
#define VIP'S ( "/Vips/%s.ini" )
#define MAX_VIPS ( 100 )
enum pVipInfo
{
iCash,
iVip,
iDias
}
new InfoVip [ MAX_VIPS ] [ pVipInfo ] ;
new Nome [ MAX_PLAYER_NAME ] ;
public OnFilterScriptInit(){return 1;}
public OnFilterScriptExit()
{
for ( new i=0; i<MAX_VIPS; i++)
if ( IsPlayerConnected ( i ) )
SaveVip ( i ) , DOF2::Exit ( ) ;
return 1;
}
public OnPlayerConnect(playerid)
{
LoadVip ( playerid ) ;
new file [ 50 ] ;
GetPlayerName ( playerid , Nome , sizeof ( Nome ) ) ;
format ( file , sizeof ( file ), VIP'S , Nome ) ;
if ( DOF2_FileExists ( file ) )
{
if ( gettime() >= DOF2_GetInt ( file , "Dias" ) )
{
DOF2::SetInt ( file , "Vip" , 0 ) ;
DOF2::SetInt ( file , "Dias" , 0 ) ;
DOF2_SaveFile ( ) ;
SendClientMessage ( playerid , -1 , "°iVIP° Seu Vip Expirou !! ");
DOF2_RemoveFile ( file ) ;
}
InfoVip [ playerid ] [ iVip ] = DOF2::GetInt ( file , "Vip" ) ;
InfoVip [ playerid ] [ iDias ] = DOF2::GetInt ( file , "Dias") ;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SaveVip ( playerid ) ;
return 1;
}
public OnPlayerText(playerid, text[])
{
static Tito[75];
GetPlayerName ( playerid , Nome , sizeof ( Nome ) ) ;
if ( InfoVip [ playerid ] [ iVip ] >= 1 )format(Tito,sizeof(Tito),"[V.I.P] %s: %s",Nome,text);
else if ( InfoVip [ playerid ] [ iVip ] == 0 )format(Tito,sizeof(Tito)," %s: %s",Nome,text);
SendClientMessageToAll(-1,Tito);
return 0;
}
public OnPlayerSpawn(playerid)
{
if ( InfoVip [ playerid ] [ iVip ] == 1 )
SetPlayerArmour ( playerid , 50 ) , SetPlayerHealth ( playerid , 100 );
else if ( InfoVip [ playerid ] [ iVip ] == 2 )
SetPlayerArmour ( playerid , 80 ) , SetPlayerHealth ( playerid , 100 );
else if ( InfoVip [ playerid ] [ iVip ] == 3 )
SetPlayerArmour ( playerid , 80 ) , SetPlayerHealth ( playerid , 100 ) , GivePlayerWeapon ( playerid , 24 , 500 ) ;
return 1;
}
public OnPlayerUpdate(playerid)
{
if ( InfoVip [ playerid ] [ iVip ] == 0 )
RemoveVip ( playerid ) ;
return 1;
}
//------------------------------------------------------------------------------
command(darvip, playerid, params[])
{
new ID , Stats , Dias;
if ( IsPlayerAdmin ( playerid ) )
{
if ( sscanf ( params , "uii" , ID , Stats , Dias ) )
{
SendClientMessage ( playerid , -1 , "°iCMD° /darvip [ Nome/ID ] [ Stats/Level ] [ Dias ] " ) ;
return 1;
}
SendClientMessage ( playerid , -1 , "°iSet° Vocк setou o player ! " ) ;
SendClientMessage ( ID , -1 , "°iSet° Vocк foi setado pelo administrado , agora vocк eй um VIP !! " ) ;
InfoVip [ ID ] [ iVip ] = Stats ;
InfoVip [ ID ] [ iDias ] = ( gettime ( ) + ( Dias * 24 * 60 * 60 ) ) ;
return 1;
}
else SendClientMessage ( playerid , -1 , "°iErro° Vocк nгo e administrador . " ) ;
return 1;
}
command(tirarvip, playerid, params[])
{
new ID ;
if ( IsPlayerAdmin ( playerid ) )
{
if ( sscanf ( params , "u" , ID ) )
{
SendClientMessage ( playerid , -1 , "°iCMD° /darvip [ Nome/ID ] " ) ;
return 1;
}
if ( InfoVip [ ID ] [ iVip ] == 0 ) return SendClientMessage( playerid , -1 , "°iErro° Este player nгo e VIP ." ) ;
SendClientMessage ( playerid , -1 , "°iSet° Vocк setou o player ! " ) ;
SendClientMessage ( ID , -1 , "°iSet° Vocк foi setado pelo administrado , agora vocк nгo й mais VIP !! " ) ;
InfoVip [ ID ] [ iVip ] = 0 ;
InfoVip [ ID ] [ iDias ] = 0 ;
return 1;
}
else SendClientMessage ( playerid , -1 , "°iErro° Vocк nгo e administrador . " ) ;
return 1;
}
command(darcash, playerid , params [] )
{
new ID , Quant ;
if ( IsPlayerAdmin ( playerid ) )
{
if ( sscanf ( params , "ui" , ID , Quant ) )
{
SendClientMessage ( playerid , -1 , "°iCMD° /darcash [ Nome/ID ] [ Quantidade ] " ) ;
return 1;
}
SendClientMessage ( playerid , -1 , "°iSet° Vocк setou o player ! " ) ;
SendClientMessage ( ID , -1 , "°iSet° Vocк foi setado pelo administrado !! " ) ;
InfoVip [ ID ] [ iCash ] += Quant ;
}
else SendClientMessage ( playerid , -1 , "°iErro° Vocк nгo e administrador . " ) ;
return 1;
}
command(comprarvip, playerid, params[])
{
new Estilo ;
if ( sscanf ( params , "i" , Estilo ) )
{
SendClientMessage ( playerid , -1 , "°iCMD° /comprarvip [ Estilo ] " ) ;
SendClientMessage ( playerid , -1 , "°iStats° VIP Level 1 : 5000 Cash" ) ;
SendClientMessage ( playerid , -1 , "°iStats° VIP Level 2 : 10000 Cash" ) ;
SendClientMessage ( playerid , -1 , "°iStats° VIP Level 3 : 20000 Cash" ) ;
return 1;
}
if ( Estilo < 1 || Estilo > 3 ) return SendClientMessage ( playerid , -1 , "°iErro° So entre 1 a 3 " ) ;
if ( Estilo == 1 )
{
if ( InfoVip [ playerid ] [ iCash ] < 5000 ) return SendClientMessage ( playerid , -1 , "°iErro° Vocк nгo tem todo o cash para efetuar a compra !");
InfoVip [ playerid ] [ iVip ] = 1 ;
InfoVip [ playerid ] [ iCash ] -= 5000 ;
SendClientMessage ( playerid , -1 , "°iCompra° Compra efetuada com sucesso !" ) ;
InfoVip [ playerid ] [ iDias ] = ( gettime ( ) + ( 1 * 24 * 60 * 60 ) ) ;
}
if ( Estilo == 2 )
{
if ( InfoVip [ playerid ] [ iCash ] < 10000 ) return SendClientMessage ( playerid , -1 , "°iErro° Vocк nгo tem todo o cash para efetuar a compra !");
InfoVip [ playerid ] [ iVip ] = 2 ;
InfoVip [ playerid ] [ iCash ] -= 10000 ;
SendClientMessage ( playerid , -1 , "°iCompra° Compra efetuada com sucesso !" ) ;
InfoVip [ playerid ] [ iDias ] = ( gettime ( ) + ( 1 * 24 * 60 * 60 ) ) ;
}
if ( Estilo == 3 )
{
if ( InfoVip [ playerid ] [ iCash ] < 20000 ) return SendClientMessage ( playerid , -1 , "°iErro° Vocк nгo tem todo o cash para efetuar a compra !");
InfoVip [ playerid ] [ iVip ] = 3 ;
InfoVip [ playerid ] [ iCash ] -= 20000 ;
SendClientMessage ( playerid , -1 , "°iCompra° Compra efetuada com sucesso !" ) ;
InfoVip [ playerid ] [ iDias ] = ( gettime ( ) + ( 1 * 24 * 60 * 60 ) ) ;
}
return 1;
}
command(vips, playerid , params [] )
{
new Cont, str[ 150 ] , Mauricio [ MAX_PLAYER_NAME ] ;
for ( new i=0; i<MAX_VIPS; i++)
{
Cont ++ ;
GetPlayerName ( playerid , Mauricio , sizeof ( Mauricio ) ) ;
if ( IsPlayerConnected ( i ) && InfoVip [ i ] [ iVip ] > 0 )
{
format ( str , sizeof ( str ) , "(%i°) %s : %s | %s " , Cont , Mauricio , VipName ( i ) , DiasVips(i));
SendClientMessage ( playerid , -1 , str ) ;
return 1;
}
}
return 1;
}
//------------------------------------------------------------------------------
stock DiasVips(playerid)
{
new Text[50];
if ( InfoVip [ playerid ] [ iDias ] >= 1362012111 ) Text = "1 Dia" ;
if ( InfoVip [ playerid ] [ iDias ] >= 2362012111 ) Text = "2 Dias" ; // Adcione mais
return Text;
}
CallBack::SaveVip ( playerid )
{
new file [ 50 ] ;
GetPlayerName ( playerid , Nome , sizeof ( Nome ) ) ;
format ( file , sizeof ( file ), VIP'S , Nome ) ;
if ( !DOF2::FileExists ( file ) ) DOF2::CreateFile ( file ) ;
DOF2::SetInt ( file , "Cash" , InfoVip [ playerid ] [ iCash ] ) ;
DOF2::SetInt ( file , "Vip" , InfoVip [ playerid ] [ iVip ] ) ;
DOF2::SetInt ( file , "Dias" , InfoVip [ playerid ] [ iDias ] ) ;
DOF2::SaveFile();
return 1;
}
CallBack::LoadVip ( playerid )
{
new file [ 50 ] ;
GetPlayerName ( playerid , Nome , sizeof ( Nome ) ) ;
format ( file , sizeof ( file ), VIP'S , Nome ) ;
if ( !DOF2::FileExists ( file ) ) CreatVip ( playerid ) ;
InfoVip [ playerid ] [ iCash ] = DOF2::GetInt ( file , "Cash" ) ;
InfoVip [ playerid ] [ iVip ] = DOF2::GetInt ( file , "Vip" ) ;
InfoVip [ playerid ] [ iDias ] = DOF2::GetInt ( file , "Dias") ;
return 1;
}
CallBack::CreatVip ( playerid )
{
new file [ 50 ] ;
GetPlayerName ( playerid , Nome , sizeof ( Nome ) ) ;
format ( file , sizeof ( file ), VIP'S , Nome ) ;
DOF2::CreateFile ( file ) ;
DOF2::SetInt ( file , "Cash" , InfoVip [ playerid ] [ iCash ] ) ;
DOF2::SetInt ( file , "Vip" , InfoVip [ playerid ] [ iVip ] ) ;
DOF2::SetInt ( file , "Dias" , InfoVip [ playerid ] [ iDias ] ) ;
DOF2::SaveFile();
return 1;
}
CallBack::RemoveVip ( playerid )
{
new file [ 50 ] ;
GetPlayerName ( playerid , Nome , sizeof ( Nome ) ) ;
format ( file , sizeof ( file ), VIP'S , Nome ) ;
if ( DOF2::FileExists ( file ) )
DOF2_RemoveFile ( file ) ;
return 1;
}
stock VipName ( playerid )
{
new text [ 15 ] ;
if ( InfoVip [ playerid ] [ iVip ] == 1 ) text = "VIP Bronze" ;
else if ( InfoVip [ playerid ] [ iVip ] == 2 ) text = "VIP Ouro" ;
else if ( InfoVip [ playerid ] [ iVip ] == 3 ) text = "Socio" ;
return text;
}