newtimes Posted May 14, 2011 Share Posted May 14, 2011 Hi, I'm editing the MTA PARADISE game mode (just to practice scripting in lua files) bud now i wan't to create a Payday script so i got an script from the resource page and i hoped i could fix it as i want it bud i noticed i fail what do i want : the characters will get a payday of 10% over their bank account function allPlayersPayDay() local result = exports.sql:query_assoc( "SELECT * FROM bank_accounts WHERE charactid IS player" ) local allPlayers = getElementsByType("player") for index,value in ipairs(allPlayers) do givePlayerMoney ( value, ") outputChatBox (" ------Payslip------ ", value, 255, 255, 255, false) outputChatBox ("|--------------------------|", value, 0, 255, 00, false) outputChatBox (", value, 0, 255, 0, false) outputChatBox ("", value, 255, 0, 0, false) outputChatBox ("|--------------------------|", value, 0, 255,00 , false) end end function onResourceStart(thisResource) setTimer ( allPlayersPayDay, 480000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) so now i fail at the part how to get 10% (or something) and give it to players thanks for reading Link to comment
karlis Posted May 14, 2011 Share Posted May 14, 2011 givePlayerMoney ( value, cash) --you have to specify amount of cash given im not familiar with MySQL, but if results variable is table containing the player bank account info, use (as i read, the key of table is player itself) givePlayerMoney ( value, result[value]*0.1) EDIT:also 1 ' " ' is missing in line 8. Link to comment
newtimes Posted May 14, 2011 Author Share Posted May 14, 2011 thanks for the reply i did that now i'm up with an error ERROR: payday\payday.lua:6: attempt to index local 'result' (a boolean value) my code now : function allPlayersPayDay() local result = exports.sql:query_assoc( "SELECT * FROM bank_accounts WHERE charactid IS player" ) local allPlayers = getElementsByType("player") for index,value in ipairs(allPlayers) do givePlayerMoney ( value, result[value]*0.1) outputChatBox (" ------Payslip------ ", value, 255, 255, 255, false) outputChatBox ("|--------------------------|", value, 0, 255, 00, false) outputChatBox ("You just got 10 percent of your bank value!", value , 0, 255, 0, false) outputChatBox ("-2$ Tax", value, 255, 0, 0, false) outputChatBox ("|--------------------------|", value, 0, 255,00 , false) end end function onResourceStart(thisResource) setTimer ( allPlayersPayDay, 40000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) Link to comment
karlis Posted May 14, 2011 Share Posted May 14, 2011 i said, thats in case "result" is a table, but seems its boolean(true/false) as it would be no sense to be true, its false, and that means getting the mySQL results failed. sorry, need someone else to help you with MySQL, thats out of my knowledge. Link to comment
newtimes Posted May 14, 2011 Author Share Posted May 14, 2011 i said, thats in case "result" is a table, but seems its boolean(true/false)as it would be no sense to be true, its false, and that means getting the mySQL results failed. sorry, need someone else to help you with MySQL, thats out of my knowledge. ah ok thanks anyway i'll just wait for someone to help me Link to comment
Moderators Citizen Posted May 14, 2011 Moderators Share Posted May 14, 2011 Mmmm maybe it's a stupid question but do you have installed a mysql server ? ( like wamp, easyPHP, ... ) Because without that, you can't make any mysql functions Link to comment
newtimes Posted May 15, 2011 Author Share Posted May 15, 2011 Mmmm maybe it's a stupid question but do you have installed a mysql server ? ( like wamp, easyPHP, ... )Because without that, you can't make any mysql functions the whole paradise roleplay is successful installed i have at the moment a localhosted server on my pc just to test i'm using navicat + Mysql 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