FSXTim Posted May 19, 2012 Share Posted May 19, 2012 Hello, I have a question. This script ir working perfectly, but how can I make that the player can only do that one time in 60 seconds? If the player already used the function for example 30 seconds ago, the ChatBox says "You can only use this function one time in 60 seconds! You have to wait "..xx.." seconds!" function bombe10_Button (state) if state == "left" then if source == GUIEditor_Button[12] then local vehicle = getPedOccupiedVehicle (getLocalPlayer()) local x,y,z = getElementPosition (getLocalPlayer()) triggerServerEvent ( "Feuerwerk", root ) end end end addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) Please help me. Greets Link to comment
laserlaser Posted May 19, 2012 Share Posted May 19, 2012 Try this one: function bombe10_Button (state) local me = getLocalPlayer() if tonumber(getElementData(me,"FeuerwerkTrigger")) > getTickCount() then local second = (tonumber(getElementData(me,"FeuerwerkTrigger")) - getTickCount()) / 1000 outputChatBox("You can only use this function one time in 60 seconds! You have to wait "..second.." seconds!") return end removeElementData(me,"FeuerwerkTrigger") if state == "left" then if source == GUIEditor_Button[12] then local vehicle = getPedOccupiedVehicle (getLocalPlayer()) local x,y,z = getElementPosition (getLocalPlayer()) triggerServerEvent ( "Feuerwerk", root ) setElementData(me,"FeuerwerkTrigger",getTickCount()+60000) end end end addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks for your answer. One Error: Line 3: attempt to compare number with nil Greets Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 function bombe10_Button ( state ) if ( state == "left" ) then if ( source == GUIEditor_Button[12] ) then if ( isTimer ( coldDownTimer ) ) then outputChatBox ( "You can use it again on ".. math.floor ( getTimerDetails ( coldDownTimer ) / 1000 ) .." seconds." ) else coldDownTimer = setTimer ( function ( ) end, 60000, 1 ) triggerServerEvent ( "Feuerwerk", localPlayer ) end end end end addEventHandler ( "onClientGUIClick", getRootElement(), bombe10_Button ) Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks, this is working perfectly. But there is something like this: "You can use it again in 13.32494137423 seconds." How can I make it that the ChatBox sais: "You can use it again in 13 seconds." Greets Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 Yes, using math.floor Copy my code again. Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 One thing: I want to trigger this clientside script: function tampa1_Button (state) if state == "left" then if source == GUIEditor_Button[3] then if ( isTimer ( coldDownTimer5 ) ) then outputChatBox ( "Du kannst Dein Auto erst wieder in ".. math.floor ( getTimerDetails ( coldDownTimer5 ) / 1000 ) .." Sekunden in eine Stretch verwandeln!", 255, 48, 48 ) else coldDownTimer5 = setTimer ( function ( ) end, 120000, 1 ) local lp = getLocalPlayer() local vehicle = getPedOccupiedVehicle (getLocalPlayer()) outputChatBox ( "Dein Auto wurde in eine Stretch verwandelt!", 65, 105, 225 ) triggerServerEvent ( "Stretch", lp ) end end end end addEventHandler("onClientGUIClick", getRootElement(), tampa1_Button) addCommandHandler ("tampa", getRootElement(), tampa1_Button) So I did it like this: function Stretch () local vehicle = getPedOccupiedVehicle ( thePlayer) setElementModel ( vehicle, 409 ) end addEvent ( "Stretch", true ) addEventHandler ( "Stretch", getRootElement(), Stretch ) Errors: Line 2: Bad argument @ 'getPedOccupiedVehicle' Line 3: Bad argument @ 'setElementModel' I want to trigger it, because when I set the 'setElementModel' function clientside, than only the player, who perform the function, will see his car as a Stretch. Greets Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 Your player element is "source" not "thePlayer" @ server side. Link to comment
FSXTim Posted May 20, 2012 Author Share Posted May 20, 2012 @Solidsnake14 Thanks, that's working now. You're very good and you help me everytime, so I have to say thanks for all. And I have a question: How long are you scripting now? 2 years, or 3? There is also one thing. I have problems with my database, and I want to pay you, if you would help me. It's a big problem and we don't need 5 minutes to fix it, I think it would take an hour or more. So if you want to earn some money, just tell me! Greets Link to comment
Castillo Posted May 20, 2012 Share Posted May 20, 2012 You're welcome. I'm not sure actually, maybe 2 years. PM me about your database problem. Link to comment
FSXTim Posted May 20, 2012 Author Share Posted May 20, 2012 You got a PM, sir! Greets 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