01.08.2017, 04:55
quero colocar esse sistema para modulo:
entao precisei instalar colocar o y_hook ficou assim:
so que quando vou compila na GM da esses warns/erros:
o unico jeito e apagar todas as linhas msm?
PHP код:
/*
#######################################################################################
### ###
### Sistema VIP ###
### ###
### Todos os scripts feitos aqui sгo te total autoria do criador. ###
### Este script estб livre para ediзгo e implementaзгo em gamemodes. ###
### ###
### Mantenha os devidos creditos no script. ###
### ###
### Criador, desenvolvedor e tester: Dry. ###
### ###
#######################################################################################
Funзхes:
- IsPlayerVIP(playerid) - Chechar se um jogador й VIP.
- LoadPlayerVIP(playerid) - Carregar dados de VIP de um jogador a partir do arquivo.
- SavePlayerVIP(playerid) - Salvar dados de VIP dentro do arquivo.
- CreateVipKey(playerid, Key[], Days) - Criar uma nova Key.
- UseVipKey(playerid, Key[]) - Usar determinada key.
- RemoveKey(playerid, Key[]) - Deletar uma key existente e nгo usada.
- GetExpirationDays(playerid) - Getar quantos dias faltam para expirar o VIP.
- SetVipForPlayer(playerid, Days) - Setar ou renovar o VIP de algum jogador.
- ShowWelcomeMessage(playerid) - Abre uma mensagem de boas vindas, contendo algumas info.
Comandos:
- CMD:setvip [ID] [DIAS] ( Admin ) // Setamos um jogador como VIP
- CMD:viphelp ( VIP ) // Algumas informaзхes sobre o seu VIP.
- CMD:ativarvip ( Default )// Um dialog serб aberto solicitando o cуdigo.
- CMD:novakey ( Admin ) // Uma nova key serб criada na pasta "Keys" para livre uso.
- CMD:delkey [KEY] ( Admin ) // Deletar uma key existente
- CMD:vips ( Default ) // Checar jogadores VIP online.
Configuraзхes:
#define CHAT_MODEL 3 - Modelo ao falar no chat. Preview In-Forъm
#define FULL_LIFE 1 - Spawnar com COLETE E VIDA FULL
#define DEATH_RESPAWN_LOCAL 1 - Spawnar no local onde morreu
Instalaзгo:
- Crie uma pasta chamada "Vips" localizada em scriptfiles.
- Dentro da mesma crie as seguintas pastas:
* Users
* Keys
- O precesso de criaзгo de VIP's e keys й automatico, siga os passos e comandos dentro do game.
-Atenciosamente Dry ( Lucas ).
*/
#include <a_samp>
#include <dof2>
#include <zcmd>
#include <sscanf>
#define ENGINE::%0(%1) stock %0(%1)
#define Public::%0(%1) forward %0(%1); public %0(%1)
#define DIALOG_ATIV_KEY 779
#define DIALOG_MAKE_KEY 779+1
#define DIALOG_MAKE_DAYS 779+2
#define DIALOG_CONFIRM 779+3
//Folder's
#define VIP_USERS "Vips/Users/%s.ini"
#define VIP_KEYS "Vips/Keys/%s.ini"
//Colors
#define Default 0xDE3A3AFF
#define Branco 0xFFFFFFFF
//Config
#define CHAT_MODEL 3
#define FULL_LIFE 1
#define DEATH_RESPAWN_LOCAL 1
#if DEATH_RESPAWN_LOCAL == 1// Usado para armazenar Locais de onde morreu
new Float: X[MAX_PLAYERS], Float: Y[MAX_PLAYERS], Float: Z[MAX_PLAYERS], Interior[MAX_PLAYERS];
#endif
//Player Definitions
enum PlayerParams
{
bool:VIP,
dExpiration,
hExpiration
};
new Player[MAX_PLAYERS][PlayerParams];
new bool:VisibleWelcome[MAX_PLAYERS];
new Text:DrawWelcome[MAX_PLAYERS][6];
new TimerDraw[MAX_PLAYERS];
new cKey[MAX_PLAYERS][128], cDays[MAX_PLAYERS];
public OnFilterScriptInit()
{
for ( new playerid = 0; playerid < GetMaxPlayers(); playerid++)
{
if ( IsPlayerConnected(playerid))
{
LoadPlayerVIP(playerid);
}
}
SetTimer("CheckVipsInGame", 60000, true);
print("VIP System Loaded");
return 1;
}
Public::CheckVipsInGame()
{
for ( new playerid = 0; playerid < GetMaxPlayers(); playerid++)
{
if ( IsPlayerConnected(playerid) && IsPlayerVIP(playerid))
{
if ( GetExpirationDays(playerid) <= 0)
{
SetVipForPlayer(playerid, 0);
}
}
}
}
public OnFilterScriptExit()
{
for ( new playerid = 0; playerid < GetMaxPlayers(); playerid++) HiddenWelcome(playerid);
print("VIP System UnLoaded.");
return 1;
}
public OnPlayerConnect(playerid)
{
LoadPlayerVIP(playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
HiddenWelcome(playerid);
Player[playerid][VIP] = false;
return 1;
}
public OnPlayerSpawn(playerid)
{
if ( IsPlayerVIP(playerid))
{
#if FULL_LIFE == 1
{
SetPlayerHealth(playerid, 100.0);
SetPlayerArmour(playerid, 100.0);
}
#endif
#if DEATH_RESPAWN_LOCAL == 1
{
SetPlayerInterior(playerid, Interior[playerid]);
SetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
}
#endif
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
#if DEATH_RESPAWN_LOCAL == 1
{
if ( IsPlayerVIP(playerid))
{
GetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
Interior[playerid] = GetPlayerInterior(playerid);
}
}
#endif
return 1;
}
public OnPlayerText(playerid, text[])
{
if ( IsPlayerVIP(playerid))
{
new Name[24];
GetPlayerName(playerid, Name, 24);
#if CHAT_MODEL == 1
{
new dStr[128];
format ( dStr, 128, "[%d]%s[V.I.P]: {FFFFFF}%s", playerid, Name, text);
SendClientMessageToAll(GetPlayerColor(playerid), dStr);
return 0;
}
#endif
#if CHAT_MODEL == 2
{
new dStr[128];
format ( dStr, 128, "%s[%d][V.I.P]: {FFFFFF}%s", Name, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), dStr);
return 0;
}
#endif
#if CHAT_MODEL == 3
{
new dStr[128];
format ( dStr, 128, "{F9BD0B}VIP {FFFFFF}%s diz: {FFFFFF}%s", Name, text);
SendClientMessageToAll(GetPlayerColor(playerid), dStr);
return 0;
}
#endif
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if ( dialogid == DIALOG_ATIV_KEY && response)
{
UseVipKey(playerid, inputtext);
return 1;
}
if ( dialogid == DIALOG_MAKE_KEY && response )
{
format ( cKey[playerid], 128, inputtext);
new Str[128];
format ( Str, sizeof Str, "{FFFFFF}Seu novo codigo VIP: {DE3A3A}%s\n\n{FFFFFF}Agora nos informe a quantidade de dias do VIP:", cKey[playerid]);
ShowPlayerDialog(playerid, DIALOG_MAKE_DAYS, DIALOG_STYLE_INPUT, "Criaзгo de Nova Key", Str, "Criar", "Cancelar");
return true;
}
if ( dialogid == DIALOG_MAKE_DAYS && response )
{
if ( !IsNumeric(inputtext)) return SendClientMessage(playerid, Default, "Dias sгo compostos de nъmeros.");
cDays[playerid] = strval(inputtext);
new Str[500];
format ( Str, sizeof Str, "{FFFFFF}Informaзхes de sua nova key:\n\nCуdigo: {DE3A3A}%s\n{FFFFFF}Vencimento: {DE3A3A}%d dias\n\n{FFFFFF}Deseja criar ?", cKey[playerid], cDays[playerid]);
ShowPlayerDialog(playerid, DIALOG_CONFIRM, DIALOG_STYLE_MSGBOX, "{FFFFFF}Criaзгo de Nova Key",Str, "Sim", "Nгo");
return 1;
}
if ( dialogid == DIALOG_CONFIRM && response)
{
CreateVipKey(playerid, cKey[playerid], cDays[playerid]);
return 1;
}
return 1;
}
CMD:ativarvip(playerid)
{
ShowPlayerDialog(playerid, DIALOG_ATIV_KEY, DIALOG_STYLE_INPUT, "{FFFFFF}Ativar VIP", "{FFFFFF}Bem vindo.\nNos informe sua key para ativar seu beneficio VIP:", "Ativar", "Sair");
return 1;
}
CMD:novakey(playerid, params[])
{
if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Default, "Vocк nгo tem perissгo para isso.");
ShowPlayerDialog(playerid, DIALOG_MAKE_KEY, DIALOG_STYLE_INPUT, "{FFFFFF}Criaзгo de Nova Key", "{FFFFFF}Nos informe um novo cуdigo VIP:", "Criar", "Cancelar");
return 1;
}
CMD:viphelp(playerid)
{
if ( !IsPlayerVIP(playerid)) return SendClientMessage(playerid, Default, "[Erro]{FFFFFF} Vocк nгo й vip.");
new Str[1028]; format ( Str, sizeof Str, "{FFFFFF}Confira aqui comandos e status do seu VIP.\n\nSeu VIP expira em: %d dias.\n\nContate um administrador para renovar seu plano.", GetExpirationDays(playerid));
ShowPlayerDialog(playerid, 775+1, DIALOG_STYLE_MSGBOX, "{FFFFFF}Informaзхes do VIP", Str, "Sair", "");
return 1;
}
CMD:delkey(playerid, params[])
{
if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Default, "Vocк nгo tem perissгo para isso.");
new Key[128];
if ( sscanf ( params, "s", Key)) return SendClientMessage(playerid, Default, "[Erro]{FFFFFF} Nos informe o nome da key.");
RemoveKey(playerid, Key);
return 1;
}
CMD:setvip(playerid, params[])
{
if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Vocк nгo tem permissгo para isso.");
new Nome, Dias;
if ( sscanf ( params, "id", Nome, Dias)) return SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Use: /setvip [ID/NAME] [DIAS]");
SetVipForPlayer(Nome, Dias);
return 1;
}
CMD:vips(playerid)
{
new Name[24], Str[128];
SendClientMessage(playerid, Default, "VIP's Online:");
for ( new i = 0; i < GetMaxPlayers(); i++)
{
if ( IsPlayerConnected(i) && IsPlayerVIP(i))
{
GetPlayerName(i, Name, 24);
format ( Str, sizeof Str, "[V.I.P]{FFFFFF} %s ID: %d", Name, i);
SendClientMessage(i, Default, Str);
}
}
return 1;
}
ENGINE::IsPlayerVIP(playerid)
{
if ( Player[playerid][VIP] == false ) return 0;
return 1;
}
ENGINE::LoadPlayerVIP(playerid)
{
new Name[24], dStr[128];
GetPlayerName(playerid, Name, sizeof Name);
format ( dStr, sizeof dStr, VIP_USERS, Name);
if ( !DOF2::FileExists(dStr)) return true;
Player[playerid][VIP] = true;
Player[playerid][dExpiration] = DOF2::GetInt(dStr, "Day_Expiration");
Player[playerid][hExpiration] = DOF2::GetInt(dStr, "Hour_Expiration");
ShowWelcomeMessage(playerid);
return true;
}
ENGINE::SavePlayerVIP(playerid)
{
if ( IsPlayerVIP(playerid))
{
new Name[24], Str[128];
GetPlayerName(playerid, Name, 24);
format ( Str, sizeof Str, VIP_USERS, Name);
if ( !DOF2::FileExists(Str)) DOF2::CreateFile(Str);
if ( !DOF2::FileExists(Str)) return printf ( "O arquivo de VIP %s nгo pode ser criado ( PASTA INEXISTENTE )", Name);
DOF2::SetInt(Str, "Day_Expiration", Player[playerid][dExpiration]);
DOF2::SetInt(Str, "Hour_Expiration", Player[playerid][hExpiration]);
DOF2::SaveFile();
}
return 1;
}
ENGINE::CreateVipKey(playerid, Key[], Days)
{
new Str[128];
format ( Str, sizeof Str, VIP_KEYS, Key);
if ( DOF2::FileExists(Str))
{
new Dayss = DOF2::GetInt(Str, "VIP_Days");
format ( Str, sizeof Str, "[Erro]{FFFFFF} [ %s ] - [ %d dias ]",Key, Dayss);
SendClientMessage(playerid, Default, "[Erro] {FFFFFF}Um codigo semelhante ja estб criado.");
SendClientMessage(playerid, Default, Str);
return 1;
}
if ( Days <= 0) return SendClientMessage(playerid, Default, "[Erro]{FFFFFF} Impossнvel realizar esta operaзгo.");
DOF2::CreateFile(Str);
DOF2::SetInt(Str, "VIP_Days", Days);
DOF2::SaveFile();
format ( Str, sizeof Str, "[VIP]{FFFFFF} [ %s ] - [ %d dias ]", Key, Days);
SendClientMessage(playerid, Default, "[VIP]{FFFFFF} Um novo cуdigo VIP foi criado.");
SendClientMessage(playerid, Default, "[VIP]{FFFFFF} Use /ativarvip para usa-lo");
SendClientMessage(playerid, Default, Str);
return 1;
}
ENGINE::UseVipKey(playerid, Key[])
{
new Str[128];
format ( Str, sizeof Str, VIP_KEYS, Key);
if ( !DOF2::FileExists(Str))
{
SendClientMessage(playerid, Default, "************************************************");
SendClientMessage(playerid, Default, " O codigo fornecido jб foi usado ou nгo existe.");
SendClientMessage(playerid, Default, " Nгo tem um cуdigo VIP ? Contate um adminstrador.");
SendClientMessage(playerid, Default, "************************************************");
return 1;
}
new Days = DOF2::GetInt(Str, "VIP_Days");
SetVipForPlayer(playerid, Days);
DOF2::RemoveFile(Str);
new Name[24]; GetPlayerName(playerid, Name, 24);
printf ("O jogador %s ativou o codigo %s com %d dias", Name, Key, Days);
return 1;
}
ENGINE::RemoveKey(playerid, Key[])
{
new Str[128];
format ( Str, sizeof Str, VIP_KEYS, Key);
if ( !DOF2::FileExists(Str)) return SendClientMessage(playerid, Default, "Key Inexistente");
DOF2::RemoveFile(Str);
format (Str, sizeof Str, "[VIP KEY]{FFFFFF} O codigo %s foi removido.", Key);
SendClientMessage(playerid, Default, Str);
return 1;
}
ENGINE::GetExpirationDays(playerid)
{
new Days = 0;
if ( IsPlayerVIP(playerid))
{
Days = Player[playerid][dExpiration] - getdate();
}
return Days;
}
ENGINE::SetVipForPlayer(playerid, Days)
{
if ( !IsPlayerConnected(playerid)) return 1;
if ( Days == 0 )
{
new Nome[24], Str[128];
GetPlayerName(playerid, Nome, 24);
format ( Str, sizeof Str, VIP_USERS, Nome);
DOF2::RemoveFile(Str);
Player[playerid][VIP] = false;
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Informamos que seu VIP expirou.");
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Contate um administrador o mais rapido possнvel para renova-lo.");
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Obrigado por colaborar com nosso servidor.");
return 1;
}
new Str[128];
if ( Player[playerid][VIP] == true )
{
format ( Str, sizeof Str, "[Vip] {FFFFFF}Seu VIP foi renovado. ( %d dias )", Days);
Player[playerid][dExpiration] += Days;
Player[playerid][hExpiration] = gettime();
}
else
{
format ( Str, sizeof Str, "[Vip] {FFFFFF}Seu VIP foi ativado. ( %d dias )", Days);
Player[playerid][dExpiration] = getdate() + Days;
Player[playerid][hExpiration] = gettime();
}
Player[playerid][VIP] = true;
SavePlayerVIP(playerid);
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Obrigado por adquirir nosso plano VIP.");
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Use: /viphelp para mais informaзхes.");
SendClientMessage(playerid, Default, Str);
return 1;
}
ENGINE::ShowWelcomeMessage(playerid)
{
if ( IsPlayerVIP(playerid))
{
if ( VisibleWelcome[playerid] == false )
{
DrawWelcome[playerid][0] =TextDrawCreate(579.000000, 301.000000, "_");
TextDrawBackgroundColor (DrawWelcome[playerid][0], 255);
TextDrawFont (DrawWelcome[playerid][0], 1);
TextDrawLetterSize (DrawWelcome[playerid][0], 0.500000, 7.199999);
TextDrawColor (DrawWelcome[playerid][0], -1);
TextDrawSetOutline (DrawWelcome[playerid][0], 0);
TextDrawSetProportional (DrawWelcome[playerid][0], 1);
TextDrawSetShadow (DrawWelcome[playerid][0], 1);
TextDrawUseBox (DrawWelcome[playerid][0], 1);
TextDrawBoxColor (DrawWelcome[playerid][0], -1010580690);
TextDrawTextSize (DrawWelcome[playerid][0], 433.000000, 0.000000);
DrawWelcome[playerid][1] =TextDrawCreate(579.000000, 301.000000, "_");
TextDrawBackgroundColor (DrawWelcome[playerid][1], 255);
TextDrawFont (DrawWelcome[playerid][1], 1);
TextDrawLetterSize (DrawWelcome[playerid][1], 0.500000, 0.899999);
TextDrawColor (DrawWelcome[playerid][1], -1);
TextDrawSetOutline (DrawWelcome[playerid][1], 0);
TextDrawSetProportional (DrawWelcome[playerid][1], 1);
TextDrawSetShadow (DrawWelcome[playerid][1], 1);
TextDrawUseBox (DrawWelcome[playerid][1], 1);
TextDrawBoxColor (DrawWelcome[playerid][1], -1010580685);
TextDrawTextSize (DrawWelcome[playerid][1], 433.000000, 0.000000);
DrawWelcome[playerid][2] =TextDrawCreate(437.000000, 301.000000, "Bem Vindo Novamente");
TextDrawBackgroundColor (DrawWelcome[playerid][2], -1010580736);
TextDrawFont (DrawWelcome[playerid][2], 2);
TextDrawLetterSize (DrawWelcome[playerid][2], 0.159999, 0.899999);
TextDrawColor (DrawWelcome[playerid][2], -1);
TextDrawSetOutline (DrawWelcome[playerid][2], 0);
TextDrawSetProportional (DrawWelcome[playerid][2], 1);
TextDrawSetShadow (DrawWelcome[playerid][2], 1);
DrawWelcome[playerid][3] =TextDrawCreate(437.000000, 318.000000, "Seu VIP ainda esta ativo.");
TextDrawBackgroundColor (DrawWelcome[playerid][3], -1010580736);
TextDrawFont (DrawWelcome[playerid][3], 2);
TextDrawLetterSize (DrawWelcome[playerid][3], 0.149999, 0.799999);
TextDrawColor (DrawWelcome[playerid][3], -1);
TextDrawSetOutline (DrawWelcome[playerid][3], 0);
TextDrawSetProportional (DrawWelcome[playerid][3], 1);
TextDrawSetShadow (DrawWelcome[playerid][3], 1);
DrawWelcome[playerid][4] =TextDrawCreate(437.000000, 329.000000, "Use: /viphelp para mais info.");
TextDrawBackgroundColor (DrawWelcome[playerid][4], -1010580736);
TextDrawFont (DrawWelcome[playerid][4], 2);
TextDrawLetterSize (DrawWelcome[playerid][4], 0.149999, 0.799999);
TextDrawColor (DrawWelcome[playerid][4], -1);
TextDrawSetOutline (DrawWelcome[playerid][4], 0);
TextDrawSetProportional (DrawWelcome[playerid][4], 1);
TextDrawSetShadow (DrawWelcome[playerid][4], 1);
DrawWelcome[playerid][5] =TextDrawCreate(437.000000, 356.000000, "Seu vip expira em: ... dias");
TextDrawBackgroundColor (DrawWelcome[playerid][5], -1010580736);
TextDrawFont (DrawWelcome[playerid][5], 2);
TextDrawLetterSize (DrawWelcome[playerid][5], 0.149999, 0.799999);
TextDrawColor (DrawWelcome[playerid][5], -1);
TextDrawSetOutline (DrawWelcome[playerid][5], 0);
TextDrawSetProportional (DrawWelcome[playerid][5], 1);
TextDrawSetShadow (DrawWelcome[playerid][5], 1);
new Str[128];
format ( Str, sizeof Str, "Seu VIP expira em: %d dias.", GetExpirationDays(playerid));
TextDrawSetString(DrawWelcome[playerid][5], Str);
for ( new t = 0; t < 6; t++) TextDrawShowForPlayer(playerid, DrawWelcome[playerid][t]);
VisibleWelcome[playerid] = true;
TimerDraw[playerid] = SetTimerEx("HiddenWelcome", 6000, false, "i", playerid);
if ( GetExpirationDays(playerid) < 5)
{
format ( Str, sizeof Str, "[Vip] {FFFFFF}Seu VIP expira em %d dias.", GetExpirationDays(playerid));
SendClientMessage(playerid, Default, Str);
}
}
}
}
Public::HiddenWelcome(playerid)
{
if ( VisibleWelcome[playerid] == true )
{
for ( new t = 0; t < 6; t++) TextDrawDestroy(DrawWelcome[playerid][t]);
TimerDraw[playerid] = 0;
VisibleWelcome[playerid] = false;
}
}
ENGINE::IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
PHP код:
/*
#######################################################################################
### ###
### Sistema VIP ###
### ###
### Todos os scripts feitos aqui sгo te total autoria do criador. ###
### Este script estб livre para ediзгo e implementaзгo em gamemodes. ###
### ###
### Mantenha os devidos creditos no script. ###
### ###
### Criador, desenvolvedor e tester: Dry. ###
### ###
#######################################################################################
Funзхes:
- IsPlayerVIP(playerid) - Chechar se um jogador й VIP.
- LoadPlayerVIP(playerid) - Carregar dados de VIP de um jogador a partir do arquivo.
- SavePlayerVIP(playerid) - Salvar dados de VIP dentro do arquivo.
- CreateVipKey(playerid, Key[], Days) - Criar uma nova Key.
- UseVipKey(playerid, Key[]) - Usar determinada key.
- RemoveKey(playerid, Key[]) - Deletar uma key existente e nгo usada.
- GetExpirationDays(playerid) - Getar quantos dias faltam para expirar o VIP.
- SetVipForPlayer(playerid, Days) - Setar ou renovar o VIP de algum jogador.
- ShowWelcomeMessage(playerid) - Abre uma mensagem de boas vindas, contendo algumas info.
Comandos:
- CMD:setvip [ID] [DIAS] ( Admin ) // Setamos um jogador como VIP
- CMD:viphelp ( VIP ) // Algumas informaзхes sobre o seu VIP.
- CMD:ativarvip ( Default )// Um dialog serб aberto solicitando o cуdigo.
- CMD:novakey ( Admin ) // Uma nova key serб criada na pasta "Keys" para livre uso.
- CMD:delkey [KEY] ( Admin ) // Deletar uma key existente
- CMD:vips ( Default ) // Checar jogadores VIP online.
Configuraзхes:
#define CHAT_MODEL 3 - Modelo ao falar no chat. Preview In-Forъm
#define FULL_LIFE 1 - Spawnar com COLETE E VIDA FULL
#define DEATH_RESPAWN_LOCAL 1 - Spawnar no local onde morreu
Instalaзгo:
- Crie uma pasta chamada "Vips" localizada em scriptfiles.
- Dentro da mesma crie as seguintas pastas:
* Users
* Keys
- O precesso de criaзгo de VIP's e keys й automatico, siga os passos e comandos dentro do game.
-Atenciosamente Dry ( Lucas ).
*/
#include <a_samp>
#include <dof2>
#include <zcmd>
#include YSI\y_hooks
#define ENGINE::%0(%1) stock %0(%1)
#define Public::%0(%1) forward %0(%1); public %0(%1)
#define DIALOG_ATIV_KEY 779
#define DIALOG_MAKE_KEY 779+1
#define DIALOG_MAKE_DAYS 779+2
#define DIALOG_CONFIRM 779+3
//Folder's
#define VIP_USERS "Vips/Users/%s.ini"
#define VIP_KEYS "Vips/Keys/%s.ini"
//Colors
#define Default 0xDE3A3AFF
#define Branco 0xFFFFFFFF
//Config
#define CHAT_MODEL 3
#define FULL_LIFE 1
#define DEATH_RESPAWN_LOCAL 1
#if DEATH_RESPAWN_LOCAL == 1// Usado para armazenar Locais de onde morreu
new Float: X[MAX_PLAYERS], Float: Y[MAX_PLAYERS], Float: Z[MAX_PLAYERS], Interior[MAX_PLAYERS];
#endif
//Player Definitions
enum PlayerParams
{
bool:VIP,
dExpiration,
hExpiration
};
new Player[MAX_PLAYERS][PlayerParams];
new bool:VisibleWelcome[MAX_PLAYERS];
new Text:DrawWelcome[MAX_PLAYERS][6];
new TimerDraw[MAX_PLAYERS];
new cKey[MAX_PLAYERS][128], cDays[MAX_PLAYERS];
hook OnGameModeInit()
{
for ( new playerid = 0; playerid < GetMaxPlayers(); playerid++)
{
if ( IsPlayerConnected(playerid))
{
LoadPlayerVIP(playerid);
}
}
SetTimer("CheckVipsInGame", 60000, true);
print("VIP System Loaded");
return 1;
}
Public::CheckVipsInGame()
{
for ( new playerid = 0; playerid < GetMaxPlayers(); playerid++)
{
if ( IsPlayerConnected(playerid) && IsPlayerVIP(playerid))
{
if ( GetExpirationDays(playerid) <= 0)
{
SetVipForPlayer(playerid, 0);
}
}
}
}
hook OnGameModeExit()
{
for ( new playerid = 0; playerid < GetMaxPlayers(); playerid++) HiddenWelcome(playerid);
print("VIP System UnLoaded.");
return 1;
}
hook OnPlayerConnect(playerid)
{
LoadPlayerVIP(playerid);
return 1;
}
hook OnPlayerDisconnect(playerid, reason)
{
HiddenWelcome(playerid);
Player[playerid][VIP] = false;
return 1;
}
hook OnPlayerSpawn(playerid)
{
if ( IsPlayerVIP(playerid))
{
#if FULL_LIFE == 1
{
SetPlayerHealth(playerid, 100.0);
SetPlayerArmour(playerid, 100.0);
}
#endif
#if DEATH_RESPAWN_LOCAL == 1
{
SetPlayerInterior(playerid, Interior[playerid]);
SetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
}
#endif
}
return 1;
}
hook OnPlayerDeath(playerid, killerid, reason)
{
#if DEATH_RESPAWN_LOCAL == 1
{
if ( IsPlayerVIP(playerid))
{
GetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
Interior[playerid] = GetPlayerInterior(playerid);
}
}
#endif
return 1;
}
hook OnPlayerText(playerid, text[])
{
if ( IsPlayerVIP(playerid))
{
new Name[24];
GetPlayerName(playerid, Name, 24);
#if CHAT_MODEL == 1
{
new dStr[128];
format ( dStr, 128, "[%d]%s[V.I.P]: {FFFFFF}%s", playerid, Name, text);
SendClientMessageToAll(GetPlayerColor(playerid), dStr);
return 0;
}
#endif
#if CHAT_MODEL == 2
{
new dStr[128];
format ( dStr, 128, "%s[%d][V.I.P]: {FFFFFF}%s", Name, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), dStr);
return 0;
}
#endif
#if CHAT_MODEL == 3
{
new dStr[128];
format ( dStr, 128, "{F9BD0B}VIP {FFFFFF}%s diz: {FFFFFF}%s", Name, text);
SendClientMessageToAll(GetPlayerColor(playerid), dStr);
return 0;
}
#endif
}
return 1;
}
hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if ( dialogid == DIALOG_ATIV_KEY && response)
{
UseVipKey(playerid, inputtext);
return 1;
}
if ( dialogid == DIALOG_MAKE_KEY && response )
{
format ( cKey[playerid], 128, inputtext);
new Str[128];
format ( Str, sizeof Str, "{FFFFFF}Seu novo codigo VIP: {DE3A3A}%s\n\n{FFFFFF}Agora nos informe a quantidade de dias do VIP:", cKey[playerid]);
ShowPlayerDialog(playerid, DIALOG_MAKE_DAYS, DIALOG_STYLE_INPUT, "Criaзгo de Nova Key", Str, "Criar", "Cancelar");
return true;
}
if ( dialogid == DIALOG_MAKE_DAYS && response )
{
if ( !IsNumeric(inputtext)) return SendClientMessage(playerid, Default, "Dias sгo compostos de nъmeros.");
cDays[playerid] = strval(inputtext);
new Str[500];
format ( Str, sizeof Str, "{FFFFFF}Informaзхes de sua nova key:\n\nCуdigo: {DE3A3A}%s\n{FFFFFF}Vencimento: {DE3A3A}%d dias\n\n{FFFFFF}Deseja criar ?", cKey[playerid], cDays[playerid]);
ShowPlayerDialog(playerid, DIALOG_CONFIRM, DIALOG_STYLE_MSGBOX, "{FFFFFF}Criaзгo de Nova Key",Str, "Sim", "Nгo");
return 1;
}
if ( dialogid == DIALOG_CONFIRM && response)
{
CreateVipKey(playerid, cKey[playerid], cDays[playerid]);
return 1;
}
return 1;
}
CMD:ativarvip(playerid)
{
ShowPlayerDialog(playerid, DIALOG_ATIV_KEY, DIALOG_STYLE_INPUT, "{FFFFFF}Ativar VIP", "{FFFFFF}Bem vindo.\nNos informe sua key para ativar seu beneficio VIP:", "Ativar", "Sair");
return 1;
}
CMD:novakey(playerid, params[])
{
if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Default, "Vocк nгo tem perissгo para isso.");
ShowPlayerDialog(playerid, DIALOG_MAKE_KEY, DIALOG_STYLE_INPUT, "{FFFFFF}Criaзгo de Nova Key", "{FFFFFF}Nos informe um novo cуdigo VIP:", "Criar", "Cancelar");
return 1;
}
CMD:viphelp(playerid)
{
if ( !IsPlayerVIP(playerid)) return SendClientMessage(playerid, Default, "[Erro]{FFFFFF} Vocк nгo й vip.");
new Str[1028]; format ( Str, sizeof Str, "{FFFFFF}Confira aqui comandos e status do seu VIP.\n\nSeu VIP expira em: %d dias.\n\nContate um administrador para renovar seu plano.", GetExpirationDays(playerid));
ShowPlayerDialog(playerid, 775+1, DIALOG_STYLE_MSGBOX, "{FFFFFF}Informaзхes do VIP", Str, "Sair", "");
return 1;
}
CMD:delkey(playerid, params[])
{
if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Default, "Vocк nгo tem perissгo para isso.");
new Key[128];
if ( sscanf ( params, "s", Key)) return SendClientMessage(playerid, Default, "[Erro]{FFFFFF} Nos informe o nome da key.");
RemoveKey(playerid, Key);
return 1;
}
CMD:setvip(playerid, params[])
{
if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Vocк nгo tem permissгo para isso.");
new Nome, Dias;
if ( sscanf ( params, "id", Nome, Dias)) return SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Use: /setvip [ID/NAME] [DIAS]");
SetVipForPlayer(Nome, Dias);
return 1;
}
CMD:vips(playerid)
{
new Name[24], Str[128];
SendClientMessage(playerid, Default, "VIP's Online:");
for ( new i = 0; i < GetMaxPlayers(); i++)
{
if ( IsPlayerConnected(i) && IsPlayerVIP(i))
{
GetPlayerName(i, Name, 24);
format ( Str, sizeof Str, "[V.I.P]{FFFFFF} %s ID: %d", Name, i);
SendClientMessage(i, Default, Str);
}
}
return 1;
}
ENGINE::IsPlayerVIP(playerid)
{
if ( Player[playerid][VIP] == false ) return 0;
return 1;
}
ENGINE::LoadPlayerVIP(playerid)
{
new Name[24], dStr[128];
GetPlayerName(playerid, Name, sizeof Name);
format ( dStr, sizeof dStr, VIP_USERS, Name);
if ( !DOF2::FileExists(dStr)) return true;
Player[playerid][VIP] = true;
Player[playerid][dExpiration] = DOF2::GetInt(dStr, "Day_Expiration");
Player[playerid][hExpiration] = DOF2::GetInt(dStr, "Hour_Expiration");
ShowWelcomeMessage(playerid);
return true;
}
ENGINE::SavePlayerVIP(playerid)
{
if ( IsPlayerVIP(playerid))
{
new Name[24], Str[128];
GetPlayerName(playerid, Name, 24);
format ( Str, sizeof Str, VIP_USERS, Name);
if ( !DOF2::FileExists(Str)) DOF2::CreateFile(Str);
if ( !DOF2::FileExists(Str)) return printf ( "O arquivo de VIP %s nгo pode ser criado ( PASTA INEXISTENTE )", Name);
DOF2::SetInt(Str, "Day_Expiration", Player[playerid][dExpiration]);
DOF2::SetInt(Str, "Hour_Expiration", Player[playerid][hExpiration]);
DOF2::SaveFile();
}
return 1;
}
ENGINE::CreateVipKey(playerid, Key[], Days)
{
new Str[128];
format ( Str, sizeof Str, VIP_KEYS, Key);
if ( DOF2::FileExists(Str))
{
new Dayss = DOF2::GetInt(Str, "VIP_Days");
format ( Str, sizeof Str, "[Erro]{FFFFFF} [ %s ] - [ %d dias ]",Key, Dayss);
SendClientMessage(playerid, Default, "[Erro] {FFFFFF}Um codigo semelhante ja estб criado.");
SendClientMessage(playerid, Default, Str);
return 1;
}
if ( Days <= 0) return SendClientMessage(playerid, Default, "[Erro]{FFFFFF} Impossнvel realizar esta operaзгo.");
DOF2::CreateFile(Str);
DOF2::SetInt(Str, "VIP_Days", Days);
DOF2::SaveFile();
format ( Str, sizeof Str, "[VIP]{FFFFFF} [ %s ] - [ %d dias ]", Key, Days);
SendClientMessage(playerid, Default, "[VIP]{FFFFFF} Um novo cуdigo VIP foi criado.");
SendClientMessage(playerid, Default, "[VIP]{FFFFFF} Use /ativarvip para usa-lo");
SendClientMessage(playerid, Default, Str);
return 1;
}
ENGINE::UseVipKey(playerid, Key[])
{
new Str[128];
format ( Str, sizeof Str, VIP_KEYS, Key);
if ( !DOF2::FileExists(Str))
{
SendClientMessage(playerid, Default, "************************************************");
SendClientMessage(playerid, Default, " O codigo fornecido jб foi usado ou nгo existe.");
SendClientMessage(playerid, Default, " Nгo tem um cуdigo VIP ? Contate um adminstrador.");
SendClientMessage(playerid, Default, "************************************************");
return 1;
}
new Days = DOF2::GetInt(Str, "VIP_Days");
SetVipForPlayer(playerid, Days);
DOF2::RemoveFile(Str);
new Name[24]; GetPlayerName(playerid, Name, 24);
printf ("O jogador %s ativou o codigo %s com %d dias", Name, Key, Days);
return 1;
}
ENGINE::RemoveKey(playerid, Key[])
{
new Str[128];
format ( Str, sizeof Str, VIP_KEYS, Key);
if ( !DOF2::FileExists(Str)) return SendClientMessage(playerid, Default, "Key Inexistente");
DOF2::RemoveFile(Str);
format (Str, sizeof Str, "[VIP KEY]{FFFFFF} O codigo %s foi removido.", Key);
SendClientMessage(playerid, Default, Str);
return 1;
}
ENGINE::GetExpirationDays(playerid)
{
new Days = 0;
if ( IsPlayerVIP(playerid))
{
Days = Player[playerid][dExpiration] - getdate();
}
return Days;
}
ENGINE::SetVipForPlayer(playerid, Days)
{
if ( !IsPlayerConnected(playerid)) return 1;
if ( Days == 0 )
{
new Nome[24], Str[128];
GetPlayerName(playerid, Nome, 24);
format ( Str, sizeof Str, VIP_USERS, Nome);
DOF2::RemoveFile(Str);
Player[playerid][VIP] = false;
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Informamos que seu VIP expirou.");
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Contate um administrador o mais rapido possнvel para renova-lo.");
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Obrigado por colaborar com nosso servidor.");
return 1;
}
new Str[128];
if ( Player[playerid][VIP] == true )
{
format ( Str, sizeof Str, "[Vip] {FFFFFF}Seu VIP foi renovado. ( %d dias )", Days);
Player[playerid][dExpiration] += Days;
Player[playerid][hExpiration] = gettime();
}
else
{
format ( Str, sizeof Str, "[Vip] {FFFFFF}Seu VIP foi ativado. ( %d dias )", Days);
Player[playerid][dExpiration] = getdate() + Days;
Player[playerid][hExpiration] = gettime();
}
Player[playerid][VIP] = true;
SavePlayerVIP(playerid);
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Obrigado por adquirir nosso plano VIP.");
SendClientMessage(playerid, Default, "[Vip] {FFFFFF}Use: /viphelp para mais informaзхes.");
SendClientMessage(playerid, Default, Str);
return 1;
}
ENGINE::ShowWelcomeMessage(playerid)
{
if ( IsPlayerVIP(playerid))
{
if ( VisibleWelcome[playerid] == false )
{
DrawWelcome[playerid][0] =TextDrawCreate(579.000000, 301.000000, "_");
TextDrawBackgroundColor (DrawWelcome[playerid][0], 255);
TextDrawFont (DrawWelcome[playerid][0], 1);
TextDrawLetterSize (DrawWelcome[playerid][0], 0.500000, 7.199999);
TextDrawColor (DrawWelcome[playerid][0], -1);
TextDrawSetOutline (DrawWelcome[playerid][0], 0);
TextDrawSetProportional (DrawWelcome[playerid][0], 1);
TextDrawSetShadow (DrawWelcome[playerid][0], 1);
TextDrawUseBox (DrawWelcome[playerid][0], 1);
TextDrawBoxColor (DrawWelcome[playerid][0], -1010580690);
TextDrawTextSize (DrawWelcome[playerid][0], 433.000000, 0.000000);
DrawWelcome[playerid][1] =TextDrawCreate(579.000000, 301.000000, "_");
TextDrawBackgroundColor (DrawWelcome[playerid][1], 255);
TextDrawFont (DrawWelcome[playerid][1], 1);
TextDrawLetterSize (DrawWelcome[playerid][1], 0.500000, 0.899999);
TextDrawColor (DrawWelcome[playerid][1], -1);
TextDrawSetOutline (DrawWelcome[playerid][1], 0);
TextDrawSetProportional (DrawWelcome[playerid][1], 1);
TextDrawSetShadow (DrawWelcome[playerid][1], 1);
TextDrawUseBox (DrawWelcome[playerid][1], 1);
TextDrawBoxColor (DrawWelcome[playerid][1], -1010580685);
TextDrawTextSize (DrawWelcome[playerid][1], 433.000000, 0.000000);
DrawWelcome[playerid][2] =TextDrawCreate(437.000000, 301.000000, "Bem Vindo Novamente");
TextDrawBackgroundColor (DrawWelcome[playerid][2], -1010580736);
TextDrawFont (DrawWelcome[playerid][2], 2);
TextDrawLetterSize (DrawWelcome[playerid][2], 0.159999, 0.899999);
TextDrawColor (DrawWelcome[playerid][2], -1);
TextDrawSetOutline (DrawWelcome[playerid][2], 0);
TextDrawSetProportional (DrawWelcome[playerid][2], 1);
TextDrawSetShadow (DrawWelcome[playerid][2], 1);
DrawWelcome[playerid][3] =TextDrawCreate(437.000000, 318.000000, "Seu VIP ainda esta ativo.");
TextDrawBackgroundColor (DrawWelcome[playerid][3], -1010580736);
TextDrawFont (DrawWelcome[playerid][3], 2);
TextDrawLetterSize (DrawWelcome[playerid][3], 0.149999, 0.799999);
TextDrawColor (DrawWelcome[playerid][3], -1);
TextDrawSetOutline (DrawWelcome[playerid][3], 0);
TextDrawSetProportional (DrawWelcome[playerid][3], 1);
TextDrawSetShadow (DrawWelcome[playerid][3], 1);
DrawWelcome[playerid][4] =TextDrawCreate(437.000000, 329.000000, "Use: /viphelp para mais info.");
TextDrawBackgroundColor (DrawWelcome[playerid][4], -1010580736);
TextDrawFont (DrawWelcome[playerid][4], 2);
TextDrawLetterSize (DrawWelcome[playerid][4], 0.149999, 0.799999);
TextDrawColor (DrawWelcome[playerid][4], -1);
TextDrawSetOutline (DrawWelcome[playerid][4], 0);
TextDrawSetProportional (DrawWelcome[playerid][4], 1);
TextDrawSetShadow (DrawWelcome[playerid][4], 1);
DrawWelcome[playerid][5] =TextDrawCreate(437.000000, 356.000000, "Seu vip expira em: ... dias");
TextDrawBackgroundColor (DrawWelcome[playerid][5], -1010580736);
TextDrawFont (DrawWelcome[playerid][5], 2);
TextDrawLetterSize (DrawWelcome[playerid][5], 0.149999, 0.799999);
TextDrawColor (DrawWelcome[playerid][5], -1);
TextDrawSetOutline (DrawWelcome[playerid][5], 0);
TextDrawSetProportional (DrawWelcome[playerid][5], 1);
TextDrawSetShadow (DrawWelcome[playerid][5], 1);
new Str[128];
format ( Str, sizeof Str, "Seu VIP expira em: %d dias.", GetExpirationDays(playerid));
TextDrawSetString(DrawWelcome[playerid][5], Str);
for ( new t = 0; t < 6; t++) TextDrawShowForPlayer(playerid, DrawWelcome[playerid][t]);
VisibleWelcome[playerid] = true;
TimerDraw[playerid] = SetTimerEx("HiddenWelcome", 6000, false, "i", playerid);
if ( GetExpirationDays(playerid) < 5)
{
format ( Str, sizeof Str, "[Vip] {FFFFFF}Seu VIP expira em %d dias.", GetExpirationDays(playerid));
SendClientMessage(playerid, Default, Str);
}
}
}
}
Public::HiddenWelcome(playerid)
{
if ( VisibleWelcome[playerid] == true )
{
for ( new t = 0; t < 6; t++) TextDrawDestroy(DrawWelcome[playerid][t]);
TimerDraw[playerid] = 0;
VisibleWelcome[playerid] = false;
}
}
ENGINE::IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
PHP код:
D:\samp037_svr_R2-1-1_win32\pawno\include\YSI\..\YSI_Data\y_foreach/iterators.inc(679) : warning 219: local variable "X" shadows a variable at a preceding level
D:\samp037_svr_R2-1-1_win32\pawno\include\YSI\..\YSI_Data\y_foreach/iterators.inc(679) : warning 219: local variable "Y" shadows a variable at a preceding level
D:\samp037_svr_R2-1-1_win32\pawno\include\YSI\..\YSI_Data\y_foreach/iterators.inc(679) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/admin.inc(68) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/admin.inc(68) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/admin.inc(68) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/admin.inc(85) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/admin.inc(85) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/admin.inc(85) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/admin.inc(137) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/admin.inc(137) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/admin.inc(137) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/admin.inc(254) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/admin.inc(254) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/admin.inc(254) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/admin.inc(299) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/admin.inc(299) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/admin.inc(299) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/admin.inc(340) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/admin.inc(340) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/admin.inc(340) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/items.inc(813) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/items.inc(813) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/items.inc(813) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/items.inc(1305) : warning 219: local variable "X" shadows a variable at a preceding level
../modulos/items.inc(1305) : warning 219: local variable "Y" shadows a variable at a preceding level
../modulos/items.inc(1305) : warning 219: local variable "Z" shadows a variable at a preceding level
../modulos/vips.inc(105) : error 021: symbol already defined: "Player"
../modulos/vips.inc(155) : warning 213: tag mismatch
../modulos/vips.inc(315) : warning 213: tag mismatch
../modulos/vips.inc(325) : warning 213: tag mismatch
../modulos/vips.inc(326) : warning 213: tag mismatch
../modulos/vips.inc(327) : warning 213: tag mismatch
../modulos/vips.inc(341) : warning 213: tag mismatch
../modulos/vips.inc(342) : warning 213: tag mismatch
../modulos/vips.inc(407) : warning 213: tag mismatch
../modulos/vips.inc(421) : warning 213: tag mismatch
../modulos/vips.inc(428) : warning 213: tag mismatch
../modulos/vips.inc(431) : warning 213: tag mismatch
../modulos/vips.inc(432) : warning 213: tag mismatch
../modulos/vips.inc(437) : warning 213: tag mismatch
../modulos/vips.inc(438) : warning 213: tag mismatch
../modulos/vips.inc(440) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.