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

if player sex .... then....

Black Dove

Web-Developer
Joined
Apr 14, 2010
Messages
129
Reaction score
4
Location
Egypt
I Got a Script Want To Edit It
For Example Auto Animated Text Above Player Has XXXXX Storage "King"
All Players Have This Storage Get This Animated Text
But I Want to Edit It For Female Characters Change It To Be "Queen"
Anyone Can Help Me .. ?
 
tested on 0.4

Code:
function onThink(interval, lastExecution)
         for _, name in ipairs(getOnlinePlayers()) do
         local cid = getPlayerByName(name)
               if not isPlayerGhost(cid) and getPlayerStorageValue(cid,x) == 1 and getPlayerSex(cid) == 1 then
                  doSendMagicEffect(getPlayerPosition(cid), 39)
                  doSendAnimatedText(getPlayerPosition(cid), "KING!", TEXTCOLOR_RED)
        elseif not isPlayerGhost(cid) and getPlayerStorageValue(cid,x) == 1 and getPlayerSex(cid) == 0 then
                  doSendMagicEffect(getPlayerPosition(cid), 39)
                  doSendAnimatedText(getPlayerPosition(cid), "QUEEN!", TEXTCOLOR_RED)
               end
    end
         return true
end

edit: the sex for female was 0 not 2 lol
 
Last edited:
tested on 0.4

Code:
function onThink(interval, lastExecution)
         for _, name in ipairs(getOnlinePlayers()) do
         local cid = getPlayerByName(name)
               if not isPlayerGhost(cid) and getPlayerStorageValue(cid,x) == 1 and getPlayerSex(cid) == 1 then
                  doSendMagicEffect(getPlayerPosition(cid), 39)
                  doSendAnimatedText(getPlayerPosition(cid), "KING!", TEXTCOLOR_RED)
        elseif not isPlayerGhost(cid) and getPlayerStorageValue(cid,x) == 1 and getPlayerSex(cid) == 2 then
                  doSendMagicEffect(getPlayerPosition(cid), 39)
                  doSendAnimatedText(getPlayerPosition(cid), "QUEEN!", TEXTCOLOR_RED)
               end
    end
         return true
end

Code:
function onThink(interval, lastExecution)
    for _, name in ipairs(getOnlinePlayers()) do
        local cid = getPlayerByName(name)
        if(not isPlayerGhost(cid) and getPlayerStorageValue(cid, x) == 1) then
            local text = getPlayerSex(cid) == 0 and "QUEEN" or "KING"
            doSendMagicEffect(getPlayerPosition(cid), 39)
            doSendAnimatedText(getPlayerPosition(cid), text, TEXTCOLOR_RED)
        end
    end
return true
end
Check the diffrence and http://otland.net/threads/how-to-tab-lua-scripts.203763/
 
Code:
function onThink(interval, lastExecution)
    for _, name in ipairs(getOnlinePlayers()) do
        local cid = getPlayerByName(name)
        if(not isPlayerGhost(cid) and getPlayerStorageValue(cid, x) == 1) then
            local text = getPlayerSex(cid) == 0 and "QUEEN" or "KING"
            doSendMagicEffect(getPlayerPosition(cid), 39)
            doSendAnimatedText(getPlayerPosition(cid), text, TEXTCOLOR_RED)
        end
    end
return true
end
Check the diffrence and http://otland.net/threads/how-to-tab-lua-scripts.203763/
will check it tomorrow! thanks for giving tips and stuff
 
If you have 2 options you can always use

ifthis and dothis or dothisinstead

personally i have a habbit of doing it like so:
((ifthis and dothis) or dothisinstead)

so for you it would be
local word = ((sex == 1 and "King") or "Queen")
 
Back
Top