Jump to content

[HELP] Set "SetTime" to a Function


P4rano1a

Recommended Posts

Hello people, I am a newbie in the world of scripts and I do not understand much, I need help to set a setTime to this command, I would like this command to be used every 5 minutes, I would really appreciate it if you can help me

function getPiezasContrabandistas (player)
	if not exports.factions:isPlayerInFaction(player, 9) then outputChatBox("No eres Contrabandista.", player, 255, 0, 0) return end
	if getElementDimension(player) ~= 97 then outputChatBox("No estás en el desarme.", player, 255, 0, 0) return end
	exports.items:give(player, 34, 20)
	exports.chat:me(player, "toma una caja con piezas.")
	outputChatBox("recibiste 20 piezas", player, 0, 255, 0)
end
addCommandHandler("piezas", getPiezasContrabandistas)

 

Link to comment

It does not work for me, it gives me an error "attempt to call global ´checkPasiveTimer (a nil value)", I do not understand much the English language, i'm latino

addCommandHandler("piezas",
function (player)
		if checkPassiveTimer("piezas timer", player, 5000) then
		outputChatBox("recibiste 20 piezas", player, 0, 255, 0)
	if not exports.factions:isPlayerInFaction(player, 9) then outputChatBox("No eres Contrabandista.", player, 255, 0, 0) return end
	if getElementDimension(player) ~= 97 then outputChatBox("No estás en el desarme.", player, 255, 0, 0) return end
	exports.items:give(player, 34, 20)
	exports.chat:me(player, "toma una caja con piezas.")
	
	end
end)
Link to comment
  • Moderators
4 hours ago, P4rano1a said:

it gives me an error "attempt to call global ´checkPasiveTimer (a nil value)"

MTA useful functions do not exist unless they are added.

See Code and expand the blue box 'Server- and/or clientside Script', there you can find the source code for that function.1361411316_Schermafbeelding2022-08-07om01_31_26.thumb.png.7c0884823a87b4a21f7083bec565a091.png

4 hours ago, P4rano1a said:

I do not understand much the English language, i'm latino

In that case I only recommend to post on your own language section. It saves some time for both of us. ?

 

 

Link to comment
local minutes = 5

function startTimer(player)
	setElementData(player,"piezas_timer",true)
	setTimer(setElementData,60000*minutes,1,player,"piezas_timer",nil)
end

function getPiezasContrabandistas (player)
	if getElementData(player,"piezas_timer") then
    	return outputChatBox("The command can be used once every "..minutes.." minutes.", player, 255, 0, 0)
    end
  
	if not exports.factions:isPlayerInFaction(player, 9) then outputChatBox("No eres Contrabandista.", player, 255, 0, 0) return end
	if getElementDimension(player) ~= 97 then outputChatBox("No estás en el desarme.", player, 255, 0, 0) return end
	exports.items:give(player, 34, 20)
	exports.chat:me(player, "toma una caja con piezas.")
	outputChatBox("recibiste 20 piezas", player, 0, 255, 0)
	startTimer(player)
end
addCommandHandler("piezas", getPiezasContrabandistas)

Haven't tested but try this ?

Link to comment

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...