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

Lua TFS 1.2 Looking for TalkAction like twitch predication system

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
870
Solutions
2
Reaction score
49
Hello,
so i was looking some twitch and i got an idea which is gamble/prediction system based on talkaction, which works like this.

/prediction next bonus is 100k?, yes, idontknow, 2
(prediction text, keyword1, keywword2, timer)

so it would send braodcast message that would look like this now

Player1: next bonus is 100k?
yes/idontknow
timer left:1:59
yes: 56%, idontknow:44%
command for player when he sees this would be
/predict idontknow, 500
(predict keyword, amount of money you betting)

So when time passes admin can type
/prediction answer, idontknow

when he types it it sends another broadcast message like


Player1: next bonus is 100k?
answer: idontknow
yes: 56%, idontknow:44%

and now it would split gold to those players who voted idontknow, so its like return ratio. But i dont even know if its possible tho :D but it seems interesting
 
I found this in my old files from TFS 0.3.6pl1 , its an basic vote where you ask an question in-game with admin command and people have to write simple : !yes or !no , to vote on this question.
You can re-make it for your own purposes.

XML:
XML:
    <!-- Vote -->
    <talkaction words="/vote" access="4" event="script" value="vote.lua"/>
    <talkaction words="!yes" event="script" value="vote.lua"/>
    <talkaction words="!no" event="script" value="vote.lua"/>

LUA:
Lua:
function vote_clean()
    setGlobalStorageValue(9955, 0) -- Vote storage, requires to check if any vote is already activated on server (ongoing)
    setGlobalStorageValue(2222, 0) -- "yes" storage
    setGlobalStorageValue(2223, 0) -- "no" storage
    return true
end
 
function vote_end()
         doBroadcastMessage("Vote is finally done! \n\n "..getGlobalStorageValue(2222).." players voted for yes \n and "..getGlobalStorageValue(2223).." voted for no.")
     addEvent(vote_clean, 2000)
         return true
end
 
function onSay(cid, words, param)
    local vote_end_time = 120 -- when vote finish in seconds ( 120 = 2 minutes )
    if getGlobalStorageValue(9955) ~= 1 then
        if words == '/vote' then
            addEvent(vote_end, vote_end_time * 1000)
            doBroadcastMessage(""..param.."? \n\n To vote YES, write \'!yes\', \n for vote NO, write \'!no\'.")
            setGlobalStorageValue(9955, 1)
        end
    end
    if getGlobalStorageValue(9955) == 1 then
        if words == '!yes' and getPlayerStorageValue(cid,7236) <= os.time() then
            setGlobalStorageValue(2222, getGlobalStorageValue(2222) + 1)
            doPlayerSendTextMessage(cid, 19, 'You voted for - YES.')
            setPlayerStorageValue(cid,7236, os.time()+(vote_end_time))
        elseif words == '!no' and getPlayerStorageValue(cid,7236) <= os.time() then
            setGlobalStorageValue(2223, getGlobalStorageValue(2223) + 1)
            doPlayerSendTextMessage(cid, 19, 'You voted for - NO.')
            setPlayerStorageValue(cid,7236, os.time()+(vote_end_time))
        elseif getPlayerStorageValue(cid,7236) >= os.time() then
            doPlayerSendTextMessage(cid, 19, "You already voted on this vote.")
        end
    else
        doPlayerSendTextMessage(cid, 19, "Currently there is no active vote.")
    end
    return true
end
 
I found this in my old files from TFS 0.3.6pl1 , its an basic vote where you ask an question in-game with admin command and people have to write simple : !yes or !no , to vote on this question.
You can re-make it for your own purposes.

XML:
XML:
    <!-- Vote -->
    <talkaction words="/vote" access="4" event="script" value="vote.lua"/>
    <talkaction words="!yes" event="script" value="vote.lua"/>
    <talkaction words="!no" event="script" value="vote.lua"/>

LUA:
Lua:
function vote_clean()
    setGlobalStorageValue(9955, 0) -- Vote storage, requires to check if any vote is already activated on server (ongoing)
    setGlobalStorageValue(2222, 0) -- "yes" storage
    setGlobalStorageValue(2223, 0) -- "no" storage
    return true
end
 
function vote_end()
         doBroadcastMessage("Vote is finally done! \n\n "..getGlobalStorageValue(2222).." players voted for yes \n and "..getGlobalStorageValue(2223).." voted for no.")
     addEvent(vote_clean, 2000)
         return true
end
 
function onSay(cid, words, param)
    local vote_end_time = 120 -- when vote finish in seconds ( 120 = 2 minutes )
    if getGlobalStorageValue(9955) ~= 1 then
        if words == '/vote' then
            addEvent(vote_end, vote_end_time * 1000)
            doBroadcastMessage(""..param.."? \n\n To vote YES, write \'!yes\', \n for vote NO, write \'!no\'.")
            setGlobalStorageValue(9955, 1)
        end
    end
    if getGlobalStorageValue(9955) == 1 then
        if words == '!yes' and getPlayerStorageValue(cid,7236) <= os.time() then
            setGlobalStorageValue(2222, getGlobalStorageValue(2222) + 1)
            doPlayerSendTextMessage(cid, 19, 'You voted for - YES.')
            setPlayerStorageValue(cid,7236, os.time()+(vote_end_time))
        elseif words == '!no' and getPlayerStorageValue(cid,7236) <= os.time() then
            setGlobalStorageValue(2223, getGlobalStorageValue(2223) + 1)
            doPlayerSendTextMessage(cid, 19, 'You voted for - NO.')
            setPlayerStorageValue(cid,7236, os.time()+(vote_end_time))
        elseif getPlayerStorageValue(cid,7236) >= os.time() then
            doPlayerSendTextMessage(cid, 19, "You already voted on this vote.")
        end
    else
        doPlayerSendTextMessage(cid, 19, "Currently there is no active vote.")
    end
    return true
end
Thats nice but those thinks i mentioned are the hardest stuff to do or maybe not even possible
 
Back
Top