Ernis456 Posted April 21, 2010 Share Posted April 21, 2010 How can I make gates automatic opening and opening with command ? Link to comment
Callum Posted April 21, 2010 Share Posted April 21, 2010 By scripting them, of course. You could try https://community.multitheftauto.com/index.php?p= ... ils&id=614 or make your own. Link to comment
Ernis456 Posted April 21, 2010 Author Share Posted April 21, 2010 (edited) What lua code to make gates on my own ? Another question. How to make payday ? e.g. Every 20 minutes player gets 3 000 $ How to do car reserved to job. e.g. Only cops can drive Police car. Edited April 21, 2010 by Guest Link to comment
dzek (varez) Posted April 21, 2010 Share Posted April 21, 2010 list: [click function name to get to wiki] addCommandHandler moveObject createObject hmm.. its all i think Link to comment
Ernis456 Posted April 21, 2010 Author Share Posted April 21, 2010 Thanx. Another question. How to make payday ? e.g. Every 20 minutes player gets 3 000 $ How to do car reserved to job. e.g. Only cops can drive Police car. Link to comment
Jason_Gregory Posted April 21, 2010 Share Posted April 21, 2010 function payDay(money) local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do givePlayerMoney(thePlayer, tonumber(money)) end end Simply use a Timer with the payDay Function. Link to comment
dzek (varez) Posted April 21, 2010 Share Posted April 21, 2010 Another question. I see two questions:P How to make payday ? e.g. Every 20 minutes player gets 3 000 $ setTimer getElementsByType("player") givePlayerMoney but payday script is on community How to do car reserved to job. e.g. Only cops can drive Police car. -- use event onVehicleStartEnter with addEventHandler -- and in handler function get the vehicle model id getElementModel -- and check if the id is one of police cars -- if yes, check if the player model id getElementModel -- is the cop id -- if NOT do cancelEvent() and now, FANFARES edit: of course before cancelling the event you can output something to the players chatbox, so players won't get confused, why enter key isn't working Link to comment
Ernis456 Posted April 23, 2010 Author Share Posted April 23, 2010 I have problem. When I run my script Payday: function PayDay ( text ) givePlayerMoney (thePlayer, 3000 ) end setTimer ( PayDay, 3000, 1, "PayDay 3 000 $ ! " ) I getting error in console : WARNING: payday.lua: Bad argument @ 'givePlayerMoney' - Line: 2 Link to comment
Taalasmaa Posted April 23, 2010 Share Posted April 23, 2010 -- func -- time -- repeat -- money setTimer ( PayDay, 3000, 1, 3000 ) function payDay(money) local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do givePlayerMoney(thePlayer, tonumber(money)) outputChatBox("It's your payday, you've received 3000$",thePlayer,255,255,0) end end should work Link to comment
dzek (varez) Posted April 23, 2010 Share Posted April 23, 2010 I have problem.When I run my script Payday: function PayDay ( text ) givePlayerMoney (thePlayer, 3000 ) end setTimer ( PayDay, 3000, 1, "PayDay 3 000 $ ! " ) I getting error in console : WARNING: payday.lua: Bad argument @ 'givePlayerMoney' - Line: 2 your script.. its totally random! you just ignored getElementsByType("player") (i told you about that) and you are passing text that you dont use, and you are using unexisting variables (thePlayer) here's the code (hope you will think on it, not just copy and paste) function PayDay(howMuch) local playerList = getElementsByType("player") -- we are getting all players for key,val in ipairs(playersList) do -- we are looping through all players -- val is one of the players givePlayerMoney(val, howMuch) -- we give howMuch variable, passed in setTimer end outputChatBox("Payday: $"..howMuch) -- we are outputting chatbox message to everyone on the server end local mins = 30 -- every X minutes payday will be done local howMuch = 1000 -- we are setting variable defining the money to give -- we are setting timer (check: [url=https://wiki.multitheftauto.com/wiki/SetTimer]https://wiki.multitheftauto.com/wiki/SetTimer[/url]) setTimer(PayDay, mins*60*1000, 0, howMuch) -- function | time (in ms!, that why its multiplied by 1000 and 60 (1000ms = 1 sec, 1 sec*60 = 1 min, and mins(30)*1 min = 30mins) | infinite repeating | how much money to give Link to comment
dzek (varez) Posted April 23, 2010 Share Posted April 23, 2010 setTimer ( PayDay, 3000, 1, 3000 ) -- CUT should work yea, but it will be giving it every 3 secs in that one i think author confused time and money in setting timer Link to comment
Ernis456 Posted April 23, 2010 Author Share Posted April 23, 2010 function PayDay(howMuch) local playerList = getElementsByType("player") for key,val in ipairs(playersList) do givePlayerMoney(val, howMuch) end outputChatBox("Payday: $"..howMuch) end local mins = 1 local howMuch = 3000 setTimer(PayDay, mins*60*1000, 0, howMuch) error : payday.lua:3: bad argument #1 to 'ipairs' (table expected, got nil) How can I fix it ? 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