• 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!

Compiling If not hunt add stamina

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
Where in sources 0.4 show
If player hunt -stamina

I want make:
If player is not hunt +stamina
 
Stamina is normally gained when the player logs out or isn't gaining experience.
Look for something similar in 0.4
https://github.com/Jo-Tran/cryingda...f21b5602cde8a6771a2f4d/player.cpp#L3699-L3726

I didn't see nothing here adding stamina
Code:
bool Player::rateExperience(double& gainExp, bool fromMonster)
{
   if(hasFlag(PlayerFlag_NotGainExperience) || gainExp <= 0)
     return false;

   if(!fromMonster)
     return true;

   gainExp *= rates[SKILL__LEVEL] * g_game.getExperienceStage(level,
     vocation->getExperienceMultiplier());
   if(!hasFlag(PlayerFlag_HasInfiniteStamina))
   {
     int32_t minutes = getStaminaMinutes();
     if(minutes >= g_config.getNumber(ConfigManager::STAMINA_LIMIT_TOP))
     {
       if(isPremium() || !g_config.getNumber(ConfigManager::STAMINA_BONUS_PREMIUM))
         gainExp *= g_config.getDouble(ConfigManager::RATE_STAMINA_ABOVE);
     }
     else if(minutes < (g_config.getNumber(ConfigManager::STAMINA_LIMIT_BOTTOM)) && minutes > 0)
       gainExp *= g_config.getDouble(ConfigManager::RATE_STAMINA_UNDER);
     else if(minutes <= 0)
       gainExp = 0;
   }
   else if(isPremium() || !g_config.getNumber(ConfigManager::STAMINA_BONUS_PREMIUM))
     gainExp *= g_config.getDouble(ConfigManager::RATE_STAMINA_ABOVE);

   return true;
}

its just get stamina to make ifs to change experience

int32_t minutes = getStaminaMinutes();


I want know where remove stamina hunting on sourcers to make:
IF player hunt -stamina
IF player offline +stamina
IF player online, but not hunt +stamina
 
You could alternatively create a script to check when they last gained experience, or make a script to check if they are inside a towns 'limits' and reward them with stamina.
 
You could alternatively create a script to check when they last gained experience, or make a script to check if they are inside a towns 'limits' and reward them with stamina.

I tried edit on sources, because i want know how it work

the maximum I could find related to LUA was:
Code:
function onThink(interval, lastExecution)
  for _, pid in ipairs(getPlayersOnline()) do
  doPlayerAddStamina(pid, 1)
  end
  return true
end

How could i check last exp?
 
This script will add stamina for all player online not only player hunging.
U can use chack battle if player have pz locked add stamina or check tile if not pz add stamina (i will try go get laptop and make for u im use noob pbone )
 
This script will add stamina for all player online not only player hunging.
U can use chack battle if player have pz locked add stamina

i know, thats why i ask how to make a if player recive exp recent...

he know its possible, if i check combat like
Code:
if getCreatureCondition(cid, CONDITION_INFIGHT) then

Players training will not recive stamina and i dont want it
 
Why player training dont recive stamina ? They will have pz locked
Use tile pz .. if tile not pz add stamina this mean any player out temple will recive
 
u can use this script for training players
globalevent/scripts/addstamina.lua

Code:
function onThink(interval, lastExecution)
     for _, pid in ipairs(getPlayersOnline()) do
         if isInRange(getPlayerPosition(pid), {x = 962, y = 759, z = 4}, {x = 1021, y = 800, z = 7}) then -- change to positions where Training Room..
            if isPlayer(pid) then
            doPlayerAddStamina(pid, 1)
             end
         end
     end
     return true
end

globalevent.xml
Code:
<globalevent name="check" interval="70000" event="script" value="addstamina.lua"/>
 
u can use this script for training players
globalevent/scripts/addstamina.lua

Code:
function onThink(interval, lastExecution)
     for _, pid in ipairs(getPlayersOnline()) do
         if isInRange(getPlayerPosition(pid), {x = 962, y = 759, z = 4}, {x = 1021, y = 800, z = 7}) then -- change to positions where Training Room..
            if isPlayer(pid) then
            doPlayerAddStamina(pid, 1)
             end
         end
     end
     return true
end

globalevent.xml
Code:
<globalevent name="check" interval="70000" event="script" value="addstamina.lua"/>

I've saw scripts like this on web...
I cant use it
I need check last exp, cause my server dont have training monks. Players can train on everywhere with summons
 
I've saw scripts like this on web...
I cant use it
I need check last exp, cause my server dont have training monks. Players can train on everywhere with summons
Well , i got an idea :)
No function to check last exp , so you can't check last exp
But you can check fight condition

So instead of checking last exp , check his fight mode
If he got fight condition he wont get stamina , else he got stamina
The only way you can do it
 
You could alternatively create a script to check when they last gained experience, or make a script to check if they are inside a towns 'limits' and reward them with stamina.
I tried edit on sources, because i want know how it work

