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

Solved onLogin (SetSkull)

Sentinel3

New Member
Joined
Oct 16, 2014
Messages
180
Reaction score
0
Hi everyone,

I was trying to add skulls to god players

Can someone tell me what's wrong with this script? Becouse I can't login in my server. And no errors in console.

Using: Lastest TFS version (1.0)

/data/creaturescript.xml

HTML:
<event type="login" name="GodSkull" script="others/greenskull.lua"/>

/data/creaturescripts/scripts/others/greenskull.lua
HTML:
function onLogin(cid)
    local player = Player(cid)
  
    if player:getGroup():getId(5) then -- id xx for God
        player:setSkull(SKULL_GREEN)
    else
        player:sendCancelMessage("Nothing") -- replace text for which message you want
    end
end
 
Did some searching, and this should be what your looking for.
Code:
if player:getAccountType() = ACCOUNT_TYPE_GOD then

OR

if player:getAccountType() < ACCOUNT_TYPE_GOD then
     return false
   end
 
Last edited:
Code:
function onLogin(cid)
local player = Player(cid)
    if player:getAccountType() = ACCOUNT_TYPE_GOD then
    player:setSkull(SKULL_GREEN)
    else
        player:sendCancelMessage("Nothing")
end
return TRUE
end
 
Did some searching, and this should be what your looking for.
Code:
if player:getAccountType() = ACCOUNT_TYPE_GOD then

OR

if player:getAccountType() < ACCOUNT_TYPE_GOD then
     return false
   end
Code:
function onLogin(cid)
local player = Player(cid)
    if player:getAccountType() = ACCOUNT_TYPE_GOD then
    player:setSkull(SKULL_GREEN)
    else
        player:sendCancelMessage("Nothing")
end
return TRUE
end

[Warning - Event::checkScript] Can not load script: scripts/others/greenskull.lua
data/creaturescripts/scripts/others/greenskull.lua:3: 'then' expected near '='
 
Already add the scripts, but when I enter in-game doesn't work.

/data/creaturescripts.xml
HTML:
<event type="login" name="GodSkull" script="others/greenskull.lua"/>


/data/creaturescripts/scripts/others/greenskull.lua
HTML:
function onLogin(cid)
    local player = Player(cid)
    if player:getAccountType() == ACCOUNT_TYPE_GOD then
        player:setSkull(SKULL_GREEN)
    else
        player:sendCancelMessage("Error")
    end
    return true
end

I just want to achieve this for Gods:
Captura_zpsdbb96f57.png
 
Bump.

|----------------------------|

Still not working, have someone a idea about this to work perfectly?


/data/creaturescripts.xml
HTML:
<event type="login" name="GodSkull" script="others/greenskull.lua"/>

/data/creaturescripts/scripts/others/greenskull.lua
HTML:
function onLogin(cid)
    local player = Player(cid)
        getPlayerGroupId(cid)
    if player:getAccountType() == 5 then
        player:setSkull(SKULL_GREEN)
    else
        player:sendCancelMessage("Error")
    end
    return true
end
 
Code:
Skulls_t Player::getSkull() const
{
    if (hasFlag(PlayerFlag_NotGainInFight)) {
        return SKULL_NONE;
    }
    return skull;
}

Since gods have the flag PlayerFlag_NotGainInFight, they will not receive any skull. However you can subtract the flags value in groups.xml with 512.
 
Code:
Skulls_t Player::getSkull() const
{
    if (hasFlag(PlayerFlag_NotGainInFight)) {
        return SKULL_NONE;
    }
    return skull;
}

Since gods have the flag PlayerFlag_NotGainInFight, they will not receive any skull. However you can subtract the flags value in groups.xml with 512.

Then I have this:

/data/XML/groups.xml
HTML:
<?xml version="1.0" encoding="UTF-8"?>
<groups>
<group id="1" name="Player" flags="137438953472" access="0" maxdepotitems="0" maxvipentries="0" />
<group id="2" name="Tutor" flags="16809984" access="1" maxdepotitems="0" maxvipentries="200" />
<group id="3" name="Senior Tutor" flags="68736286720" access="1" maxdepotitems="0" maxvipentries="200" />
<group id="4" name="Gamemaster" flags="3808558964575" access="1" maxdepotitems="0" maxvipentries="200" />
<group id="5" name="Comunity Manager" flags="3840774348794" access="1" maxdepotitems="0" maxvipentries="200" />
<group id="6" name="God" flags="272730398714" access="1" maxdepotitems="0" maxvipentries="200" />
</groups>

What should I do right now?
 
Code:
Skulls_t Player::getSkull() const
{
    if (hasFlag(PlayerFlag_NotGainInFight)) {
        return SKULL_NONE;
    }
    return skull;
}

Since gods have the flag PlayerFlag_NotGainInFight, they will not receive any skull. However you can subtract the flags value in groups.xml with 512.
I've searched around a long time looking for how flags are generated.
I've never understood them. Is there a lengthy post anywhere that describes how flags are generated? What flag does what?
 
I'm guessing each flag a specific value, that's added each time you set a new flag.. so
272730398714 is your god's so subtract 512 from it?
272730398202 would make it work?
 
I'm guessing each flag a specific value, that's added each time you set a new flag.. so
272730398714 is your god's so subtract 512 from it?
272730398202 would make it work?
That's right (see const.h). Yep, it will work if you subtract by 512.

Use the flag calculator from @Sentinel3's post and play around with it, e.g use the first value you mentioned and subtract by 512 and you will see that "Do not gain infight" will be unticked.

zMG4jmw.png
 
Back
Top