Jump to content

[Ayuda] Script


Recommended Posts

Hola bueno entre a un servidor y vi un script que me gusto en la mayoria de los juegos online tienen algo similar y este me gusto.

Basicamente cada nose 30 mins sale una letra en el chat

Ejemplo

X---

y en otros 30 mins:

X-B-

30mins...

XCB-

Y al completarse el codigo al primer usuario que lo introdusca en el chat recibe un arma al azar ...

creo se hace con tablas y match random o algo asi pero nose, me ayudan?

Link to comment
@Anyelberth edito este recurso publico para su servidor, pero no se si te sirve ya que no hace lo mismo que tu explicas, de todas formas, prueba.

mmm alguna idea de como que debo modificar?

Sv:

--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizefrom,prizeto = 500,800 -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..prize.."$", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..prize.."$",root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = math.random(prizefrom,prizeto) 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize #00FF00$"..thePrize,root,255,255,0,true) 
    givePlayerMoney(player,thePrize) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Link to comment
@Anyelberth edito este recurso publico para su servidor, pero no se si te sirve ya que no hace lo mismo que tu explicas, de todas formas, prueba.

mmm alguna idea de como que debo modificar?

Sv:

--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizefrom,prizeto = 500,800 -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..prize.."$", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..prize.."$",root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = math.random(prizefrom,prizeto) 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize #00FF00$"..thePrize,root,255,255,0,true) 
    givePlayerMoney(player,thePrize) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Pues el recurso recompensa con dinero, si quieres cambiar eso cambias givePlayerMoney por giveWeapon y las recompensas por armas, nada difícil.

Link to comment
@Anyelberth edito este recurso publico para su servidor, pero no se si te sirve ya que no hace lo mismo que tu explicas, de todas formas, prueba.

mmm alguna idea de como que debo modificar?

Sv:

--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizefrom,prizeto = 500,800 -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..prize.."$", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..prize.."$",root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = math.random(prizefrom,prizeto) 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize #00FF00$"..thePrize,root,255,255,0,true) 
    givePlayerMoney(player,thePrize) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Pues el recurso recompensa con dinero, si quieres cambiar eso cambias givePlayerMoney por giveWeapon y las recompensas por armas, nada difícil.

No encuentro como hacerle :S

Link to comment

Le hice una edición rápida, prueba:

