Jump to content

Vote abuse


Anthrax

Recommended Posts

Posted

hola a todos, estoy teniendo problemas con el recurso votemanager.

Pues lo que quiero es que "todos jugadores" hagan votes cada 5 minutos (votemode, votemap).

ya cambie la configuración para que se haga eso cada 5 minutos pero solo lo hace para un solo jugador.

por ejemplo:

yo entro y hago un votemode, para yo haga otro votemode tengo que esperar 5 minutos. Pero entra otro jugador y el si puede hacer un votemode. ( lo que quiero es impedir eso, que se cumpla los 5 minutos del vote a nivel global)

Espero que me ayuden.

les dejo el script del votemanager (son varios)

  
--votemanager_client.lua
local rootElement = getRootElement()
 
local voteWindow
local boundVoteKeys = {}
local nameFromVoteID = {}
local voteIDFromName = {}
local optionLabels = {}
 
local isVoteActive
local hasAlreadyVoted = false
local isChangeAllowed = false
 
local timeLabel
local finishTime
 
local cacheVoteNumber
local cacheTimer
 
local layout = {}
layout.window = {
    width = 150,
    relative = false,
    alpha = 0.85,
}
layout.title = {
    posX = 10,
    posY = 25,
    width = layout.window.width,
    relative = false,
    alpha = 1,
    r = 100,
    g = 100,
    b = 250,
    font = "default-bold-small",
}
layout.option = {
    posX = 10,
    width = layout.window.width,
    relative = false,
    alpha = 1,
    r = 200,
    g = 200,
    b = 200,
    font = "default-normal",
    bottom_padding = 4, --px
}
layout.cancel = {
    posX = 10,
    width = layout.window.width,
    height = 16,
    relative = false,
    alpha = 1,
    r = 120,
    g = 120,
    b = 120,
    font = "default-normal",
}
layout.time = {
    posX = 0,
    width = layout.window.width,
    height = 16,
    relative = false,
    alpha = 1,
    r = 255,
    g = 255,
    b = 255,
    font = "default-bold-small",
}
layout.chosen = {
    alpha = 1,
    r = 255,
    g = 130,
    b = 130,
    font = "default-bold-small",
}
layout.padding = {
    bottom = 10,
}
 
local function updateTime()
    local seconds = math.ceil( (finishTime - getTickCount()) / 1000 )
    guiSetText(timeLabel, seconds)
end
 
addEvent("doShowPoll", true)
addEvent("doSendVote", true)
addEvent("doStopPoll", true)
 
