Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Use getPlayerNametagColor and this useful function (REMEMBER TO COPY SOURCE CODE): https://wiki.multitheftauto.com/wiki/RGBToHex
  2. You can disable weapon reloading aswell.
  3. Disable the "fire" control with toggleControl.
  4. That's because getPlayerFromParticalName is not defined. Add this function to the end of the script: function getPlayerFromParticalName (name) -- BY TAPL local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end
  5. Check debugscript for errors.
  6. The problem is that you are trying to make getData return a value it doesn't have, the callback function has the value.
  7. The second code is right, and it should work. What do you mean by "nothing happened"? is the money being sent to the player?
  8. This will get the first result in the table: result [ 1 ] [ db_row ]
  9. Create a sub-table using the player element as index. if ( not ignorePlayers [ thePlayer ] ) then ignorePlayers [ thePlayer ] = { } end table.insert ( ignorePlayers [ thePlayer ], playerIgnored )
  10. You shouldn't be connecting to MySQL everytime you want to retrive data, make a single connection and then use the connection handler for the rest of the functions.
  11. Same problem .. local myFont = guiCreateFont( "Font.ttf", 2 ) if myFont == false then local myFont = guiCreateFont( "Font.ttf", 2 ) end "myFont" is defined as a local variable, it doesn't exist outside that 'if' condition.
  12. Castillo

    Help

    I really don't understand the problem. By the way, why are you using tostring for the numbers? createMarker uses numbers. Also, this will give you an error: tostring(v[3])-1
  13. He's talking about object models, not IDs. @NadhmiNK: You can loop through all objects, check if their model is the one you want, and then disable the collisions.
  14. You could instead, send the serial of the player, and create a function to get the player element from the serial.
  15. Eso solo funcionara si la "gang" es "SWAT". if ( myself == otherguy ) then Con eso te funcionara para todas las gangs.
  16. And how does that help with anything? you are supposed to check if 'balance' is the right value.
  17. Did what exactly? did you even understand what I told you to do?
  18. Por lo que leo ahi, te ofrecio devolverte el dinero si no podian restaurar el medio de pago. No se bien si era eso cierto, pero ninguna de las "pruebas" que publicaste hacen quedar mal a la compañia.
  19. Debug the script, see what is not working, if the deposit/withdraw part, or the loading part ( onPlayerLogin ).
  20. Can you be more specific about what "doesn't work"?
  21. If you register an event with addEvent function, then you can trigger it later with triggerEvent.
  22. triggerEvent, triggerClientEvent and triggerServerEvent are different functions, but they work pretty much the same way.
  23. You can use this function to trigger your own events, such as: -- server side: addEvent ( "onHelloCommandUsed", true ) -- Register the 'onHelloCommandUsed' event addEventHandler ( "onHelloCommandUsed", root, function ( ) outputChatBox ( getPlayerName ( source ) .." used the /hello command." ) -- Output the name of the player that used the /hello command to the chat end ) addCommandHandler ( "hello", function ( thePlayer ) triggerEvent ( "onHelloCommandUsed", thePlayer ) -- Trigger the 'onHelloCommandUsed' event end )
  24. -- client side: function depoistMoney ( ) local text = tonumber ( guiGetText ( GUIEditor.edit[2] ) ) or 0 local text2 = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) or 0 if guiRadioButtonGetSelected ( GUIEditor.radiobutton[1] ) then if ( text and getPlayerMoney ( ) >= text and text >= 0 ) then guiSetText ( GUIEditor.edit[1], "Transferring..." ) setTimer ( guiSetText, 2000, 1, GUIEditor.edit[1], tostring ( text + text2 ) ) triggerServerEvent ( "bank_deposit", localPlayer, text ) end end end function withdrawMoney ( ) local text = tonumber ( guiGetText ( GUIEditor.edit[2] ) ) or 0 local text2 = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) or 0 if guiRadioButtonGetSelected ( GUIEditor.radiobutton[2] ) then if ( text2 >= text and text > 0 ) then guiSetText ( GUIEditor.edit[1], "Transferring..." ) setTimer ( guiSetText, 2000, 1, GUIEditor.edit[1], tostring ( text2 - text ) ) triggerServerEvent ( "bank_withdraw", localPlayer, text ) end end end -- server side: addEventHandler ( "onPlayerLogin", getRootElement(), function ( _, account ) if ( not isGuestAccount ( account ) ) then local balance = tonumber ( getAccountData ( account, "bankmoney" ) ) or 0 setElementData ( source, "bankmoney", balance ) end end ) function bank_deposit ( text ) if ( text > 0 ) then local moneyBank = getAccountData ( getPlayerAccount ( source ), "bankmoney" ) local newBalance = ( moneyBank + text ) takePlayerMoney ( source, text ) exports [ 'SAEGMessages' ]:sendClientMessage ( "You have deposited $".. text .." to your bank account", source, 200, 200, 200 ) setAccountData ( getPlayerAccount ( source ), "bankmoney", newBalance ) setElementData ( source, "bankmoney", newBalance ) else exports [ 'SAEGMessages' ]:sendClientMessage ( "You don't have enough money to deposit $".. text .." to your bank account.", source, 200, 200, 200 ) end end addEvent ( "bank_deposit", true ) addEventHandler ( "bank_deposit", root, bank_deposit ) function bank_withdraw ( text ) if ( text > 0 ) then local moneyBank = getAccountData ( getPlayerAccount ( source ), "bankmoney" ) local newBalance = ( moneyBank - text ) givePlayerMoney ( source, text ) exports [ 'SAEGMessages' ]:sendClientMessage ( "You have withdrawn $".. text .." from your bank account", source, 200, 200, 200 ) setAccountData ( getPlayerAccount ( source ), "bankmoney", newBalance ) setElementData ( source, "bankmoney", newBalance ) else exports [ 'SAEGMessages' ]:sendClientMessage ( "You don't have enough money in your bank account to withdraw $".. text ..".", source, 200, 200, 200 ) end end addEvent ( "bank_withdraw", true ) addEventHandler ( "bank_withdraw", root, bank_withdraw ) I have removed the onPlayerQuit/Logout events, since you set the account data on deposit/withdraw, so there should be no need to save it again.
×
×
  • Create New...