Lua creaturescripts - what type of event should i use?

gritness

New Member
Joined
May 26, 2021
Messages
16
Reaction score
2
Hey

I have a simple script made, but like in thema idk what type of event should i use? (event type in creaturescripts.xml)

"<event type=" " name="ChcekPlayerLevel" script ="nowe/questlog25update.lua" />"

Bellow u can see script which check player level (to 25 lvl)


local storage_quest25 = 1001
local storage_questlog25update = 50000

function onAdvance(player, skill, oldLevel, newLevel)

if player:getLevel() >= 25 and player:getStorageValue(storage_questlog25update) ~= 2 then
player:setStorageValue(storage_questlog25update, 2)
player:setStorageValue(storage_quest25,2)
end


end
 
Solution
Hey

I have a simple script made, but like in thema idk what type of event should i use? (event type in creaturescripts.xml)

"<event type=" " name="ChcekPlayerLevel" script ="nowe/questlog25update.lua" />"

Bellow u can see script which check player level (to 25 lvl)


local storage_quest25 = 1001
local storage_questlog25update = 50000

function onAdvance(player, skill, oldLevel, newLevel)

if player:getLevel() >= 25 and player:getStorageValue(storage_questlog25update) ~= 2 then
player:setStorageValue(storage_questlog25update, 2)
player:setStorageValue(storage_quest25,2)
end


end

type="advance"

Pox

Well-Known Member
Joined
Apr 28, 2020
Messages
126
Solutions
7
Reaction score
88
Hey

I have a simple script made, but like in thema idk what type of event should i use? (event type in creaturescripts.xml)

"<event type=" " name="ChcekPlayerLevel" script ="nowe/questlog25update.lua" />"

Bellow u can see script which check player level (to 25 lvl)


local storage_quest25 = 1001
local storage_questlog25update = 50000

function onAdvance(player, skill, oldLevel, newLevel)

if player:getLevel() >= 25 and player:getStorageValue(storage_questlog25update) ~= 2 then
player:setStorageValue(storage_questlog25update, 2)
player:setStorageValue(storage_quest25,2)
end


end

type="advance"
 
Solution

BulawOw

Soul of Shinobi
Premium User
Joined
Sep 15, 2014
Messages
195
Solutions
6
Reaction score
60
U need to think this way "so my script is checking if level is bigger then 25 or equal" the main word is advance now u have to go to ur src and check if advance creatureevent exist ctrl + f and seach for creatureevent if u gonna do it this what u gonna find this inside creatureevent.cpp


C++:
if (tmpStr == "login") {
        type = CREATURE_EVENT_LOGIN;
    } else if (tmpStr == "logout") {
        type = CREATURE_EVENT_LOGOUT;
    } else if (tmpStr == "think") {
        type = CREATURE_EVENT_THINK;
    } else if (tmpStr == "preparedeath") {
        type = CREATURE_EVENT_PREPAREDEATH;
    } else if (tmpStr == "death") {
        type = CREATURE_EVENT_DEATH;
    } else if (tmpStr == "kill") {
        type = CREATURE_EVENT_KILL;
    } else if (tmpStr == "advance") {
        type = CREATURE_EVENT_ADVANCE;
    } else if (tmpStr == "modalwindow") {
        type = CREATURE_EVENT_MODALWINDOW;
    } else if (tmpStr == "textedit") {
        type = CREATURE_EVENT_TEXTEDIT;
    } else if (tmpStr == "healthchange") {
        type = CREATURE_EVENT_HEALTHCHANGE;
    } else if (tmpStr == "manachange") {
        type = CREATURE_EVENT_MANACHANGE;
    } else if (tmpStr == "extendedopcode") {
        type = CREATURE_EVENT_EXTENDED_OPCODE;
    } else {
        std::cout << "[Error - CreatureEvent::configureEvent] Invalid type for creature event: " << eventName << std::endl;
        return false;
    }

And as u can see advance event exist so u just put type="advance" but in case its not exist u just need to create it ur self if u know c++ or look for something else that is really close and efficient
 
OP
gritness

gritness

New Member
Joined
May 26, 2021
Messages
16
Reaction score
2
Work perfectly thanks :)
Post automatically merged:

Thanks a lot, I found list of all events in my src directory and much much more :D Will be usefull in future :)
U need to think this way "so my script is checking if level is bigger then 25 or equal" the main word is advance now u have to go to ur src and check if advance creatureevent exist ctrl + f and seach for creatureevent if u gonna do it this what u gonna find this inside creatureevent.cpp


C++:
if (tmpStr == "login") {
        type = CREATURE_EVENT_LOGIN;
    } else if (tmpStr == "logout") {
        type = CREATURE_EVENT_LOGOUT;
    } else if (tmpStr == "think") {
        type = CREATURE_EVENT_THINK;
    } else if (tmpStr == "preparedeath") {
        type = CREATURE_EVENT_PREPAREDEATH;
    } else if (tmpStr == "death") {
        type = CREATURE_EVENT_DEATH;
    } else if (tmpStr == "kill") {
        type = CREATURE_EVENT_KILL;
    } else if (tmpStr == "advance") {
        type = CREATURE_EVENT_ADVANCE;
    } else if (tmpStr == "modalwindow") {
        type = CREATURE_EVENT_MODALWINDOW;
    } else if (tmpStr == "textedit") {
        type = CREATURE_EVENT_TEXTEDIT;
    } else if (tmpStr == "healthchange") {
        type = CREATURE_EVENT_HEALTHCHANGE;
    } else if (tmpStr == "manachange") {
        type = CREATURE_EVENT_MANACHANGE;
    } else if (tmpStr == "extendedopcode") {
        type = CREATURE_EVENT_EXTENDED_OPCODE;
    } else {
        std::cout << "[Error - CreatureEvent::configureEvent] Invalid type for creature event: " << eventName << std::endl;
        return false;
    }

And as u can see advance event exist so u just put type="advance" but in case its not exist u just need to create it ur self if u know c++ or look for something else that is really close and efficient
 
Last edited:
Top