Sistema de Vip com dias para acabar
3 participantes
Página 1 de 1
Sistema de Vip com dias para acabar
Na pasta Game da sua source crie VIPDays.cs
e nessa coloque:
Em GameState ou GameClient (Depende da source), adicione:
Agora pesquise por
Sql para a Database:
e nessa coloque:
- Código:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xConquer.Database;
namespace xConquer.Game
{
public class VIPDays
{
/*
* All Rights Reserved © Ąbdṳallah Môhsen
*/
public DateTime VIPStartON, VIPEndAt;
public byte VIPLevelDays, OldVIPLevel;
public int VIPLogMessage;
public VIPDays()
{
foreach (Client.GameState client in Program.GamePool)
{
this.VIPLevelDays = 0;
this.OldVIPLevel = client.Entity.VIPLevel;
}
}
public static void READ(Client.GameState client)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("vipdays").Where("UID", client.Entity.UID))
using (var reader = new MySqlReader(cmd))
{
if (reader.Read())
{
client.VIPDays.VIPLevelDays = reader.ReadByte("VIPLevelDays");
client.VIPDays.OldVIPLevel = reader.ReadByte("OldVIPLevel");
client.VIPDays.VIPStartON = DateTime.FromBinary(reader.ReadInt64("VIPStartON"));
client.VIPDays.VIPEndAt = DateTime.FromBinary(reader.ReadInt64("VIPEndAt"));
}
else
{
using (var cmds = new MySqlCommand(MySqlCommandType.INSERT))
cmds.Insert("vipdays").Insert("Name", client.Entity.Name).Insert("UID", client.Entity.UID).Execute();
}
}
}
public static void SAVE(Client.GameState client)
{
xConquer.Database.MySqlCommand cmd = new xConquer.Database.MySqlCommand(xConquer.Database.MySqlCommandType.UPDATE);
cmd.Update("vipdays")
.Set("VIPLevelDays", client.VIPDays.VIPLevelDays)
.Set("OldVIPLevel", client.VIPDays.OldVIPLevel)
.Set("VIPStartON", client.VIPDays.VIPStartON)
.Set("VIPEndAt", client.VIPDays.VIPEndAt);
cmd.Where("UID", client.Entity.UID);
cmd.Execute();
}
}
}
Em GameState ou GameClient (Depende da source), adicione:
- Código:
public Game.VIPDays VIPDays = new Game.VIPDays();
- Código:
#region VIPDays Check
/*
* All Rights Reserved © Ąbdṳallah Môhsen
*/
if (client.VIPDays.VIPLevelDays > 0 && DateTime.Now >= client.VIPDays.VIPEndAt)
{
client.Entity.VIPLevel = client.VIPDays.OldVIPLevel;
client.VIPDays.VIPLevelDays = 0;
client.VIPDays.VIPStartON = Convert.ToDateTime(0);
client.VIPDays.VIPEndAt = Convert.ToDateTime(0);
VIPDays.SAVE(client);
client.Send("Your VIP is end, Try to get other item and unlock it.");
}
#endregion
- Código:
Npcs dialog = new Npcs(client);
- Código:
#region VIIPDays.
/*
* All Rights Reserved © Ąbdṳallah Môhsen
*/
if (client.ActiveNpc == 3004121)
{
if (client.Inventory.Contains(client.ActiveNpc, 1))
{
if (req.OptionID == 1)
{
if (client.Entity.VIPLevel > 3)
{
dialog.Text("You are VIPLevel " + client.Entity.VIPLevel + ", So you can't unlock this item.");
dialog.Option("Ohh, Sorry.", 255);
dialog.Send();
}
else
{
if (client.Entity.VIPLevel < 4)
{
dialog.Text("Are you sure you want to unlock this item.");
dialog.Option("Yes I'm sure.", 2);
dialog.Send();
}
}
}
if (req.OptionID == 2)
{
if (client.Entity.VIPLevel < 4)
{
client.VIPDays.OldVIPLevel = client.Entity.VIPLevel;//هنا بيحفظ الفي اي بي القديم بتاعك علشان بعد الاسبوع يرجعهولك تاني
client.VIPDays.VIPLevelDays = 4;//هنا بيديلك الفي اي بي الي موجود في الشنه والي انت هتتحدو
client.VIPDays.VIPStartON = DateTime.Now;//هنا بيسجل بدايه الاسبوع بتاعك من وقت فتح الشنطه
client.VIPDays.VIPEndAt = DateTime.Now.AddDays(7);//هنا بيحدد الوقت الي هيخلص فيه الفي اي بي ويرجعلك الفي اي بي القديم
client.Entity.VIPLevel = client.VIPDays.VIPLevelDays;//هنا بيديلك الفي اي بي
client.Inventory.Remove(client.ActiveNpc, 1);
client.Send("Congratulations " + client.Entity.Name + ", You have got VIPLevel " + client.VIPDays.VIPLevelDays + " to " + client.VIPDays.VIPEndAt + ".");
VIPDays.SAVE(client);
}
}
}
}
#endregion
Agora pesquise por
- Código:
tatic void UseItem
- Código:
#region VIP7Days
case 3004121:
{
Npcs dialog = new Npcs(client);
dialog.Text("Hello " + client.Entity.Name + ", There is VIPLevel 4 For 7 Days. If you want to get it just confirm.");
dialog.Option("Confirm.", 1);
dialog.Option("Cancel.", 255);
dialog.Avatar(318);
dialog.Send();
client.ActiveNpc = item.ID;
break;
}
#endregion
- Código:
client.Entity.FullyLoaded = true;
- Código:
Game.VIPDays.READ(client);
- Código:
Private void ShutDown()
- Código:
Kernel.GamePool.Remove(Entity.UID);
- Código:
VIPDays.SAVE(this);
Sql para a Database:
- Código:
/*
Navicat MySQL Data Transfer
Source Host : localhost:3306
Source Database : cq
Target Host : localhost:3306
Target Database : cq
Date: 29/12/2016 01:11:26 ã
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for vipdays
-- ----------------------------
DROP TABLE IF EXISTS `vipdays`;
CREATE TABLE `vipdays` (
`Name` varchar(16) NOT NULL default '',
`UID` bigint(18) unsigned NOT NULL default '0',
`VIPLevelDays` tinyint(5) unsigned default '0',
`OldVIPLevel` tinyint(5) unsigned default '0',
`VIPStartON` bigint(16) default '0',
`VIPEndAt` bigint(16) default '0',
PRIMARY KEY (`UID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of vipdays
-- ----------------------------
Re: Sistema de Vip com dias para acabar
crc felipe fico toop mano vlw
devid019- Membro
- Mensagens : 24
Data de inscrição : 21/02/2016
Re: Sistema de Vip com dias para acabar
felipe estou com o unico problema no Program.GamePoo()
na minha soucer nao tem esse GamePool)
na minha soucer nao tem esse GamePool)
devid019- Membro
- Mensagens : 24
Data de inscrição : 21/02/2016
Re: Sistema de Vip com dias para acabar
Felipe estou com um problema , segue print
luis pereira- Membro
- Mensagens : 32
Data de inscrição : 13/12/2021
Idade : 29
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
|
|