Jump to content

GRANADEIRA


Recommended Posts

Posted

 

Bom Dia,

 

Pessoal to com problema num script precisava de uma ajuda, o sistema é quando o jogador pega a arma na mão ela reconhece a função que ela vai fazer e se nao tiver na mão ela nao executa a função.

 

function changeFiringMode ()
    local weapon = getPedWeapon( getLocalPlayer())
	--outputChatBox("PLAYER: "..weapon)
    if weapon == 31 then 
	    nameweapon = "AKS-74 Kobra" or "M4A1 CCO"
		setElementData ( getLocalPlayer(), "userArma", nameweapon )
	end
	if (getElementData(getLocalPlayer(),"userArma") == nameweapon) then
	    if getElementData ( getLocalPlayer(), "usingGrenadeThrower" ) then
			setElementData ( getLocalPlayer(), "usingGrenadeThrower", false )
			unbindKey ( "mouse1", "down", throwGrenade )
			toggleControl ( "fire", true )
			playSound ("sounds/itm_grenade_up.wav")
	    else
	        local weapon2 = getElementData ( getLocalPlayer(), "selectedWeapon") or "no"
	        if weapon2 and grenadesConfig[weapon2] and ( getElementData ( getLocalPlayer(), grenadesConfig[weapon2].grenadeName ) or 0 ) > 0 then 
		        setElementData ( getLocalPlayer(), "usingGrenadeThrower", weapon2 )
		        bindKey ( "mouse1", "down", throwGrenade )
		        toggleControl ( "fire", false )
		        playSound ("sounds/itm_grenade_up.wav")
	        else
		        triggerEvent ("displayClientInfo", getLocalPlayer(),"Inventory","*Você precisa de granada!",255,22,0)
		    end
	    end
	end
end

 

Tentei usar essas função aqui mas não foi como pensei.

local weapon = getPedWeapon( getLocalPlayer())
	--outputChatBox("PLAYER: "..weapon)
    if weapon == 31 then 
	    nameweapon = "AKS-74 Kobra" or "M4A1 CCO"
		setElementData ( getLocalPlayer(), "userArma", nameweapon )
	end
	if (getElementData(getLocalPlayer(),"userArma") == nameweapon) then

 

  • Other Languages Moderators
Posted
3 hours ago, felipebaidoloko said:

Tentei usar essas função aqui mas não foi como pensei.


local weapon = getPedWeapon( getLocalPlayer())
	--outputChatBox("PLAYER: "..weapon)
    if weapon == 31 then 
	    nameweapon = "AKS-74 Kobra" or "M4A1 CCO"
		setElementData ( getLocalPlayer(), "userArma", nameweapon )
	end
	if (getElementData(getLocalPlayer(),"userArma") == nameweapon) then

 

Não entendi a linha 4. Não tem lógica nisso.

Posted

sim eu tentei fazer um monte de coisa pra fazer isso, ai tava tentando ja coisa sem logica kkkkkk ai por isso vim pedir uma ajuda pq é um sistema que eu to fazendo.

  • Other Languages Moderators
Posted

Tá. Pra começar está faltando um evento ativador nessa sua função. Ela não está sendo chamada em lugar nenhum, apenas está ali sem utilidade.

Eu faria com o evento onClientPlayerWeaponSwitch, que ativa a função toda vez que você troca o slot da arma na mão. Esse evento tem 2 parâmetros de função: previousSlot, currentSlot. Esses parâmetros são respectivamente o slot que vc estava usando e o slot que vc está usando agora, depois que trocou de arma. Cada slot representa um tipo de arma, vc pode ver isso em Weapons.

Exemplo:

function showWeaponName (previousSlot, currentSlot)
	local weaponName = "Hand" -- Mão (soco)
	if getPedWeapon (getLocalPlayer(), currentSlot) == 38 then -- Se a arma que o jogador está usando agora é a minigun, então:
		weaponName = "Minigun"
	elseif getPedWeapon (getLocalPlayer(), currentSlot) == 30 then -- Se a arma que o jogador está usando agora é a ak-47, então:
		weaponName = "AK-47"
	end
	outputChatBox ("Você está usando uma "..weaponName) -- Mostra isso ao jogador sempre que ele troca de slot.
end
addEventHandler ("onClientPlayerWeaponSwitch", getRootElement(), showWeaponName)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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