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

TalkAction [TFS 1.0] Talkaction / modalWindow group flags calculator

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,694
Location
Poland
Do not post that script on other forums without my permission

talkactions.xml:
Code:
<talkaction words="/flags" script="flagcalc.lua"/>

flagcalc.lua:
Code:
player_flags = {
   [0] = "CannotUseCombat",
   [1] = "CannotAttackPlayer",
   [2] = "CannotAttackMonster",
   [3] = "CannotBeAttacked",
   [4] = "CanConvinceAll",
   [5] = "CanSummonAll",
   [6] = "CanIllusionAll",
   [7] = "CanSenseInvisibility",
   [8] = "IgnoredByMonsters",
   [9] = "NotGainInFight",
   [10] = "HasInfiniteMana",
   [11] = "HasInfiniteSoul",
   [12] = "HasNoExhaustion",
   [13] = "CannotUseSpells",
   [14] = "CannotPickupItem",
   [15] = "CanAlwaysLogin",
   [16] = "CanBroadcast",
   [17] = "CanEditHouses",
   [18] = "CannotBeBanned",
   [19] = "CannotBePushed",
   [20] = "HasInfiniteCapacity",
   [21] = "CanPushAllCreatures",
   [22] = "CanTalkRedPrivate",
   [23] = "CanTalkRedChannel",
   [24] = "TalkOrangeHelpChannel",
   [25] = "NotGainExperience",
   [26] = "NotGainMana",
   [27] = "NotGainHealth",
   [28] = "NotGainSkill",
   [29] = "SetMaxSpeed",
   [30] = "SpecialVIP",
   [31] = "NotGenerateLoot",
   [32] = "CanTalkRedChannelAnonymous",
   [33] = "IgnoreProtectionZone",
   [34] = "IgnoreSpellCheck",
   [35] = "IgnoreWeaponCheck",
   [36] = "CannotBeMuted",
   [37] = "IsAlwaysPremium"
}

player_flags_calc = {}

function nextFlag(cid, id, modalid)
local firstWindow = ModalWindow(modalid, "Player Flag Calculator", player_flags[id])
   firstWindow:addButton(1, "true")
   firstWindow:addButton(2, "false")
   firstWindow:addButton(3, "stop")
   firstWindow:setDefaultEnterButton(1)
   firstWindow:setDefaultEscapeButton(3)
   firstWindow:sendToPlayer(cid)
return true
end

function onSay(cid, words, param)
   if Player(cid):getAccountType() >= ACCOUNT_TYPE_GOD then
     player_flags_calc[cid] = 0
     nextFlag(cid, 0, 9000)
   end
return false
end

creaturescripts.xml:
Code:
<event type="modalwindow" name="flagw" script="flag_window.lua"/>

login.lua:
Code:
player:registerEvent("flagw")

flag_window.lua:
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
   if modalWindowId < 9000 or modalWindowId > 9050 then
     return false
   end
 
   if Player(cid):getAccountType() < ACCOUNT_TYPE_GOD then
     return false
   end
 
   if buttonId == 1 then
     player_flags_calc[cid] = player_flags_calc[cid] + 2 ^ (modalWindowId - 9000)
   elseif buttonId == 3 then
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Output: " .. player_flags_calc[cid])
     return true
   end
 
   if player_flags[modalWindowId + 1 - 9000] ~= nil then
     nextFlag(cid, modalWindowId + 1 - 9000, modalWindowId + 1)
   else
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Output: " .. player_flags_calc[cid])
   end
return true
end
 
Last edited:
Thank You, good job! Gotta check this out!

Kind Regards,
Eldin.
 
client-sided commands + related flags:
#b [message] Broadcast to all players on game world <---- CanBroadcast
#c [message] Red message in active channel <---- CanTalkRedChannel
@Name@ [message] Red message to a specific player <---- CanTalkRedPrivate

examples:
Code:
#b Event will be delayed due to a bug. (broadcast)
#c Please stop spamming (for example: when trade or help channel is open)
@Tester on Test'Name@ Stop that, this is your last warning (red private message to player in @@ syntax)
 
Do not post that script on other forums without my permission

talkactions.xml:
Code:
<talkaction words="/flags" script="flagcalc.lua"/>

flagcalc.lua:
Code:
player_flags = {
   [0] = "CannotUseCombat",
   [1] = "CannotAttackPlayer",
   [2] = "CannotAttackMonster",
   [3] = "CannotBeAttacked",
   [4] = "CanConvinceAll",
   [5] = "CanSummonAll",
   [6] = "CanIllusionAll",
   [7] = "CanSenseInvisibility",
   [8] = "IgnoredByMonsters",
   [9] = "NotGainInFight",
   [10] = "HasInfiniteMana",
   [11] = "HasInfiniteSoul",
   [12] = "HasNoExhaustion",
   [13] = "CannotUseSpells",
   [14] = "CannotPickupItem",
   [15] = "CanAlwaysLogin",
   [16] = "CanBroadcast",
   [17] = "CanEditHouses",
   [18] = "CannotBeBanned",
   [19] = "CannotBePushed",
   [20] = "HasInfiniteCapacity",
   [21] = "CanPushAllCreatures",
   [22] = "CanTalkRedPrivate",
   [23] = "CanTalkRedChannel",
   [24] = "TalkOrangeHelpChannel",
   [25] = "NotGainExperience",
   [26] = "NotGainMana",
   [27] = "NotGainHealth",
   [28] = "NotGainSkill",
   [29] = "SetMaxSpeed",
   [30] = "SpecialVIP",
   [31] = "NotGenerateLoot",
   [32] = "CanTalkRedChannelAnonymous",
   [33] = "IgnoreProtectionZone",
   [34] = "IgnoreSpellCheck",
   [35] = "IgnoreWeaponCheck",
   [36] = "CannotBeMuted",
   [37] = "IsAlwaysPremium"
}

