[C++][CreatureScript] event onAdvance

 
Tibia.net.pl

Wróć   Tibia.net.pl > OpenTibia > Skrypty - pozostałe > C++

#2 event Tibia.net.pl: Kończymy rozgrzewkę! (Start - Sobota, godz. 17:00) Big meeting (22 listopada, Poznań)


  Tibia.net.pl (#?)
[C++][CreatureScript] event onAdvance

Dyskusja dotycząca tematu [C++][CreatureScript] event onAdvance, który znajduje się w kategorii Skrypty - pozostałe (Pomoc oraz inne skrypty związane z OT.), na forum C++ (Wszystko, co związane z kompilowaniem.). Treść: Witam chcialem wrzucic na to forum Skrypt C++ do TFS na event onAdvance . Nie testowalem tego, lecz uwazam ze kod ... Na Tibia.net.pl znajdziesz dokończenie tematu [C++][CreatureScript] event onAdvance



Odpowiedz
 
21-08-2008, 20:54  
Fanatyk
 
Użytkownik schikell na Tibia.net.pl

[C++][CreatureScript] event onAdvance


Witam chcialem wrzucic na to forum Skrypt C++ do TFS na event onAdvance.

Nie testowalem tego, lecz uwazam ze kod dziala poprawnie.

Autorem kodu jest Nostradamus

creatureevent.cpp

Po:

Kod:
m_logoutEvent = NULL;
Dodaj:

Kod:
m_advanceEvent = NULL;
Po:

Kod:
delete m_logoutEvent;
Dodaj:

Kod:
delete m_advanceEvent;
Po:

Kod:
m_logoutEvent->clearEvent();
Dodaj:

Kod:
m_advanceEvent->clearEvent();
Po:

Kod:
case CREATURE_EVENT_LOGOUT:
    delete m_logoutEvent;
    m_logoutEvent = creatureEvent;
    return true;
Dodaj:

Kod:
case CREATURE_EVENT_ADVANCE:
    delete m_advanceEvent;
    m_advanceEvent = creatureEvent;
    return true;
Po:

Kod:
uint32_t CreatureEvents::playerLogout(Player* player)
{
    if(m_logoutEvent)
        return m_logoutEvent->executeOnLogout(player);
    else
        return 0;
}
Dodaj:

Kod:
uint32_t CreatureEvents::playerAdvance(Player* player)
{
    if(m_advanceEvent)
        return m_advanceEvent->executeOnAdvance(player);
    else
        return 0;
}
Po:

Kod:
else if(str == "logout")
    m_type = CREATURE_EVENT_LOGOUT;
Dodaj:

Kod:
else if(str == "advance")
    m_type = CREATURE_EVENT_ADVANCE;
Po:

Kod:
case CREATURE_EVENT_LOGOUT:
    return "onLogout";
Dodaj:

Kod:
case CREATURE_EVENT_ADVANCE:
    return "onAdvance";
Na koncu dodaj:

Kod:
uint32_t CreatureEvent::executeOnAdvance(Player* player)
{
    //onAdvance(cid)
    if(m_scriptInterface->reserveScriptEnv())
    {
        ScriptEnviroment* env = m_scriptInterface->getScriptEnv();
        #ifdef __DEBUG_LUASCRIPTS__
            char desc[30];
            sprintf(desc, "%s", player->getName().c_str());
            env->setEventDesc(desc);
        #endif
        env->setScriptId(m_scriptId, m_scriptInterface);
        env->setRealPos(player->getPosition());
        uint32_t cid = env->addThing(player);
        lua_State* L = m_scriptInterface->getLuaState();
        m_scriptInterface->pushFunction(m_scriptId);
        lua_pushnumber(L, cid);
        int32_t result = m_scriptInterface->callFunction(1);
        m_scriptInterface->releaseScriptEnv();
        return (result == LUA_TRUE);
    }
    else
    {
        std::cout << "[Error] Call stack overflow. CreatureEvent::executeOnLogout" << std::endl;
        return 0;
    }
}

creatureevent.h


Po:

Kod:
CREATURE_EVENT_LOGOUT,
Dodaj:

Kod:
CREATURE_EVENT_ADVANCE
Po:

Kod:
uint32_t playerLogout(Player* player);
Dodaj:

Kod:
uint32_t playerAdvance(Player* player);
Po:

Kod:
CreatureEvent* m_logoutEvent;
Dodaj:

Kod:
CreatureEvent* m_advanceEvent;
Po:

Kod:
uint32_t executeOnLogout(Player* player);
Dodaj:

Kod:
uint32_t executeOnAdvance(Player* player);

player.cpp


Po:

Kod:
levelMsg << "You advanced from Level " << prevLevel << " to Level " << newLevel << ".";
sendTextMessage(MSG_EVENT_ADVANCE, levelMsg.str());
Dodaj:

Kod:
//scripting event - onAdvance
g_creatureEvents->playerAdvance(this);
Po:

Kod:
advMsg << "You advanced in " << g_game.getSkillName(skill) << ".";
client->sendTextMessage(MSG_EVENT_ADVANCE, advMsg.str());
client->sendSkills();
Dodaj:

Kod:
//scripting event - onAdvance
g_creatureEvents->playerAdvance(this);
Po:

Kod:
MaglvMsg << "You advanced to magic level " << magLevel << ".";
sendTextMessage(MSG_EVENT_ADVANCE, MaglvMsg.str());
sendStats();
Dodaj:

Kod:
//scripting event - onAdvance
g_creatureEvents->playerAdvance(this);


Mysle ze wielu osoba to sie przyda. Tylko trzeba pamietac o jednym.


Przy dodawaniu skryptu z funkcja onAdvence, zamiast:

Kod:
function onAdvance(cid, oldlevel)
Dajemy:

Kod:
function onAdvance(cid)

Inaczej Bedzie CRASH Silnika


Przykladowy skrypt:

Kod:
function onAdvance(cid)
	if getPlayerLevel(cid) == 100 then
		broadcastMessage(getPlayerName(cid)..", awansowal na 100 LvL. Gratulujemy !", 
MESSAGE_EVENT_ADVANCE)
	end
end
Jezeli dodamy wyzej wymieniony skpypt, to jezeli jakis gracz zdobedzie 100 LvL to wszyscy to zobacza w formie napisu:

Nick Gracza, awansowal na 100 LvL. Gratulujemy!

---------------------------------

Mysle ze artykul jest czytelny. Prosze O Komentarze. Pozdrawiam.
 


22-08-2008, 22:21  
Fanatyk
 
Użytkownik schikell na Tibia.net.pl

Odp: [C++][CreatureScript] event onAdvance


Testowalem na TFS event dziala poprawnie. Polecam
 
17-09-2008, 02:14  
Elf
Maniak

Odp: [C++][CreatureScript] event onAdvance


Autorem danego przez Ciebie kodu jest Nostradamus, a TFS'owskiego Elf.
 
23-09-2008, 19:18  
Fanatyk
 
Użytkownik schikell na Tibia.net.pl

Odp: [C++][CreatureScript] event onAdvance


Sory zle poprawilem autora, na innym forum znalazlem ten skrypt i pisal ze to jego wiec tak wrzucilem
 
23-09-2008, 21:08  
Maniak
 
Użytkownik Hoster na Tibia.net.pl

Odp: [C++][CreatureScript] event onAdvance


Fajny skrypt Każdy skrypt na moim OTS się przyda Widzę, że dużo piszesz w tym dziale (c++). Ocena: 7.10

Pozdrawiam.
 
23-09-2008, 21:16  
Bywalec
 
Użytkownik Striker na Tibia.net.pl

Odp: [C++][CreatureScript] event onAdvance


No u mnie działa 100%,dzięki bo ja 0 z C++.
 


Odpowiedz

Narzędzia tematu
Wygląd

Podobne wątki

[8.11][TFS] event onAdvance - Prosze o pomoc z eventem onAdvance. Mam silnik TFS 0.2.13 ale ten event nie dziala :/ Potrzebuje tego do Fajerwerek na 100 lvl. Bardzo bym prosil o... schikell, 21-08-2008


Tibia.net.pl: C++ (Wszystko, co związane z kompilowaniem.)
Temat: [C++][CreatureScript] event onAdvance Witam chcialem wrzucic na to forum Skrypt C++ do TFS [...]


Zanim spytasz w temacie - wpadnij tu! - Aleq (0) 17-11-2008 16:25 Auto balance team 7.6 - Pawcio. (0) 17-11-2008 15:03 Devland 8.1 HELP! - Mzikos (2) 15-11-2008 10:03 [-8.1] Priv NPC by Aragorn - Aragornkk (3) Wczoraj 17:32 Sucre evolution [8.0] - jinn (0) 31-10-2008 16:41 [C++] GM pisze zawsze na czerwono - schikell (1) 05-10-2008 10:34 [C++] Komenda /giveskill - schikell (3) 30-09-2008 21:00 [7.6] - mati504 (0) 29-09-2008 20:28 [8.2+]Attack speed - fabian766 (0) 21-09-2008 12:21 [8.21] C++ Pomoc - God Tyran (1) 19-09-2008 21:03


Czasy w strefie GMT +1. Teraz jest 17:09.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.2.0 © 2008, Crawlability, Inc.