2015-04-29 46 views
1

最近我我ptokax更新到0.5.3,從那時起我votekick腳本已停止工作在我的腳本需要輸入從其他在線用戶爲1或2的接受或拒絕每當用戶輸入1個或2的腳本已經停止接受輸入,並在表中插入它,我懷疑用戶被踢或沒有,但現在它可能是由於一些語法變化。請看看我的劇本並提出建議。添加變量值ptokax腳本

data = " <Nick> 2" -- this is the way script takes input frm dc chat 
       s,e,vote= string.find(data,"%b<>%s(.+)") 

       if vote == "1" then 
        table.insert(votesPlus,user.sNick) 
        Core.SendToAll("*--"..user.sNick.." accepts--") 
        if #votesPlus == votes or # votesMinus == votes then 
         stop(nTimerId) 
        end 
       return true 
       elseif vote == "2" then 
        table.insert(votesMinus,user.sNick) 
        Core.SendToAll("*--"..user.sNick.." denies--") 
        if #votesPlus == votes or # votesMinus == votes then 
         stop(nTimerId) 
        end 
        return true 
       else 
        -- the user is not voting even when poll active 
       end 
+0

請說更準確地想要得到什麼,因爲它最後一次工作,你現在有什麼問題發生了什麼變化。 – meneldal

+0

ptokax的更新之前,此腳本用來工作正常,但現在這部分因某種原因停止工作後,因爲它是應該採取輸入1或2,但現在它不採取某種原因輸入。 – warl0ck

回答

0
  1. 請註明您是否使用發佈和Lua 5.3.0或5.1.5使用的PtokaX。
  2. NMDC hub protocols定義聊天消息被以下列格式發送:

    <Nick> the message| 
    

    其中|充當定界符。

除此之外,我沒有看到您的腳本有任何問題。你可以,雖然,優化性能:

local vote = data:match "%b<>%s(%d)" 
-- since you only want a single digit to be matched 
-- also, use local variable whenever possible 

if vote == "1" then 
    table.insert(votesPlus, user.sNick) 
    Core.SendToAll("*--"..user.sNick.." accepts--") 
    if #votesPlus == votes or #votesMinus == votes then 
     stop(nTimerId) 
    end 
    return true 
elseif vote == "2" then 
    table.insert(votesMinus, user.sNick) 
    Core.SendToAll("*--"..user.sNick.." denies--") 
    if #votesPlus == votes or #votesMinus == votes then 
     stop(nTimerId) 
    end 
    return true 
else 
    -- the user is not voting even when poll active 
    -- return false so that further scripts might be able to process it 
    return false 
end 

PS:我想你還應該檢查,如果同一個用戶投票兩次!另外,您可以輸入以下代碼:

if #votesPlus == votes or #votesMinus == votes then 
    stop(nTimerId) 
end 

在呼叫OnTimer函數。

+0

我使用ptokax爲lua 5.1.5僅 – warl0ck

+0

但如果腳本似乎罰款的話,我無法弄清楚爲什麼它不採取由用戶輸入的踢球員或沒有。 – warl0ck

+0

@ warl0ck你可以把整個腳本放到你的問題中嗎? – hjpotter92