player_flags_calc = {}

function nextFlag(cid, id, modalid)
local firstWindow = ModalWindow(modalid, "Player Flag Calculator", player_flags[id])
   firstWindow:addButton(1, "true")
   firstWindow:addButton(2, "false")
   firstWindow:addButton(3, "stop")
   firstWindow:setDefaultEnterButton(1)
   firstWindow:setDefaultEscapeButton(3)
   firstWindow:sendToPlayer(cid)
return true
end

function onSay(cid, words, param)
   if Player(cid):getAccountType() >= ACCOUNT_TYPE_GOD then
     player_flags_calc[cid] = 0
     nextFlag(cid, 0, 9000)
   end
return false
end

creaturescripts.xml:
Code:
<event type="modalwindow" name="flagw" script="flag_window.lua"/>

login.lua:
Code:
player:registerEvent("flagw")

flag_window.lua:
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
   if modalWindowId < 9000 or modalWindowId > 9050 then
     return false
   end

   if Player(cid):getAccountType() < ACCOUNT_TYPE_GOD then
     return false
   end

   if buttonId == 1 then
     player_flags_calc[cid] = player_flags_calc[cid] + 2 ^ (modalWindowId - 9000)
   elseif buttonId == 3 then
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Output: " .. player_flags_calc[cid])
     return true
   end

   if player_flags[modalWindowId + 1 - 9000] ~= nil then
     nextFlag(cid, modalWindowId + 1 - 9000, modalWindowId + 1)
   else
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Output: " .. player_flags_calc[cid])
   end
return true
end

It is rather odd, but I followed instructions precisely(very easy install) and now for some reason when I use the talkactions /flags I get a modalwindow with three options for CannotUseCombat stop, true, false. No matter which option I choose, the window disappears and nothing happens after that.
 
@Codinablack
You didn't register creaturecript correctly.
There should be another window when you press true/false and if you press stop, green number should appear
 
@Codinablack
You didn't register creaturecript correctly.
There should be another window when you press true/false and if you press stop, green number should appear

Right, I know... I did everything, double checked everything, it is registered in login.lua, it is registered in creaturescripts.xml, and all the code is copied from here. No typo's on names from any .xml file.
 
Right, I know... I did everything, double checked everything, it is registered in login.lua, it is registered in creaturescripts.xml, and all the code is copied from here. No typo's on names from any .xml file.
Make sure you use acc type 5 or remove this:
Code:
 if Player(cid):getAccountType() < ACCOUNT_TYPE_GO return false end

Oh and check if these window ids aren't in use already.
 
I know I am not that big of a noob, I have my own modal window by my own design working perfectly. I have the !highscores by cbrm (creaturescript using modalwindow) working, and task system too. I know how to register an event, and there aren't any typo's, I have looked over and over again.

Make sure you use acc type 5 or remove this:
Code:
 if Player(cid):getAccountType() < ACCOUNT_TYPE_GO return false end

Oh and check if these window ids aren't in use already.

It's not an account issue, I am on my god account. Now as far as conversions go, I am not any good with that... I have a modalwindow with title 0xFF but have no idea what that translates for decimal value, I wouldn't think that it would be the problem though, as far as that goes, no other window comes close to the same windowId.

Removed the line anyways (commented out the check, the return false I changed to true, tried as false, and commented it out) and still not working on my god account. Same problem everytime...
 
I have a modalwindow with title 0xFF but have no idea what that translates for decimal value, I wouldn't think that it would be the problem though, as far as that goes, no other window comes close to the same windowId.

0xFF = FF(hex) = 255(dec)
 
So did u even solve this problem? im getting the same thing as black
 
Last edited:
No I never did solve this problem, never came back to it because it wasn't a high priority, more of a luxury. I am sure if I had time to look it over I could probably isolate and solve the problem now, but there are so many group flag calulators out there right now I just didn't even bother, right now I am working 60+ hrs a week, so I barely get time to check on here, eat, shower and sleep... Maybe on my next day off I could take a look at it if I remember....
 
how to fix this problem
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/flag_window.lua:onModalWindow
data/creaturescripts/scripts/flag_window.lua:11: attempt to perform arithmetic o
n a nil value
stack traceback:
        [C]: in function '__add'
        data/creaturescripts/scripts/flag_window.lua:11: in function <data/creat
urescripts/scripts/flag_window.lua:1>
 
Back
Top