the maximum I could find related to LUA was:
Code:
function onThink(interval, lastExecution)
  for _, pid in ipairs(getPlayersOnline()) do
  doPlayerAddStamina(pid, 1)
  end
  return true
end

How could i check last exp?
creaturevent
Code:
local timing = 2 * 60 * 1000 -- 2 minutes

local function giveStamina(cid, exp)
    if not isPlayer(cid) then
        return true
    end

    local experience = getPlayerExperience(cid)
    if experience == exp then
        -- check if stamina is full
            doPlayerAddStamina(cid, 1)
        -- end
    end

    addEvent(giveStamina, timing, cid, experience)
end

function onLogin(cid)
    local experience = getPlayerExperience(cid)
    addEvent(giveStamina, timing, cid, experience)
    return true
end
I don't know enough about stamina.. but you'll have to check if they are currently full stamina before adding another minute to it.
 
Last edited:
i want know some information about ur training system its will help me to do it ...
u can use when player stay on training tile take storage and when player logout or move from tile change storage to 0
and change
if isPlayer(pid) then
to
if getPlayerStorageValue(pid,xxxx) > 1 then
hope its help u
 
i want know some information about ur training system its will help me to do it ...
u can use when player stay on training tile take storage and when player logout or move from tile change storage to 0
and change
if isPlayer(pid) then
to
if getPlayerStorageValue(pid,xxxx) > 1 then
hope its help u

No man, i dont use training monks, players tain where they want
Just sumon a monk and train...


creaturevent
Code:
local timing = 2 * 60 * 1000 -- 2 minutes

local function giveStamina(cid, exp)
    if not isPlayer(cid) then
        return true
    end

    local experience = getPlayerExperience(cid)
    if experience == exp then
        -- check if stamina is full
            doPlayerAddStamina(cid, 1)
        -- end
    end

    addEvent(giveStamina, timing, cid, experience)
end

function onLogin(cid)
    local experience = getPlayerExperience(cid)
    addEvent(giveStamina, timing, cid, experience)
end
I don't know enough about stamina.. but you'll have to check if they are currently full stamina before adding another minute to it.


I've tried your script, but now i cant login on my server..
What i made worng?

creaturescripts.xml
Code:
<event type="login" name="AddStaminaIfNotHunting" event="script" value="add_stamina_not_hunt.lua"/>

login.lua (register)
Code:
registerCreatureEvent(cid, "AddStaminaIfNotHunting")

add_stamina_not_hunt.lua
Code:
local timing = 1 * 60 * 1000 -- 1 minute
local fullstamina = 42 * 60 * 1000

local function giveStamina(cid, exp)
  if not isPlayer(cid) then
  return true
  end

  local experience = getPlayerExperience(cid)
  if experience == exp then
  if(getPlayerStamina(cid) >= fullstamina) then
  doPlayerAddStamina(cid, 1)
  end
  end

  addEvent(giveStamina, timing, cid, experience)
end

function onLogin(cid)
  local experience = getPlayerExperience(cid)
  addEvent(giveStamina, timing, cid, experience)
end
 
No man, i dont use training monks, players tain where they want
Just sumon a monk and train...





I've tried your script, but now i cant login on my server..
What i made worng?

creaturescripts.xml
Code:
<event type="login" name="AddStaminaIfNotHunting" event="script" value="add_stamina_not_hunt.lua"/>

login.lua (register)
Code:
registerCreatureEvent(cid, "AddStaminaIfNotHunting")

add_stamina_not_hunt.lua
Code:
local timing = 1 * 60 * 1000 -- 1 minute
local fullstamina = 42 * 60 * 1000

local function giveStamina(cid, exp)
  if not isPlayer(cid) then
  return true
  end

  local experience = getPlayerExperience(cid)
  if experience == exp then
  if(getPlayerStamina(cid) >= fullstamina) then
  doPlayerAddStamina(cid, 1)
  end
  end

  addEvent(giveStamina, timing, cid, experience)
end

function onLogin(cid)
  local experience = getPlayerExperience(cid)
  addEvent(giveStamina, timing, cid, experience)
end
function onLogin(cid)
local experience = getPlayerExperience(cid)
addEvent(giveStamina, timing, cid, experience)
return true
end

my bad
 
i can make if any one have battle will get stamina
if he hunt or training or pk he will get stamina if u need i can show u but i think bad idea :S
 
Idk why, but its no adding stamina... :(
Code:
local fullstamina = 42 * 60 * 1000
if(getPlayerStamina(cid) >= fullstamina) then
These parts of your code are incorrect.
Change to this.
Code:
local fullstamina = 42 * 60
if getPlayerStamina(cid) < fullstamina then
 
Code:
local fullstamina = 42 * 60 * 1000
if(getPlayerStamina(cid) >= fullstamina) then
These parts of your code are incorrect.
Change to this.
Code:
local fullstamina = 42 * 60
if getPlayerStamina(cid) < fullstamina then

Ty! Sorry to didn't see
 
Back
Top