• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua creaturescripts - what type of event should i use?

gritness

Member
Joined
May 26, 2021
Messages
33
Reaction score
6
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"
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
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
 
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:
Back
Top