1 (edited by DBGuy 2013-06-08 11:13:12)

Topic: [PROBLEM] Only one person can gain bonus from a tile

Hi!
Yes it's me again smile
I've created a new tile that gives a player some money.

switch(GameServer()->Collision()->GetTile(m_Pos.x, m_Pos.y))
{
    case CCollision::COLFLAG_MONEY50:
        if(Server()->Tick() > lastMoney + Server()->TickSpeed())
        {
            // ccity.pMoney[m_pPlayer->GetCID()] += 50;
            m_Money += 50;
            char Buf[128];
                // str_format(Buf, sizeof(Buf), "Your money: %d $", ccity.pMoney[m_pPlayer->GetCID()]);
            str_format(Buf, sizeof(Buf), "Your money: %d $", m_Money);
            GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID());
            lastMoney = Server()->Tick();
        }
        break;
}

If one player stands on the tile, he/she can earn money. But if someone stands on the same tile too (but in another place), he/she can't earn money (a player who joined the latest can do it).

Can someone help me with this problem?

2

Re: [PROBLEM] Only one person can gain bonus from a tile

you can copy it from my uTown source, it works well there...

alternatively i need to see more of code to tell you the problem

#yemDX is a known troll

3

Re: [PROBLEM] Only one person can gain bonus from a tile

How much of code do you need to see?

Now I can tell you:
- That code in my first post is in character.cpp in the Tick() function,
- m_Money is a public integer variable defined in CCharacter class.

4

Re: [PROBLEM] Only one person can gain bonus from a tile

maybe you've made a mistake in

void CCollision::Init(class CLayers *pLayers)

#yemDX is a known troll

5

Re: [PROBLEM] Only one person can gain bonus from a tile

Hi,
sorry for my long time no answering.

The solution was easy.
I defined at the beginning of the Tick() function static int variable called lastMoney (first value was taken from Server()->Tick() return). To solve it, I declared it inside the CCharacter class (not static variable), and then defined in class initialization.

Thanks anyway smile