P4rano1a Posted Saturday at 10:24 Share Posted Saturday at 10:24 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
Moderators IIYAMA Posted Saturday at 12:41 Moderators Share Posted Saturday at 12:41 2 hours ago, P4rano1a said: I would like this command to be used every 5 minutes Checkout this useful function: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer Link to comment
P4rano1a Posted Saturday at 19:24 Author Share Posted Saturday at 19:24 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
Shady1 Posted Saturday at 21:03 Share Posted Saturday at 21:03 I answered the answer about your topic in this section, if you have any other questions, tag me Link to comment
Moderators IIYAMA Posted Saturday at 23:47 Moderators Share Posted Saturday at 23:47 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. 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
shishani Posted Sunday at 13:06 Share Posted Sunday at 13:06 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now