addEventHandler("doShowPoll", rootElement,
    function (pollData, pollOptions, pollTime)
        --clear the send vote cache
        cacheVoteNumber = ""
        --clear the bound keys table
        boundVoteKeys = {}
        --store the vote option names in the array nameFromVoteID
        nameFromVoteID = pollOptions
        --then build a reverse table
        voteIDFromName = {}
        local width
        for id, name in ipairs(nameFromVoteID) do
            voteIDFromName[name] = id
            width = dxGetTextWidth("1. "..name) + 20
            --check if the name width is higher than the current width
            if layout.window.width < width then
                --set the curent width to the width of the name
                layout.window.width = width
            end
        end
       
        for word in string.gfind(pollData.title, "[^%s]+") do
            width = dxGetTextWidth(word) + 20
            if layout.window.width < width then
                layout.window.width = width
            end
        end
       
        --determine if we have to append nomination number
        local nominationString = ""
        if pollData.nomination > 1 then
            nominationString = " (nomination "..pollData.nomination..")"
        end
       
        isChangeAllowed = pollData.allowchange
 
        layout.title.width  = layout.window.width - 20
        layout.option.width = layout.window.width
        layout.cancel.width = layout.window.width
        layout.time.width   = layout.window.width
       
        local screenX, screenY = guiGetScreenSize()
       
        --create the window
        voteWindow = guiCreateWindowFromCache (
                        screenX,
                        screenY,
                        layout.window.width,
                        screenY, --!
                        "Vote"..nominationString,
                        layout.window.relative
                    )
        guiSetAlpha(voteWindow, layout.window.alpha)
       
        --create the title label
       
        local titleLabel = guiCreateLabelFromCache(
                        layout.title.posX,
                        layout.title.posY,
                        layout.title.width,
                        0, --!
                        pollData.title,
                        layout.title.relative,
                        voteWindow
                    )
        local titleHeight = guiLabelGetFontHeight(titleLabel) * math.ceil(guiLabelGetTextExtent(titleLabel) / layout.title.width)
        guiSetSize(titleLabel, layout.title.width, titleHeight, false)
        guiLabelSetHorizontalAlign ( titleLabel, "left", true )
       
        guiLabelSetColor(titleLabel, layout.title.r, layout.title.g, layout.title.b)
        guiSetAlpha(titleLabel, layout.title.alpha)
        guiSetFont(titleLabel, layout.title.font)
        setElementParent(titleLabel, voteWindow)
       
        local labelY = layout.title.posY + titleHeight
       
        --for each option, bind its key and create its label
        for index, option in ipairs(pollOptions) do
            --bind the number key and add it to the bound keys table
            local optionKey = tostring(index)
            bindKey(optionKey, "down", sendVote_bind)
            bindKey("num_"..optionKey, "down", sendVote_bind)
           
            table.insert(boundVoteKeys, optionKey)
           
            --create the option label
            optionLabels[index] = guiCreateLabelFromCache(
                        layout.option.posX,
                        labelY,
                        layout.option.width,
                        0,
                        optionKey..". "..option,
                        layout.option.relative,
                        voteWindow
                    )
            -- -[[ FIXME - wordwrap
            --local optionHeight = guiLabelGetFontHeight(optionLabels[index]) *
            --  math.ceil(guiLabelGetTextExtent(optionLabels[index]) / layout.option.width)
            local optionHeight = 16
            guiSetSize(optionLabels[index], layout.option.width, titleHeight, false)
            guiLabelSetHorizontalAlign ( optionLabels[index], "left", true )
            --]]
           
            guiLabelSetColor(optionLabels[index], layout.option.r, layout.option.g, layout.option.b)
            guiSetAlpha(optionLabels[index], layout.option.alpha)
            setElementParent(optionLabels[index], voteWindow)
           
            labelY = labelY + optionHeight + layout.option.bottom_padding
        end
       
        --bind 0 keys if there are more than 9 options
        if #pollOptions > 9 then
            bindKey("0", "down", sendVote_bind)
            bindKey("num_0", "down", sendVote_bind)
            table.insert(boundVoteKeys, "0")
        end
       
        if isChangeAllowed then
            bindKey("backspace", "down", sendVote_bind)
           
            --create the cancel label
            cancelLabel = guiCreateLabelFromCache(
                        layout.cancel.posX,
                        labelY,
                        layout.cancel.width,
                        layout.cancel.height,
                        "(Backspace to cancel)",
                        layout.cancel.relative,
                        voteWindow
                    )
            guiLabelSetHorizontalAlign ( cancelLabel, "left", true )
            guiLabelSetColor(cancelLabel, layout.cancel.r, layout.cancel.g, layout.cancel.b)
            guiSetAlpha(cancelLabel, layout.cancel.alpha)
            setElementParent(cancelLabel, voteWindow)
               
            labelY = labelY + layout.cancel.height
        end
       
        --create the time label
        timeLabel = guiCreateLabelFromCache(
                        layout.time.posX,
                        labelY,
                        layout.time.width,
                        layout.time.height,
                        "",
                        layout.time.relative,
                        voteWindow
                    )
        guiLabelSetColor(timeLabel, layout.time.r, layout.time.g, layout.time.b)
        guiLabelSetHorizontalAlign(timeLabel, "center")
        guiSetAlpha(timeLabel, layout.time.alpha)
        guiSetFont(timeLabel, layout.time.font)
        setElementParent(timeLabel, voteWindow)
       
        labelY = labelY + layout.time.height
       
        --adjust the window to the number of options
        local windowHeight = labelY + layout.padding.bottom
        guiSetSize(voteWindow, layout.window.width, windowHeight, false)
        guiSetPosition(voteWindow, screenX - layout.window.width, screenY - windowHeight, false)
       
       
Posted

Agrega un elementData al votar junto a un removeElementData con timer, luego en donde se ejecuta la funcion de votar agregale un if que detecte si tiene el data de voto.

Posted (edited)
Agrega un elementData al votar junto a un removeElementData con timer, luego en donde se ejecuta la funcion de votar agregale un if que detecte si tiene el data de voto.

¿¡Un elementData!? ¿Estamos locos o que? Con una simple y sencilla variable booleana bastaría y seria mucho mas eficiente.

Edited by Guest
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...