Jump to content

xXMADEXx

Members
  • Posts

    2,718
  • Joined

  • Last visited

Everything posted by xXMADEXx

  1. You could do something like this: money.php -- Your PHP Code <?php if ( isset ( $_GET['m'] ) && isset ( $_GET['a'] ) ) { $money = $_GET['m']; $account = $_GET['a']; include "mta/mta_sdk.php"; $mta = new mta ( "server ip", port, username, password ); $mta->getResource("PHP_Callback")->call("giveTheMoneyToAccount", $account, $money ); } ?> Lua: -- for PHP_Callback resource -- make sure to export "giveTheMoneyToAccount" on http also -- function giveTheMoneyToAccount ( account, money ) for i, v in pairs ( getElementsByType ( "player" ) ) do local a = getPlayerAccount ( v ) if ( not isGuestAccount ( a ) and getAccountName ( a ) == acount ) then givePlayerMoney ( v, money ) return true end end return false end and the url would be: http://yourwebsite/money.php?a=accountName&m=1000
  2. you can just open the gps resource script to see how it works.
  3. Try to use this (client): function loadHandler(button, state) if button == "left" and state == "up" then local row, col = guiGridListGetSelectedItem(glistLoadList) local startpos = guiGridListGetItemData(glistLoadList, row, 2) local endpos = guiGridListGetItemData(glistLoadList, row, 3) local cash_ = guiGridListGetItemData(glistLoadList, row, 4) if row and col and row ~= -1 and col ~=-1 then startx, starty, startz = unpack(startpos) endx, endy, endz = unpack(endpos) cash = unpack(cash_) createLoadStart() end end end function createLoadStart() startMarker = createMarker(startx, starty, startz, "checkpoint", 7) startBlip = createBlip(startx, starty, startz, 0, 2, 0, 0, 255) hideLoad() end function startLoading() local vehicle = getPedOccupiedVehicle(localPlayer) if isElementWithinMarker(localPlayer, startMarker) then if vehicle then if (getElementModel(vehicle)) == 403 or (getElementModel(vehicle)) == 515 or (getElementModel(vehicle)) == 514 then trailer = createVehicle(435, -99, -57, 3.5, 0, 0, 167) guiSetText(lblLoading, "Loading...") guiSetVisible(lblLoading, true) attachTrailerToVehicle(vehicle, trailer) setElementFrozen(vehicle, true) setTimer(function () guiSetVisible(lblLoading, false) setElementFrozen(vehicle, false) end, 10*1000, 1) destroyElement(startMarker) destroyElement(startBlip) endMarker = createMarker(endx, endy, endz, "checkpoint", 7) endBlip = createBlip(endx, endy, endz, 0, 2, 255, 0, 0) end else outputChatBox("You need to be in some sort of 18 Wheeler to take a job.", localPlayer) end else outputChatBox("You need to be in the load marker to get the trailer.", localPlayer) end end addCommandHandler("load", startLoading) function startUnLoading() local person = localPlayer local vehicle = getPedOccupiedVehicle(localPlayer) if isElementWithinMarker(localPlayer, endMarker) then if vehicle then if getVehicleTowingVehicle(trailer) == vehicle then guiSetText(lblLoading, "Unloading...") guiSetVisible(lblLoading, true) setElementFrozen(vehicle, true) setTimer(function () guiSetVisible(lblLoading, false) setElementFrozen(vehicle, false) detachTrailerFromVehicle(vehicle) destroyElement(trailer) end, 10*1000, 1) destroyElement(endMarker) destroyElement(endBlip) triggerServerEvent("finishRoute", localPlayer, person, cash) end end else outputChatBox("You need to be in the unload marker to unload the trailer.", localPlayer) end end addCommandHandler("unload", startUnLoading) and if it still isn't working, put this for the server side and tell me the results: function finishLoad(person, cash) outputChatBox ( tostring ( cash ) ) givePlayerMoney(person, tonumber(cash)) end addEvent("finishRoute", true) addEventHandler("finishRoute", root, finishLoad)
  4. Rather than scanning the database evertime a player joins or something, I would make a table that manages everything, and then updated the database when the resource is stopped. When the resource is started, then put all of the data into the table.
  5. xXMADEXx

    [HELP] Please

    setElementBlood isn't a function of MultiTheftAuto, and players can only have health on between 0-100. Use this as the loop: for _, p in pairs ( alivePlayers ) do setElementHealth ( p, 100 ) outputChatBox("Server: Your blood was restored to full by an Admin!", p, 0, 255, 0) end
  6. Thanks for the idea, I'll add that right away!
  7. You can try this: local pBlips = {} function onSpawn ( p ) if ( not source or not isElement ( source ) and p and isElement ( p ) ) then source = p end takeAllWeapons ( source ) setPlayerMoney ( source, 0 ) giveWeapon ( source, 24, 100 ) setPedStat ( source, 73, 1000 ) setPedStat ( source, 75, 1000 ) setPedStat ( source, 71, 1000 ) setPedStat ( source, 75, 1000 ) setPedStat ( source, 77, 1000 ) setPedStat ( source, 78, 1000 ) giveWeapon ( source, 26, 100 ) giveWeapon ( source, 32, 100 ) giveWeapon ( source, 31, 150 ) giveWeapon ( source, 46, 200 ) givePlayerMoney ( source, 5000 ) local playerTeam = getPlayerTeam(source) if (playerTeam) and not pBlips[source] then local r, g, b = getTeamColor(playerTeam) local myBlip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) pBlips[source] = myBlip elseif pBlips[source] then destroyPlayerBlip(source) end end function destroyPlayerBlip(pElement) local theElement = source or pElement if pBlips[theElement] then destroyElement(pBlips[theElement]) pBlips[theElement] = nil end end addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) addEventHandler("onPlayerWasted", getRootElement(), destroyPlayerBlip) addEventHandler("onPlayerQuit", getRootElement(), destroyPlayerBlip) addEventHandler ( 'onResourceStart', resourceRoot, function ( ) for _, p in pairs ( getElementsByType ( "player" ) ) do onSpawn ( p ) end end )
  8. go head and try this local busMarker = createMarker(1813.21045, -1900.71777, 12.57342, "cylinder", 1, 255, 255, 255) local busBlip = createBlip(1778.73706, -1907.69165, 13.38839,56) local busTeam = createTeam("Bus Drivers", 0, 255, 0) function onMarkerHit( player ) if source == busMarker then setPlayerTeam ( player, busTeam ) end end addEventHandler( "onMarkerHit", busMarker, onMarkerHit ) "~=" is the exact opposite of "==". It means if they are not equal then continue.
  9. Don't check Console for errors, use /debugscript 3 addEvent ( "onPlayerLevelUP", true ) addEventHandler ( "onPlayerLevelUP", root, function ( ) local playerTeam = getPlayerTeam( source ) local r, g, b = getTeamColor ( playerTeam ) local eX, eY, eZ = getElementPosition( source ) marke = createMarker ( eX, eY+5, eZ ,"corona", 5, r, g, b, 200 ) attachElements ( marke, source ) setTimer( function ( m ) destroyElement( m ) end, 6000, 1, marke) end )
  10. -- top of your script local rot = 0 -- in the render rot = rot + 1 if ( rot >= 360 ) then rot = 0 end dxDrawImage (0:44 x *, x * 0.3, 100, 100, "images/timer.png", 0,0,0, tocolor (0,255,0), rot)
  11. You need to change the texture files for them or maybe use the detail shader. https://wiki.multitheftauto.com/wiki/Shader_examples
  12. TUTORIAL/GUIDE NO LONGER MAINTAINED This tutorial is no longer maintained and it's contents may be deprecated or no longer work. I created this tutorial in 2014, when I was very involved with MTA and the community around it. Due to the nature of life, I ended up leaving MTA to focus on more important things (work, family, life, etc). I believe this tutorial has helped a lot of people get into scripting for MTA over the years, and I'm happy I was able to do answer questions and help people get into coding! Introduction Hello everyone, and thank you for viewing my introduction for Lua scripting. This tutorial will cover the basics of Lua, but nothing too advanced. This tutorial is highly detailed and should give you a pretty good understanding on how Lua works, even if you have never coded it before. Something to remember is that I do not teach or even talk about using object-oriented programming in this tutorial. Things you'll be learning: For general lua - Variables - Complete - Tables - Complete - Functions - Complete - Return - Complete - Loops - Complete - If/Else/Elseif - Complete - Usage of pre-defined variables Any type of programming - Formatting your code For mta - Create a resource and what is required for one - Complete - Events - Complete - Commands - Complete - Exports & how to call one - Complete So, now that you know what you're going to be learning about, let's get started! Variables Tables Functions Working with return inside functions Loops If/Else/Elseif Usage of pre-defined variables __________________________________________________________________________________________________ Formatting your code __________________________________________________________________________________________________ Making a resource Introduction to events Commands Exports Good luck with your Lua scripting career, I hope that this tutorial has helped you!
  13. viewtopic.php?f=91&t=26541
  14. Read this: viewtopic.php?f=91&t=26541 I learned scripting when I was either 10 or 11 (I can't really remember) so it's defiantly possible if you really want to learn. The method I used to learn how to script is download scripts from the community and just play with them a little, and add your own modifications. You should also go to: http://lua.org and https://wiki.multitheftauto.com
  15. You can use my http-modloader script for your vehicle mods. (If this doesn't work, you can use the added downloadFile resource)
  16. what does debugscript say?
  17. That wouldn't work, because the resource would have to be running on the client side for the event handler to trigger, and the resource has to be downloaded before it will start... You should use this: addEventHandler ( "onPlayerJoin", root, function ( ) fadeCamera ( source, true ) end )
  18. Oh, that probably wouldn't be possible, I think you would need a custom animation which MTA doesn't support yet.
  19. I'm actually pretty sure that the /register (not sure about /login) is part of the default admin resource. Edit: I checked the admin resource, and it should be (by default) in admin/server/admin_server.lua on lines 447-468
  20. I would just call a php code from a website, and have it query the then return it, using the php sdk.
  21. It is, as you can see with this function...
  22. You can look here http://gtag.gtagaming.com/forums/index.php?showtopic=35
  23. Use the function setPedStat and event onPlayerJoin/onPlayerLogin
×
×
  • Create New...