Jump to content

Weapons(ayuda)


#Dv^

Recommended Posts

Hola, había hecho este scritp para que te de un arma random al escribir el comando te da un arma random

El problema es cuando pongo /arma solo sale en el chat "Ha obtenido un arma"

local weapons = { 12, 14, 15, 20, 30, 31 } 
local weapID = getWeaponNameFromID ( weapName ) 
function arma ( thePlayer, weapName ) 
    giveWeapon ( thePlayer, weapons[ math.random( #weapons ) ] )  -- Gives the M4 weapon with 200 ammo 
    outputChatBox("Ha obtenido una ".. weapName, playerSource ) 
end 
addCommandHandler("arma", arma) 

Agradezco la ayuda

Link to comment
addCommandHandler("arma", 
    function(thePlayer) 
        local weapons = {12, 14, 15, 20, 30, 31} 
        local weaponID = weapons[math.random(#weapons)] 
        if giveWeapon(thePlayer, weaponID) then 
            outputChatBox("Ha obtenido una ".. getWeaponNameFromID(weaponID), thePlayer ) 
        end 
    end 
) 

Link to comment
  
local weapons = { 12, 14, 15, 20, 30, 31 } 
local weapID = getWeaponNameFromID ( weapName ) 
function arma ( thePlayer ) 
    local wepId = weapons[ math.random( #weapons ) ]  
    giveWeapon ( thePlayer, wepId )  -- Gives the M4 weapon with 200 ammo 
    outputChatBox("Ha obtenido una ".. getWeaponNameFromID(wepId), thePlayer ) 
end 
addCommandHandler("arma", arma) 

Link to comment
local weapons = { 12, 14, 15, 20, 30, 31 } 
  
addCommandHandler ( "arma", 
    function ( player, commandName ) 
        local municionRandom = math.random ( 15, 50 ) -- Municion random desde 15 hasta 50 
        local weapon =  weapons[ math.random( #weapons ) ]  
        giveWeapon ( player, weapon, municionRandom ) 
        outputChatBox ( "Ha obtenido una "..getWeaponNameFromID ( weapon ).." con "..municionRandom.." de munición.", player ) 
    end 
) 

Link to comment
local weapons = { 12, 14, 15, 20, 30, 31 } 
  
addCommandHandler ( "arma", 
    function ( player, commandName ) 
        local municionRandom = math.random ( 15, 50 ) -- Municion random desde 15 hasta 50 
        local weapon =  weapons[ math.random( #weapons ) ]  
        giveWeapon ( player, weapon, municionRandom ) 
        outputChatBox ( "Ha obtenido una "..getWeaponNameFromID ( weapon ).." con "..municionRandom.." de munición.", player ) 
    end 
) 

No es necesario nombrar los argumentos de las funciones que no utilizarás, es innecesario y pierdes memoria :lol:

Link to comment

:P

• playerSource: The player who triggered the command. If not triggered by a player (e.g. by admin), this will be false.  
• commandName: The name of the command triggered. This is useful if multiple commands go through one function.  
• arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below.  
  

Me basé en eso

Link to comment
  • Recently Browsing   0 members

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