Jump to content

Bueno,duda scripting


Carlossg

Recommended Posts

Tengo una duda de algunos comandos que no se si existen y si existen me gustaría que me los digerais porfavor

1ºUn comando para ver si el nitro esta lleno o vacio y ver como se vacía

2ºUn evento para eventhandler que diga el final survior (en race)

3ºComo se usa math.random

Gracias y si se me ocurren mas los ire poniendo

Link to comment

En cuanto al 1 no entendi lol (un comando para saber cuanto nitro tenes?)

En en 2. no se de race...

En el 3ro, si tienes razon, sirve para sacar un numero aleatorio entre X y Y, aunque no requiere de un segundo argumento (es opcional), quiero decir, sin segundo argumento puede sacar un numero de una tabla o algo asi lol.

Como no se si me explique bien el anterior, aqui ay mas info de las funciones math. en Lua, te seran utiles, almenos para mi lo fueron... http://www.lua.org/manual/5.1/es/manual.html#pdf-math.random

Link to comment
quiero decir, sin segundo argumento puede sacar un numero de una tabla o algo asi lol.

Hay 2 argumentos posibles. Si especificas 1, la función toma un número entre 1 y el argumento.

Si especificas 2, la función toma un número entre el primer y el segundo argumento.

Para lo de saber quién es el último superviviente, busca acá: https://wiki.multitheftauto.com/wiki/Res ... sion_0.8.3

Creo que hay 2 que te sirven, uno de Finish y otro de Wasted.

Link to comment
hehe aora tengo otra duda que no se como hacer el
outputChatBox 

solo para un jugador y que solo lo vea el y no los demas

Bueno, todo esta en los argumentos: (https://wiki.multitheftauto.com/wiki/OutputChatBox)

Si es Server Side:

--Desde la Wiki:  
bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] 

Primer Argumento: Mensaje

Segundo Argumento: Elemento (Aqui decides a quien se le va a ver)

Tercero, Cuato y Quinto: R G B

Sexto Argumento: True o Flase, True para activar los Hex Color Codes (los #XXXXXX) y false para desactivarlos)

En Clien Side es lo Mismo, Solo que sin el segundo Argumento, por lo tanto el mensaje solo se le vera al juegador Local.

Link to comment

Ayuda con este script me he quedado estancado

        addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
         local money = tonumber(getElementData(thePlayer,"data.money")) 
         local suerte = math.random(0,1) 
         if ammount > money then 
         outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
         end 
         if ammount > 1000 then 
         outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
         end          
          
    end) 

Lo unico que me queda es por hacer que si el mathrandom da 1 que gane la "ammount" que ha introducido y que si da 0 la pierda.

Link to comment
addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
       local money = tonumber(getElementData(thePlayer,"data.money")) 
       local suerte = math.random(0,1) 
       if (tonumber(ammount) > money) then 
             outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
       end 
       if (ammount > 1000) then 
             outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
       end 
       if (suerte == 1) then 
             givePlayerMoney(thePlayer, tonumber(ammount)) 
       elseif (suerte == 0) then 
             takePlayerMoney(thePlayer, tonumber(ammount)) 
       end 
end) 

Link to comment

Usa éste para ocupar menos espacio. Si puedes simplificar tu script, mejor :)

addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
       if tonumber(ammount) > tonumber(getElementData(thePlayer,"data.money")) then 
             outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
       elseif ammount > 1000 then 
             outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
       end 
       if math.random ( 2 ) == 1 then givePlayerMoney(thePlayer, tonumber(ammount)) 
       else takePlayerMoney(thePlayer, tonumber(ammount)) end 
end) 

Link to comment
Usa éste para ocupar menos espacio. Si puedes simplificar tu script, mejor :)
addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
       if tonumber(ammount) > tonumber(getElementData(thePlayer,"data.money")) then 
             outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
       elseif ammount > 1000 then 
             outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
       end 
       if math.random ( 2 ) == 1 then givePlayerMoney(thePlayer, tonumber(ammount)) 
       else takePlayerMoney(thePlayer, tonumber(ammount)) end 
end) 

con este no habría menos posibilidades de ganar el dinero? ya que hace un número entre 0 y 2 ¿no? Dime si me equivoco

Link to comment

Creo que lo había posteado por acá pero no está.

Bueno, mira que te explico rápido.

A math.random le puedes dar 2 argumentos.

Si le das 2, entonces te entrega un número entre el primer y el segundo argumento.

Si le das 1, te entrega un número entre 1 y el argumento.

Osea que "math.random ( 2 )" tiene una probabilidad de 50% para 1 y 2.

La probabilidad de ganar dinero se mantiene.

Link to comment
function getServerMaps() 
local mapsTable = {} 
    for resourceKey, resourceValue in ipairs(getResources()) do 
        local name = getResourceInfo ( resourceValue, "name" ) 
        local type = getResourceInfo ( resourceValue, "type" ) 
        local author = getResourceInfo ( resourceValue, "author" ) 
        local game = getResourceInfo ( resourceValue, "gamemodes" ) 
        if (type == "map" and game == "race") then 
            table.insert(mapsTable, {name=name, author=author or "Unknown"}) 
        end 
    end 
    return mapsTable 
end 

Esa funcion deberia cargar todos los mapas que sean para el game mode "race" en una tabla y devolverla cuando ejecutas la funcion.

Ejemplo:

local mapas = getServerMaps() 
for index, map in pairs(mapas) do 
    outputChatBox(tostring(map.name) ..": ".. tostring(map.author)) 
end 

P.S: El script es server-side.

Link to comment
Usa éste para ocupar menos espacio. Si puedes simplificar tu script, mejor :)
addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
       if tonumber(ammount) > tonumber(getElementData(thePlayer,"data.money")) then 
             outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
       elseif ammount > 1000 then 
             outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
       end 
       if math.random ( 2 ) == 1 then givePlayerMoney(thePlayer, tonumber(ammount)) 
       else takePlayerMoney(thePlayer, tonumber(ammount)) end 
end) 

Gracias pero no es con dinero real del mta es con dinero símbolico de este script que me ayudaste viewtopic.php?f=91&t=37651

Por lo de los mapas gracias ahora solo tengo que hacer una ventena y que muestre eso y por cierto P.S que es Post Scripting?

Link to comment
  • Recently Browsing   0 members

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