jkub Posted September 25, 2009 Share Posted September 25, 2009 I am making a multi function bomb shop and I need some help with the time bomb part. It has a window for setting your own time for the car to blow up but I do no know how to pass the data from the function that retrives the data from the input field into the function that arms the bomb and tells it when to blow up. The only way I can do it right now is with this command /arm I want to be able to use my time window I made in the gui to tell how long the time will be plz help me this is server part function armTimeBomb ( player, cmd, timeSetting ) local veh = getPedOccupiedVehicle(player) if isPedInVehicle ( player ) then if getElementData ( veh, "rigged", true ) then setTimer ( blowVehicle, tonumber(timeSetting), 1, veh ) outputChatBox ( "Go Boom in " ..timeSetting ) end end end addEventHandler ( "clientSetTimeBomb", root, function ( timeSetting ) timeSetting = timeSetting takePlayerMoney ( client, 350 ) outputChatBox ( "You have purchased a Time Bomb. To arm the bomb type /arm", client, 0, 255, 0 ) outputChatBox ( timeSetting ) addCommandHandler ( "arm", armTimeBomb, tonumber(timeSetting) ) end ) --TIME BOMB function clientTimeBomb() if ( getPlayerMoney ( client ) >= 350 ) then if isPedInVehicle ( client ) then local clientVeh = getPedOccupiedVehicle ( client ) if getElementData ( clientVeh, "rigged", true ) then outputChatBox ( "ERROR: This vehicle is already rigged", client, 255, 0, 0 ) else setElementData ( clientVeh, "rigged", clientVeh ) setElementData ( clientVeh, "timebomb", clientVeh ) triggerClientEvent ( client, "showTimeModifier", client ) end end end end --TIME BOMB Link to comment
50p Posted September 25, 2009 Share Posted September 25, 2009 ...I want to be able to use my time window I made in the gui to tell how long the time will be plz help me ... What's the problem then? You know how to arm the bomb (you have a function for it) so make a gui element call that function. Because that function is server-side, use triggerServerEvent to... well, trigger server event which will call that function. I don't see anything difficult that you couldn't do since you use triggerClientEvent. Link to comment
jkub Posted September 25, 2009 Author Share Posted September 25, 2009 As soon as the player clicks the ok button on the time modifier window for that section I do not want it armed instantly. Instead I want the script to be able to store the time that the person put in and later when they type a command to arm it then it would be able to arm then blow up after their time they set. Thats my problem. I dont know how to keep the data in their long enough so whenever I get to the function that actually arms the bomb and is about to blow up It does not know what the time setting is and it comes up with nil. triggerevent would not apply due to the fact that it would instantly trigger the function that arms the bomb. and the person would not even type the arm command. Im sorry if this comes unclear lol. Kind of hard to explain Link to comment
50p Posted September 25, 2009 Share Posted September 25, 2009 I see you have a custom event which is clientSetTimeBomb. - Do you trigger it from client script? - How do you trigger that event? (Show the line of code) - Where do you get nil? (which line?) - Do you have a text box where user types in the time? If so, why don't you send text from that text box to server with triggerServerEvent? Give more info. Do you even know what parameters addCommandHandler needs? Use wiki, PLEASE. There are a few ways of storing data. You can use setElementData or tables. setElementData( somePlayer, "bomb_time", 12345 ); -- or someTable = { } someTable[ somePlayer ] = 12345; -- then use one of them, getElementData or that table local time = someTable[ somePlayer ]; -- or local time = getElementData( somePlayer, "bomb_time" ); setTimer( blowVehicle, time, 1, vehicle ); Link to comment
jkub Posted September 29, 2009 Author Share Posted September 29, 2009 Thanks:) I tried this and studied some other scripts closely to get more understanding of the elementData part I can use to define the time settings. I went ahead and did a collision sensor thingy with this and it works! ( with 1 small bug ) Thanks Ive also rewrote the gui to where all gui clicks are on one function. Looks much neater now 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