--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..getWeaponNameFromID( prize ), wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..getWeaponNameFromID( prize ),root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = prizess[ math.random( 1, #prizess) ] 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize ("..thePrize..")",root,255,255,0,true) 
    giveWeapon(player,thePrize, 200) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Cualquier cosa, avísame.

PD: Necesitas el recurso 'easytext'.

Edited by Guest
Link to comment
Le hice una edición rápida, prueba:
--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..prize.."$", wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..prize.."$",root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = prizess[ math.random( 1, #prizess) ] 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize ("..thePrize..")",root,255,255,0,true) 
    giveWeapon(player,thePrize, 200) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Cualquier cosa, avísame.

Pero ahi 1 "problema" nose como funcione pero... yo uso el comando /randomword y genera un codigo alazar todo bien... pero te muestra en pantalla el codigo al instante que lo pongo... yo quiero que cada 30mins te de 1 letra del codigo y no todo :S

Link to comment
Pero ahi 1 "problema" nose como funcione pero... yo uso el comando /randomword y genera un codigo alazar todo bien... pero te muestra en pantalla el codigo al instante que lo pongo... yo quiero que cada 30mins te de 1 letra del codigo y no todo :S

Es lo que te decía, no funciona tal cual lo pediste, tendrás que crear tu uno propio si quieres hacer eso.

Edited by Guest
Link to comment
Cualquier cosa, avísame.

Pero ahi 1 "problema" nose como funcione pero... yo uso el comando /randomword y genera un codigo alazar todo bien... pero te muestra en pantalla el codigo al instante que lo pongo... yo quiero que cada 30mins te de 1 letra del codigo y no todo :S

Es lo que te decía, no funciona tal cual lo pediste, tendrás que crear tu uno propio si quieres hacer eso.

Alguna idea de que podria hacer o como?

Link to comment
Cualquier cosa, avísame.

Pero ahi 1 "problema" nose como funcione pero... yo uso el comando /randomword y genera un codigo alazar todo bien... pero te muestra en pantalla el codigo al instante que lo pongo... yo quiero que cada 30mins te de 1 letra del codigo y no todo :S

Es lo que te decía, no funciona tal cual lo pediste, tendrás que crear tu uno propio si quieres hacer eso.

Alguna idea de que podria hacer o como?

Usa el script de @Al3grab como referencia.

Link to comment

Como puedo hacer para darles un nombre?

prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } 

Cada numero es un Id de arma pero al ganarle dice has ganado 22 , o 25... pero quiero que diga el nombre...

osea 29 = Mp5? para que en el chat diga has ganado Mp5

Link to comment
Como puedo hacer para darles un nombre?
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } 

Cada numero es un Id de arma pero al ganarle dice has ganado 22 , o 25... pero quiero que diga el nombre...

osea 29 = Mp5? para que en el chat diga has ganado Mp5

Usa 'getWeaponNameFromID'.

ya lo ise acomo me dijeron del los IF pero como usaria la que medices?

prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
Arma = getWeaponNameFromID ( prizess ) 
outputChatBox("Premio : "..Arma.."",root,255,255,0,true) 
  

me da error en el argumento ..como lo uso?

Link to comment
--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..getWeaponNameFromID( prize ), wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..getWeaponNameFromID( prize ),root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = prizess[ math.random( 1, #prizess) ] 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize ("..getWeaponNameFromID(thePrize)..")",root,255,255,0,true) 
    giveWeapon(player,thePrize, 200) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Usa eso, hacerlo con if's es estúpido.

Link to comment
--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..getWeaponNameFromID( prize ), wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..getWeaponNameFromID( prize ),root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = prizess[ math.random( 1, #prizess) ] 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize ("..getWeaponNameFromID(thePrize)..")",root,255,255,0,true) 
    giveWeapon(player,thePrize, 200) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Usa eso, hacerlo con if's es estúpido.

Geneal, Gracias eres el mejor :D ...

ahora solo me falta averiguar como hacer lo de la clave eb el chat... que solo muestre 1 letra y no todo..

Link to comment
  • MTA Team
--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..getWeaponNameFromID( prize ), wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..getWeaponNameFromID( prize ),root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = prizess[ math.random( 1, #prizess) ] 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize ("..getWeaponNameFromID(thePrize)..")",root,255,255,0,true) 
    giveWeapon(player,thePrize, 200) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Usa eso, hacerlo con if's es estúpido.

Cuida tu temperamento @Alexs :lol:

Link to comment
--***********************************-- 
--***********************************-- 
--           Random Words            -- 
--            By Al3grab             -- 
--***********************************-- 
--***********************************-- 
  
---- Changeable 
captchaNums = 5 -- captcha letters length 
wordTimeInSec = 25 --- the time before the word disappear in seconds [ default 11 seconds ] 
prizess = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 } -- the prize random num 
timerfrom,timerto = 1.5,5.5 -- the random timer that shows the word [ default from 3 to 15 minutes ] 
---- unChangeable 
wordOn = false 
theWord = nil 
thePrize = nil 
wordTime = wordTimeInSec * 1000 
-- 
outputDebugString("Random Words By Al3grab | Started") 
-- 
function createCode(code,prize) 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:displayMessageForPlayer(v,1, "=========", wordTime, 0.07, 0.5, 0, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,2, "Word : "..code.."", wordTime, 0.07, 0.533, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,3, "Prize : "..getWeaponNameFromID( prize ), wordTime, 0.07, 0.563, 255, 255, 0, 255, 1.6) 
        exports.easytext:displayMessageForPlayer(v,4, "=========", wordTime, 0.07, 0.593, 0, 255, 0, 255, 1.6) 
    end 
outputChatBox("- Random Words : #FFFF00Enter the word shown below to win the prize.",root,0,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("Word : "..code.."",root,255,255,0,true) 
outputChatBox("Prize : "..getWeaponNameFromID( prize ),root,255,255,0,true) 
outputChatBox("=========",root,0,255,0,true) 
outputChatBox("- #FFFF00You can see the word down on your screen.",root,0,255,0,true) 
-- 
startCodeTimer() 
wordOn = true 
end 
  
function makeRandomCode(Word,Prize) 
    if ( Word and Prize ) then 
        theWord = Word 
        thePrize = Prize 
    else 
        theWord =  makeCaptcha(captchaNums) 
        thePrize = prizess[ math.random( 1, #prizess) ] 
    end 
    if ( tostring(theWord) and tonumber(thePrize) ) then 
        createCode(theWord,thePrize) 
    end 
end 
  
function startCodeTimer() 
    codeTimer = setTimer( function () 
        removeCode() 
        outputChatBox("- #FFFF00No one won the prize",root,0,255,0,true) 
    end , wordTime , 1 ) 
end 
  
function removeCode() 
    for k,v in ipairs( getElementsByType("player") ) do 
        exports.easytext:clearMessageForPlayer(v,1) 
        exports.easytext:clearMessageForPlayer(v,2) 
        exports.easytext:clearMessageForPlayer(v,3) 
        exports.easytext:clearMessageForPlayer(v,4) 
    end 
    if isTimer ( codeTimer ) then 
        killTimer(codeTimer) 
    end 
    theWord = nil 
    thePrize = nil 
    wordOn = false 
end 
  
function makeCaptcha(capNumz) 
 theC = "" 
  tCode = { "a","A", "b","B", "c","C", "d","D", "e","E", "f","F", "g","G", "h","H", "j","J", "k","K", "l","L", "m","L", "n","N", "o","O", "p","P", "q","Q", "r","R", "s","S", "t","T", "u","U", "v","V", "x","X", "y","Y", "z","Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "#", "?" } 
for k=1,capNumz or 5 do 
  randomCode = math.random (#tCode ) 
  theC = ""..theC..""..tCode[randomCode].."" 
end 
            return theC 
end 
  
function onPlayerWin(player) 
    outputChatBox("* "..getPlayerName(player).." #FFFF00Has won the Prize ("..getWeaponNameFromID(thePrize)..")",root,255,255,0,true) 
    giveWeapon(player,thePrize, 200) 
    removeCode() 
end 
  
function detcetChatMessage(msg,msgtype) 
    if ( wordOn == true and msg and msgtype == 0 ) then 
        if msg == theWord then 
            onPlayerWin(source) 
        end 
    end 
end 
addEventHandler("onPlayerChat",root,detcetChatMessage) 
  
addEventHandler("onResourceStop",resourceRoot,function() 
    removeCode() 
end ) 
  
function setRandomTimer() 
    setTimer(function() 
        if not wordOn then 
            makeRandomCode() 
        end 
            setRandomTimer() 
    end , math.random(timerfrom,timerto) * 60 * 1000 , 1 ) 
end 
  
addEventHandler("onResourceStart",resourceRoot,function() setRandomTimer() 
    easytext = getResourceFromName("easytext") 
    if ( easytext  ) then 
        if getResourceState(easytext) == "loaded" then 
        startResource(easytext) 
        end 
    else 
        outputChatBox("* Error , need for easytext resource to start") 
        cancelEvent() 
    end 
end ) 
  
for k,v in ipairs ( {"randomcode","randomword","rw","rd"} ) do 
addCommandHandler(v,function(plr,cmd,prize,...) 
    if plr and hasObjectPermissionTo(plr,"function.kickPlayer") then 
        if ( not prize ) then 
            makeRandomCode() 
        else 
            word = table.concat({...}, " ") 
            if ( word ) then 
                makeRandomCode(word,prize) 
            end 
        end 
    end 
end ) 
end 

Usa eso, hacerlo con if's es estúpido.

Cuida tu temperamento @Alexs :lol:

No empieces con el resentimiento ni con el Off Topic, si te molesta algo que diga, mejor déjalo ahí.

Link to comment
  • Recently Browsing   0 members

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