Jump to content

JesusAliso

Members
  • Posts

    332
  • Joined

  • Last visited

Posts posted by JesusAliso

  1. Quote
    --- Settings ---
    
    LOT_PRIZE_NUM = 1000 -- The lottery prize .
    LOT_PRIZE_PLUS = 100 -- If no one won the prize it will be increased , this is the plus number .
    LOT_PRIZE_PLUS_TIMES = 5 -- If no one won the prize it will be increased , this is how many times it will be increased
    --
    LOT_TICKET_PRICE = 50 -- The Lottery ticket prize .
    LOT_NUM_LIMIT = 10 -- What is the higher lottery number .
    --
    LOT_TIME_LIMIT_FROM,LOT_TIME_LIMIT_TO = 30,60 -- Random timer limit to start the lottery in seconds .
    LOT_RANDOM_NUMBER = 1 -- Random timer to make lottery in minutes .
    --- Script ---
    rRoot = resourceRoot
    --
    LOT_NUM = nil
    LOT_PRIZE = nil
    LOT_ON = false
    LOT_INC = 0
    LOT_TICKETS = {}
    LOT_WINNERS = {}
    --
    function outLot(msg,to)
    	if to then
    	--
    	outputChatBox("**#00FF00[Loteria]#FFFF00 "..msg,to,255,0,0,true)
    	else
    	outputChatBox("**#00FF00[Loteria]#FFFF00 "..msg,root,255,0,0,true)
    	end
    end 
    
    
    function onLotStart()
    	outputDebugString("Lottery By Al3grab | Started")
    	--
    	local help = getResourceFromName("helpmanager")
    	if not help then
    		outLot("By Al3grab Started")
    	else
    		local state = getResourceState(help)
    		if state == "running"  then
    			outLot("By Al3grab Started , Press F9 For Help")
    		else
    			outLot("By Al3grab Started")
    		end
    	end
    	--
    	createRandomLot()
    end
    addEventHandler("onResourceStart",rRoot,onLotStart)
    
    function createRandomLot()
    	local random:~ = math.random(1,tonumber(LOT_RANDOM_NUMBER))
    	if random:~ then
    		outLot("La próxima lotería comenzará en #00FFFF"..tonumber(random:~).."#FFFF00 Minutos")
    		random:~Timer = setTimer ( createLot , random:~ * 60 * 1000 , 1 )
    	end
    end
    
    function createLot(prize)
    	if random:~Timer then if isTimer(random:~Timer) then killTimer(random:~Timer) end end
    	LOT_NUM_LIMIT = LOT_NUM_LIMIT or 30
    	prize = prize or LOT_PRIZE_NUM
    	--
    	local lot = math.floor(math.random(1,tonumber(LOT_NUM_LIMIT)))
    	local lotTime = math.floor(math.random(LOT_TIME_LIMIT_FROM,LOT_TIME_LIMIT_TO))
    	local lotTime = lotTime * 1000
    	if lot and lotTime then
    		startLottery( 
    		lot ,
    		lotTime ,
    		prize or 50000 ,
    		LOT_PRIZE_PLUS or 5000 ,
    		LOT_TICKET_PRICE or 5000
    		)
    	end
    end
    
    addCommandHandler("lottery",function(me,cmd,prize)
    	if hasObjectPermissionTo(me,"command.shutdown") then
    		createLot(prize or nil)
    	end
    end , false ,false )
    
    function startLottery ( LotNumber , StartAfter , Prize , Plus , TicketPrice )
    	if ( LotNumber and StartAfter and Prize and Plus and TicketPrice ) then
    		outLot("La lotería comenzará en #00FFFF"..tonumber(math.floor(StartAfter/1000)).."#FFFF00 Segundos , El premio es #00FF00"..Prize.."$")
    		outLot("Usa /Ticket <numero (1-"..tonumber(LOT_NUM_LIMIT)..")> Comando para comprar un billete, el billete cuesta: #00FF00"..TicketPrice.."$")
    		LOT_NUM = LotNumber
    		LOT_PRIZE = Prize
    		LOT_INC = 0
    		LOT_ON = true
    		setTimer( function ()
    			LOT_WINNERS = {}
    			if ( LOT_TICKETS and type(LOT_TICKETS) == "table" ) then
    				for k,v in ipairs ( LOT_TICKETS ) do
    					local Player = v[1]
    					local TicketNumber = v[2]
    					if ( Player and TicketNumber ) then
    						if TicketNumber == LOT_NUM then
    							table.insert(LOT_WINNERS,Player)
    						end
    					end
    				end
    				--
    				if ( LOT_WINNERS ) then
    					onLotteryFinish(LOT_WINNERS)
    				end
    			end
    		end , StartAfter , 1 )
    		
    	end
    end 
    
    function onLotteryFinish ( table )
    	if ( table ) then
    		outLot("El número de la suerte fue #00FFFF"..tonumber(LOT_NUM).."#FFFF00 !")
    		if #table > 0 then
    			outLot("Los ganadores son:")
    			for k,v in ipairs ( table ) do
    				if isElement(v) then
    					outputChatBox("- "..getPlayerName(v),root,255,255,0,true)
    					givePlayerMoney(v,LOT_PRIZE)
    				end
    			end
    			--
    			destroyLottery(true)
    		else
    			outLot("¡Nadie ganó la lotería!")
    			increaseLottery()
    		end
    	end
    end
    
    function increaseLottery()
    	if (  tonumber(LOT_PRIZE_PLUS) ) then
    		if LOT_INC ~= LOT_PRIZE_PLUS_TIMES then
    			local LOT_INC  = tonumber(LOT_PRIZE) + tonumber(LOT_PRIZE_PLUS)
    			--
    			destroyLottery(false)
    			outLot("La lotería se ha aumentado a #00FF00"..tonumber(LOT_INC).."$#FFFF00 !")
    			createLot(LOT_INC)
    			--
    			LOT_INC = LOT_INC + 1
    		else
    			destroyLottery(true)
    		end
    	end
    end
    
    function destroyLottery(startNew)
    	LOT_NUM = nil
    	LOT_PRIZE = nil
    	LOT_ON = false
    	LOT_INC = 0
    	LOT_TICKETS = {}
    	LOT_WINNERS = {}
    	--
    	if startNew then
    		createRandomLot()
    	end
    end
    
    addCommandHandler("ticket",function ( me , cmd , number )
    	if LOT_ON then
    		if tonumber(number) and tonumber(number) >= 1 and tonumber(number) <= tonumber(LOT_NUM_LIMIT) then
    			if getPlayerMoney(me) >= LOT_TICKET_PRICE then
    				outputChatBox("**#00FF00[Loteria]#FFFF00 Tu número es "..number..", buena suerte !",me,255,0,0,true)
    				takePlayerMoney(me,LOT_TICKET_PRICE)
    				--
    				table.insert(LOT_TICKETS,{me,tonumber(number)})
    			else
    				outputChatBox("**#00FF00[Loteria]#FFFF00 no tienes #00FF00"..tonumber(LOT_TICKET_PRICE).."$",me,255,0,0,true)
    			end
    		else
    			outputChatBox("**#00FF00[Loteria]#FFFF00 El numero para el Ticket debe estar entre 1-"..LOT_NUM_LIMIT.."",me,255,0,0,true)
    		end
    	else
    		outputChatBox("**#00FF00[Loteria]#FFFF00 Ninguna Lotería está funcionando ahora !",me,255,0,0,true)
    	end
    end , false , false )

    Hello everyone, I found this lottery code and I would like to optimize it a little more. I haven't been here for a long time, but I would like to come back and learn a little more. :)
    How can I do this:
    -Limit the purchase of the ticket to 1, since the code allows you to buy 10
    -Show the current lottery prize in an on-screen text

    If you can tell me in detail what functions/events I should use to do this, I would greatly appreciate it. I'm a newbie but I can learn.

    PD: I publish in the English section, since my Spanish language section is inactive
    PD: If anyone is interested in helping me with my server please contact me on discord, I don't have much to offer but I would like to learn
    Discord: .jesusaliso

  2. 1 hour ago, Valkyrie said:

    Bueno, yo utilizo WinSCP amigo. desde ahi lo que hago es pues poner SFTP y conectarme con los mismos datos que entro al PuTTY

    spacer.png

     

    Ya desde ahi puedo administrar sin ningun problema todos los ficheros en el VPS y es bastante ordenado.

    Disculpame pero no entiendo, que pasos debo hacer primeramente? o solo descargo el WinSCP y conecto mediante la IP del VPS con el usuario y contraseña root del mismo? Tengo rato luchando con esto jeje pero no logro acceder a las carpetas del servidor, instale el 'vsftpd' y añadi un usuario pero no logro encontrar las carpetas del Servidor en el VPS.

  3. 5 hours ago, Valkyrie said:

    Yo utilizo una VPS de https://sparkedhost.com/  tienen unos planes economicos de 10 - 15 usd, con Ryzen 3900X de CPU, antiddos etc y pues el precio varia dependiendo de la ram y el disco

    Y puedes escoger diversos sistemas operativos , yo uso ubuntu server 18.04

    Tambien si lo que quieres es un host directamente de MTA y no una VPS, pues tambien te ofrecen esos planes

    Para instalarlo https://wiki.multitheftauto.com/wiki/Installing_and_Running_MTASA_Server_on_GNU_Linux

    Muchas gracias por el enlace para instalarlo, segui todo los comandos ya que un amigo me dio una VPS para ir armando mi proyecto. 

    Ya logre lo que es instalar el servidor atra vez de los comandos y iniciarlo, pero intente conectarme via el MTA y no conecta. Que pasos me faltarian a seguir? La consola no me ha arrojado ningun error y pense que usando 'openports' tendria acceso al server.

    https://imgur.com/Dk76lUz

     

    Gracias por la ayuda

     

  4. On 12/05/2020 at 20:34, aka Blue said:

    En cuanto a especificaciones de hardware parece suficiente, pero si vas a utilizar ese sistema como servidor te sugeriría meterle un Ubuntu server o algún ubuntu ligero ya que manejan y aprovechan mejor los recursos. 

    Por otro lado, la conexión es mala para albergar un servidor. Te lo tumbarían rápido.

    Vale gracias, me  pregunto como podría instalar el Servidor en Ubuntu? Y si sabes de alguna empresa que ofrezca Host para el MTA?

  5. Buenas tardes amigos, estoy de vuelta por aquí pidiendo ayuda e opiniones de como crear un Servidor para MTA en una PC y mantenerlo en linea (24/7). Hace algunos años deje de jugar al MTA y siempre me ha interesado el Scripting e Servidores, he tenido algunos por medio de empresas y pruebo scripts en servidor local de mi PC principal, menciono esto para que sepan que conozco un poco al hablar de Servidor. 

    Estas son las especificaciones del PC donde deseo iniciar el Servidor:

    E3iVcoa.png

    Tengo una conexión a Internet de 6 mb PERO la velocidad máxima al descargar es de 1.5 mb

    Tengo muchas dudas como; Puedo iniciar un servidor estable con esas especificaciones?, ¿Si no es posible, por que? ¿Falta RAM?, ¿Si es posible, que recomiendas para optimizar o tener un mejor rendimiento? Gracias espero sus respuestas :D Saludos

  6. function nickChangeHandler(oldNick, newNick) 
        if isPlayerMuted ( source ) then 
           outputChatBox ( "No puedes cambiarte el nombre estando muteado.", player, 255, 0, 0 ) 
           cancelEvent( ) 
        end      
    end 
    addEventHandler("onPlayerChangeNick", getRootElement(), nickChangeHandler) 
    

    lol :o gracias!! xD

  7. El script es para reiniciar el los 'scores' a 0. Funciona bien, pero me tira ese ERROR, pero no se cuando y cada 2,3,4 minutos. :S

    ERROR: [gameplay]/GL/Rscript.lua:7: attempt to index global 'T' (a nil value)

    Script:

    root = getRootElement() 
      
    addEventHandler("onPlayerLogin",root,function(_,account) 
        local kills = getAccountData(account,"T.Kills") 
        local deaths = getAccountData(account,"T.Deaths") 
        if not (deaths and kills) then return end 
        setElementData(source,"T.kills",T.kills) 
        setElementData(source,"T.deaths",T.deaths) 
        end 
    ) 
         
    addEventHandler("onPlayerLogout",root,function(account) 
        local kills = getElementData(source,"T.Kills") 
        local deaths = getElementData(source,"T.Deaths") 
        setAccountData(account,"T.Kills",T.Kills) 
        setAccountData(account,"T.Deaths",T.Deaths) 
        setElementData(source,"T.Kills",0) 
        setElementData(source,"T.Deaths",0) 
        end 
    ) 
      
    addEventHandler("onPlayerQuit",root,function() 
            if not isGuestAccount(getPlayerAccount(source)) then 
            local kills = getElementData(source,"T.Kills") 
            local deaths = getElementData(source,"T.Deaths") 
            setAccountData(getPlayerAccount(source),"T.Kills",T.kills) 
            setAccountData(getPlayerAccount(source),"T.Deaths",T.Deaths) 
            end 
        end 
    ) 
      
    addCommandHandler("reset",function(source) 
        setElementData(source,"T.Kills",0) 
        setElementData(source,"T.Deaths",0) 
        outputChatBox("#ff0000*INFO* #ffffffTus scores han sido reiniciados a '0' !",source,255,0,0, true) 
        if not isGuestAccount(getPlayerAccount(source)) then 
        setAccountData(getPlayerAccount(source),"T.Kills",0) 
        setAccountData(getPlayerAccount(source),"T.Deaths",0) 
        end 
        end 
    ) 
      
    addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),function() 
            for k,v in ipairs(getElementsByType("player")) do 
            if not isGuestAccount(getPlayerAccount(v)) then 
            if (getAccountData(getPlayerAccount(v),"T.Kills") and getAccountData(getPlayerAccount(v),"T.Deaths")) then 
            setElementData(v,"T.Kills",getAccountData(getPlayerAccount(v),"T.Kills")) 
            setElementData(v,"T.Deaths",getAccountData(getPlayerAccount(v),"T.Deaths")) 
            end 
            end 
        end 
        end 
    ) 
    

  8. Debes hacer un trigger del server-side al client-side el cual activara el panel.

    Ahmmm vale. gracias por la ayuda :D por cierto si no es mucho pedir, me explicarías la linea donde esta el 'isElement' y el 'getElementType', esa linea. y también por que no usaste 'isPedInVehicle' :S

  9. addEvent( "check", true ) 
    addEventHandler( "check", root, 
    function () 
        if isElement(source) and getElementType(source) == "player" then 
            if getPedOccupiedVehicle ( source ) then 
                local accName = getAccountName ( getPlayerAccount ( source ) ) 
                if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
                    outputChatBox ("* Panel abierto correctamente", thePlayer, 0, 255, 0) 
                else 
                    outputChatBox ( "* No tienes acceso", thePlayer, 255, 0, 0) 
                end 
            else 
                outputChatBox ( "* Debes estar en un vehiculo", thePlayer, 255, 0, 0) 
            end 
        else 
            outputChatBox ( "* Argumento source no esta definido como jugador", client, 255, 0, 0) 
        end 
    end 
    ) 
    

    oh gracias, lo acabo de testear. El mensaje (Debes de estar en un vehículo) funciona bien, pero el panel se sigue abriendo. No tira ningún error o warning.. :S

    Este es el clien-side:

    function guii() 
            if (guiGetVisible(window) == false) then  
               guiSetVisible(window, true) 
               showCursor(true) 
               triggerServerEvent ("check", getLocalPlayer()) 
            else 
               guiSetVisible(window, false) 
               showCursor(false) 
            end 
        end 
    bindKey (keyy, "down", guii) 
    

  10. ahmm lo acabo de probar y sale el mismo 'WARNING'.. también sale el panel como dije anteriormente. Intentare usando esa función en client-side.

    PD: los 'thePlayer' por andar copiando la linea de otro codigo xD (costumbre) :lol:

    EDIT: No pude :S no conoces otra forma de comprobar si el jugador esta en un vehículo?

  11. Buenas, tengo un 'panel' que se abre a través de la 'tecla' F6 y lo que quiero hacer es:

    Que (no) salga el 'panel' si (no) esta en un 'vehículo'.. y si esta en un 'vehículo' pues que salga. también que le salga un mensaje si (no) esta en un vehículo.

    Estoy usando esta función 'isPedInVehicle'.. intente con esto:

    addEvent( "check", true ) 
    addEventHandler( "check", getRootElement (), 
    function () 
        local jugador = getPedOccupiedVehicle ( source ) 
        local accName = getAccountName ( getPlayerAccount ( source ) ) 
        if isPedInVehicle (jugador) then 
        if jugador then 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then  
        outputChatBox ("* Panel abierto correctamente", thePlayer, 0, 255, 0) 
        else 
        outputChatBox ( "* No tienes acceso", thePlayer, 255, 0, 0) 
                end 
            end 
        end 
    end 
    ) 
    

    Me sale este warning cada vez que abre el panel:

    WARNING: panel\server.lua:666: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got boolean]

    No se si estoy usando mal la función :? también el panel se abre sin ningún problema, solo sale el warning..

    ah y como podría hacer que salga el mensaje solamente si no esta en un vehículo? (No se como) xD

  12. Si usas createVehicle, añades las texturas al vehiculo usando su variable. Obviamente si el script está en lado servidor y triggeas el EngineApplyShaderToModel al lado cliente.

    ahmm realmente nunca e usado esta función 'EngineApplyShaderToModel', solo te entendi la parte del trigger.. :S

    Me darías algún ejemplo para esa función? porfa

    Vas a tener que usar shaders

    realmente no e tratado nunca con shaders.. que funciones utilizaría? agradecería mucho un ejemplo

  13. Holaaa, como podría reemplazar la texturas de un vehículo en especifico? por ejemplo, quiero hacer autos privados.. y en el 'script' del auto privado, tengo el auto creado con 'createVehicle'.. como reemplazo solo la textura de ese vehículo?

    Script:

    auto = createVehicle( 411, 2567.1836000, -2418.5632000, 14.2882800, 315.1200000, 0, 0, 0 ) 
    puerta = setVehicleDoorState ( auto, 1, 1 ) 
      
        function  privado( player, seat, jacked ) 
            if ( source == auto ) then 
                local account = getPlayerAccount( player ) 
                local accountName = ( account and getAccountName ( account ) or "" ) 
                if not( accountName == "Jesus" ) then 
                    cancelEvent() 
                    outputChatBox("* Este auto pertenece especialmente a: Jesus ", player, 255, 0, 0) 
                else 
                    outputChatBox("* Bienvenido a tu vehiculo", player, 0, 255, 0) 
                end 
            end 
        end 
    addEventHandler ( "onVehicleStartEnter", getRootElement(), privado ) 
    

  14. Bueno, supongo que es una función export, por lo cual, cuando lo vayas a usar en otro script, usa lo siguiente:

    Modo server-side:

    exports.sidechat:outputSideChat ( mensaje, jugador a quien le quieres mostrar el mensaje, color RGB del mensaje ) 
    

    Ejemplo:

    exports.sidechat:outputSideChat ( "Hola, que tal", player, 0, 255,0 ) 
    

    Modo client-side

    exports.sidechat:outputSideChat ( mensaje, color RGB del mensaje) 
    

    Ejemplo:

    exports.sidechat:outputSideChat ( "Hey, que tal, cliente", 0, 255, 0 ) 
    

    oh, dejame probar y te aviso :D

×
×
  • Create New...