1 (edited by ljwlaji 2016-02-08 15:53:13)

wanna do a project to give a player some items and learn riding skill
i do this but,it don't work.
i think i know the mistake but don t know how to fix it

//This function is called just before the players level changes
void OnPlayerLevelChanged(Player* player/*player*/, uint8* newlevel/*newLevel*/)
{
    char msg[250];
    switch (player->GetSession()->GetSecurity())
    {
        case 0:
        {
              {
              if (player->getLevel() == 40)
              {
                  snprintf(msg, 250, "[%d] class [%d] has been Level 40 now !!!", player->GetName, player->getClass);
                  player->AddItem(34334, 1);
                  player->LearnSpell(456789);
              }
              if (player->getLevel() == 60)
              {
                  snprintf(msg, 250, "[%d] class [%d] has been Level 60 now !!!", player->GetName, player->getClass);
                  player->AddItem(123456, 1);
                  player->LearnSpell(456789);
              }
              sWorld.SendGlobalText(msg, NULL);
              break;
        }
        case 1: //
        {
            if (player->getLevel() == 40)
            {
                snprintf(msg, 250, "[%d] class [%d] has been Level 40 now !!!", player->GetName, player->getClass);
                player->AddItem(123456, 1);
                player->LearnSpell(456789);
            }
            if (player->getLevel() == 60)
            {
                snprintf(msg, 250, "[%d] class [%d] has been Level 460now !!!", player->GetName, player->getClass);
                player->AddItem(123456, 1);
                player->LearnSpell(456789);
            }
        }
            sWorld.SendGlobalText(msg, NULL);
            break;
}

i think maybe there should be some code between additem-> and leranspell-> to let core knows to give who?
or player->getlevel() == 40 is a wrong write.
but don t know the right way to write....

2 (edited by Baynar 2016-02-09 12:18:08)

Change:

void OnPlayerLevelChanged(Player* player/*player*/, uint8* newlevel/*newLevel*/)

to:

void OnPlayerLevelChanged(Player* player, uint8* newlevel)

i think this should fix it

also check if u have

newscript->OnPlayerLevelChanged = &OnPlayerLevelChanged;

if its needed

Baynar wrote:

Change:

void OnPlayerLevelChanged(Player* player/*player*/, uint8* newlevel/*newLevel*/)

to:

void OnPlayerLevelChanged(Player* player, uint8* newlevel)

i think this should fix it

also check if u have

newscript->OnPlayerLevelChanged = &OnPlayerLevelChanged;

if its needed

thank you very much! i'll check it