I wrote a code for a game. There are three inventory slots that can be opened with money or jewels. The first slot with buff ID 174 can be opened only with 10kk money:
CPlayer::RemoveItem(IPlayer.GetOffset(),9,31,10000000);
With the following check i check if the player has the slots already opened:
if (!IPlayer.IsBuff(172) && !IPlayer.IsBuff(173) && !IPlayer.IsBuff(174))
The last two slots (buff ID 173 and 172) can be opened only with 39 jewels.
The problem I have atm is that if I opened the first slot it goes good, it takes out the money and works but when i'm opening after the first slot the second slot i get both messages :
IPlayer.SystemMessage("You can not extend the period because there is not enough money.",TEXTCOLOR_RED);
IPlayer.SystemMessage("You can not extend the period because there are not enough jewels.",TEXTCOLOR_RED);
I want to prefent this and that the error message of not enough money will appear only when there is no money for the first slot and the other message only when slot B and C are being opened. As you see i put after the else statment of the first inventory slot a // return because when i keep that return it gets out of the if statement and wont even make it possible to open slot B and C. I see the problem but can't figur out how to make it work correctly...
Hope someone can help me out :)
I'll post down my full code:
int JewelCheck = CPlayer::FindItem(IPlayer.GetOffset(),3360,39);
int MoneyCheck = CPlayer::FindItem(IPlayer.GetOffset(),31,10000000);
if (MoneyCheck)
{
if (IPlayer.IsBuff(172) && IPlayer.IsBuff(173) && IPlayer.IsBuff(174))
{
IPlayer.SystemMessage("You cannot add more the inventory slot(s).",TEXTCOLOR_RED);
return;
}
if (!IPlayer.IsBuff(172) && !IPlayer.IsBuff(173) && !IPlayer.IsBuff(174))
{
IPlayer.Buff(174,2592000,0);
CPlayer::Write(IPlayer.GetOffset(),204,"d",36);
CPlayer::Write(IPlayer.GetOffset(),181,"dwd",IPlayer.GetID(),499,2592000);
CPlayer::RemoveItem(IPlayer.GetOffset(),9,31,10000000);
return;
}
} else {
IPlayer.SystemMessage("You can not extend the period because there are not enough money.",TEXTCOLOR_RED);
//return;
}
if (JewelCheck)
{
if (IPlayer.IsBuff(172) && IPlayer.IsBuff(173) && IPlayer.IsBuff(174))
{
IPlayer.SystemMessage("You cannot add more the inventory slot(s).",TEXTCOLOR_RED);
return;
}
if (!IPlayer.IsBuff(172) && !IPlayer.IsBuff(173) && IPlayer.IsBuff(174))
{
IPlayer.Buff(173,2592000,0);
CPlayer::Write(IPlayer.GetOffset(),204,"d",72);
CPlayer::Write(IPlayer.GetOffset(),181,"dwd",IPlayer.GetID(),500,2592000);
CPlayer::RemoveItem(IPlayer.GetOffset(),9,3360,39);
return;
}
if (!IPlayer.IsBuff(172) && IPlayer.IsBuff(173) && IPlayer.IsBuff(174))
{
IPlayer.Buff(172,2592000,0);
CPlayer::Write(IPlayer.GetOffset(),204,"d",108);
CPlayer::Write(IPlayer.GetOffset(),181,"dwd",IPlayer.GetID(),501,2592000);
CPlayer::RemoveItem(IPlayer.GetOffset(),9,3360,39);
return;
}
} else {
IPlayer.SystemMessage("You can not extend the period because there are not enough jewels.",TEXTCOLOR_RED);
return;
}
Aucun commentaire:
Enregistrer un commentaire