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

Death Times script

Na Amigo

The crazy girl
Joined
Jun 5, 2017
Messages
254
Solutions
3
Reaction score
18
Location
Egypt
hello i want to make action id with movement script step in the magicforce field if you jump at the magiceforce field a message sent to you "you have died "number of Death"
thanks
 
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
   local amount = db.storeQuery("SELECT COUNT(*) FROM `player_deaths` WHERE `player_id` = '".. getPlayerGUID(cid) .."'")
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have died ".. result.getNumber(amount, "COUNT(*)") .." times.")
   return true
end
 
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
   local amount = db.storeQuery("SELECT COUNT(*) FROM `player_deaths` WHERE `player_id` = '".. getPlayerGUID(cid) .."'")
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have died ".. result.getNumber(amount, "COUNT(*)") .." times.")
   return true
end
thank you for your reply, i've aries xml 0.4.0 8.1 and i get this error at my console
lRfah0.png
 
i dont have the source
Well it will be a little difficult to help you. :( because the 0.4 sources that we do find on github does have a db table and your script throws errors when we call this table.
The only other solution would be to re-write the script like this.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    -- is db a table and does it contain values
    if db and next(db) then
        -- does it have a function named storeQuery
        if type(db.storeQuery) == 'function' then
            local amount = db.storeQuery("SELECT COUNT(*) FROM `player_deaths` WHERE `player_id` = '".. getPlayerGUID(cid) .."'")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have died ".. result.getNumber(amount, "COUNT(*)") .." times.")
        end
        return true
    end
    return false
end
But then again the script may never execute.
 
Well it will be a little difficult to help you. :( because the 0.4 sources that we do find on github does have a db table and your script throws errors when we call this table.
The only other solution would be to re-write the script like this.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    -- is db a table and does it contain values
    if db and next(db) then
        -- does it have a function named storeQuery
        if type(db.storeQuery) == 'function' then
            local amount = db.storeQuery("SELECT COUNT(*) FROM `player_deaths` WHERE `player_id` = '".. getPlayerGUID(cid) .."'")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have died ".. result.getNumber(amount, "COUNT(*)") .." times.")
        end
        return true
    end
    return false
end
But then again the script may never execute.
He said he's using xml based server, so he hasnt any database at all...

thank you for your reply, i've aries xml 0.4.0 8.1 and i get this error at my console
lRfah0.png
Its ancient history. I suggest to change it for newest TFS.
Anyway i doubt you will get any help. Especially if you havent got a source.
 
Well it will be a little difficult to help you. :( because the 0.4 sources that we do find on github does have a db table and your script throws errors when we call this table.
The only other solution would be to re-write the script like this.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    -- is db a table and does it contain values
    if db and next(db) then
        -- does it have a function named storeQuery
        if type(db.storeQuery) == 'function' then
            local amount = db.storeQuery("SELECT COUNT(*) FROM `player_deaths` WHERE `player_id` = '".. getPlayerGUID(cid) .."'")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have died ".. result.getNumber(amount, "COUNT(*)") .." times.")
        end
        return true
    end
    return false
end
But then again the script may never execute.
dude this an xml 8.1 server Aries 0.4.0 if can write the script at new method
 
Last edited:
He said he's using xml based server, so he hasnt any database at all...
Anyway i doubt you will get any help. Especially if you havent got a source.
Where did he say he was using an xml based server?

dude this an xml 8.1 server Aries 0.4.0 if can write the script at new method
Would of been helpful if you mentioned that originally anyway as @2Rec suggested upgrade or learn xml which is easier for you :)
 
Last edited by a moderator:
Does the xml server have 'onDeath' or 'onPrepareDeath' and storage values?

If yes, you could create an onDeath/PrepareDeath script to count player deaths using storage values, then use that storage value in the movement script.
 
Does the xml server have 'onDeath' or 'onPrepareDeath' and storage values?

If yes, you could create an onDeath/PrepareDeath script to count player deaths using storage values, then use that storage value in the movement script.
could you post some script with onDeath and PrepareDeath scripts
 
\
i dont know but, i've some source xml like aries 0.4.0 99% but 8.00 i can send it to you private i am not good at programming
Well.. I found the spot you could maybe get it working, but idk what lines to put here for storage.

You'd have to advance the player storage in this file.. and recompile I guess.

creature.cpp
Code:
void Creature::onKilledCreature(Creature* target)
{
   if(getMaster()){
       getMaster()->onKilledCreature(target);
   }
  
   #ifdef __JD_DEATH_LIST__
   if(target->getPlayer()){
       target->getPlayer()->addDeath(getName(), target->getPlayer()->getLevel(), std::time(NULL));
   }
   #endif
}

I found this line in
ioplayersql.cpp
Code:
query_insert.setQuery("INSERT INTO `playerstorage` (`player` , `key` , `value` ) VALUES ");

Dunno if it's correct or not to use.
zzzz

I'm at my knowledge limit here.

-- edit
As far as I can tell, creaturescripts don't exist on your server.. so basically your missing out on 3/4 of the functions used for anything cool. :/

onLogin
onLogout
onSpawnSingle
onSpawn
onChannelJoin
onChannelLeave
onChannelRequest
onThink
onAdvance
onLook
onDirection
onOutfit
onMailSend
onMailReceive
onTradeRequest
onTradeAccept
onTextEdit
onHouseEdit
onReportBug
onReportViolation
onThankYou
onStatsChange
onAreaCombat
onThrow
onPush
onTarget
onFollow
onCombat
onAttack
onCast
onKill
onDeath
onPrepareDeath



I know that little server means a lot to you, but if you want any cool functions dealing with players directly.. your going to miss out.
 
Last edited:
Well.. I found the spot you could maybe get it working, but idk what lines to put here for storage.

You'd have to advance the player storage in this file.. and recompile I guess.

creature.cpp
Code:
void Creature::onKilledCreature(Creature* target)
{
   if(getMaster()){
       getMaster()->onKilledCreature(target);
   }
 
   #ifdef __JD_DEATH_LIST__
   if(target->getPlayer()){
       target->getPlayer()->addDeath(getName(), target->getPlayer()->getLevel(), std::time(NULL));
   }
   #endif
}

I found this line in
ioplayersql.cpp
Code:
query_insert.setQuery("INSERT INTO `playerstorage` (`player` , `key` , `value` ) VALUES ");

Dunno if it's correct or not to use.
zzzz

I'm at my knowledge limit here.

-- edit
As far as I can tell, creaturescripts don't exist on your server.. so basically your missing out on 3/4 of the functions used for anything cool. :/

onLogin
onLogout
onSpawnSingle
onSpawn
onChannelJoin
onChannelLeave
onChannelRequest
onThink
onAdvance
onLook
onDirection
onOutfit
onMailSend
onMailReceive
onTradeRequest
onTradeAccept
onTextEdit
onHouseEdit
onReportBug
onReportViolation
onThankYou
onStatsChange
onAreaCombat
onThrow
onPush
onTarget
onFollow
onCombat
onAttack
onCast
onKill
onDeath
onPrepareDeath



I know that little server means a lot to you, but if you want any cool functions dealing with players directly.. your going to miss out.
omg This is not reasonable did not work right?

Well it will be a little difficult to help you. :( because the 0.4 sources that we do find on github does have a db table and your script throws errors when we call this table.
The only other solution would be to re-write the script like this.
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    -- is db a table and does it contain values
    if db and next(db) then
        -- does it have a function named storeQuery
        if type(db.storeQuery) == 'function' then
            local amount = db.storeQuery("SELECT COUNT(*) FROM `player_deaths` WHERE `player_id` = '".. getPlayerGUID(cid) .."'")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have died ".. result.getNumber(amount, "COUNT(*)") .." times.")
        end
        return true
    end
    return false
end
But then again the script may never execute.
i tested this script at tfs 0.4.0 8.6 it's also not working

bumb!
 
Last edited by a moderator:
Back
Top