Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Hale last won the day on June 21 2017

Hale had the most liked content!


About Hale

  • Birthday 11/12/1990


  • Gang
  • Location
  • Occupation
    Electrical Engineering
  • Interests
    Lua programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Hale's Achievements


Mark (16/54)



  1. The client side part isn't needed at all, use giveWeapon server side: function NemesisTest ( ) nemesistest = exports [ "slothBot" ]:spawnBot ( 1129, -1489, 22.8, 90, 100, 0, 0, NemesisTest, 35, "hunting", true ) -- nemesistestc= exports [ "dxmessages" ]:outputDx(root,"BOSS TEST SPAWN","warning") -- baz = createObject ( 360, 622.4934082031, -847.33459472656, 75.0484313964, 0, 0, 0 ) -- attachElements ( baz, nemesistest, 0.2, 0.1, 0.5, 0, 90, 0 ) giveWeapon(nemesistest, 35, 500, true) BlipNemesisTest = createBlipAttachedTo ( nemesistest, 23 ) -- triggerClientEvent ( root, "BossSpawn", root ) -- setElementData(nemesistest, "nemesistest",true) outputChatBox ( "BOSS TEST SPAWN",getRootElement(), 0, 255, 0, true ) if nemesistest then exports.extra_health:setElementExtraHealth ( nemesistest, 1 ) end end
  2. Hale

    Vehicle Blips

    Use the same idea Tails showed you. Put police skins in a table, loop through it and check if the localPlayer has any of the police skins with getElementModel.
  3. Hale

    Vehicle Blips

    Simply use getElementModel, for example: --This function creates a blip for all currently streamed-in vehicles when the resource starts. local function resourceStart() for _, vehicle in ipairs(getElementsByType("vehicle"), root, true) do if vehicle ~= getPedOccupiedVehicle(localPlayer) then if getElementModel(vehicle) == 596 then local blip = createBlipAttachedTo(vehicle, 0, 1, 150, 150, 150, 255, -10, 300) setElementParent(blip, vehicleBlipRoot) end end end end addEventHandler("onClientResourceStart", root, resourceStart)
  4. In that "convertDX" event handler, add another event handler that will make the DX show. Here's an example: addEvent("convertDX", true) addEventHandler("convertDX", getRootElement(), function(window) guiSetAlpha(window,0) addEventHandler("onClientRender", localPlayer, drawDX) end) function drawDX() --all the drawings go here end
  5. Hale

    lua problem

    Can you please send us the function that is triggering "addPlayerToGroup" event? We don't know what's being sent as arguments.
  6. dbExec isn't supposed to return anything. You aren't using dbExec properly, please open the function in wiki and carefully read it (Usage of '?' and '??'). dbPoll returns a second argument, which is the number of affected rows. Again, read more about it on wiki, there are good examples on how to use it as well.
  7. You should really inform yourself more of how Lua works in MTA before going onto something like this. The code I provided doesn't go in any of these, like I said it should go in a different file, where the onCharacterLogOut function is. If this doesn't work, try going client-side and use onClientPlayerDamage event, which will trigger a function that triggers a server event that then triggers the function that has setPedStat in it. I made it complicated for a reason, once you understand what I wrote you'll be ready to make this work.
  8. You can use: if TruckVehiclesTable[truckElement] and isElement(TruckVehiclesTable[truckElement]) and getElementType(TruckVehiclesTable[truckElement]) == "vehicle" then destroyElement(TruckVehiclesTable[truckElement]) end
  9. Never actually thought of such way, nicely done mate!
  10. Here's an example: local x, y, z = getElementPosition(TruckVehiclesTable[truckElement]) trailer = createVehicle(515, x, y, z) attachTrailerToVehicle(TruckVehiclesTable[truckElement], trailer) I suggest you also put created trailer into a table so you can easily delete it.
  11. Hello to whoever is reading this topic, today I've decided to take some time and explain in (personally) easiest possible way how to make a drawing or a GUI that will fit all resolutions, no matter if it's 1280x1024 or 640x480. Here are the following steps: Let's say you're using 1280x1024 resolution. You have the following function: dxDrawText("$10000000", 990, 200, 1100, 250, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") Take out the positionings from the function: 990, 200, 1100, 250 Divide 1280 with X positions (990, 1100) separately. You'll get 1280/990=1.292929 and 1280/1100=1.16363 Do the same with Y positions, but use 1024 as that is maximum height (aka Y of the screen). You'll get 1024/200=5.12 and 1024/250=4.096 The numbers you got are the scales that will work in every resolution as they work in your resolution (1280x1024). To use those scales, simply divide the clients' resolution with the scale, for example: screenWidth, screenHeight = guiGetScreenSize() dxDrawText("$10000000", screenWidth/1.292929, screenHeight/5.12, screenWidth/1.16363, screenHeight/4.096, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") That's it! There's an extra scaling you can do for text size, which is tricky to work with (due to text getting blurred, ugly and unreadable) but if you're up for it: screenWidth, screenHeight = guiGetScreenSize() scale = (screenWidth/1280)*(screenHeight/1024) -- this will give you a number that will vary around 1, depending on clients' resolution (if resolution is smaller, scale will be below 1, if higher then above 1) dxDrawText("$10000000", screenWidth/1.292929, screenHeight/5.12, screenWidth/1.16363, screenHeight/4.096, tocolor ( 0, 0, 0, 255 ), scale*1, "pricedown") -- as you can see I multiplied the text size (1) with the scale, which means the text will be bigger or smaller (again, depending on the clients' screen resolution) Hope I helped, please provide some feedback for future references!
  12. He understood you, you don't understand him. Please refer to this post:
  13. The reason you cannot destroy the blip that's attached to the destination marker is that that blip is defined as local in another function, simply remove local and you'll be able to delete it. Similar goes for the marker, if you want it spawned once the truck is spawned, simply make the marker spawn once that function is triggered, here's an example: startdelmark = createMarker( 211.39999389648, 1809.5, 16.60000038147, "cylinder", 3, 42, 214, 153, 100 ) --spawns truck from here. local myBlip = createBlipAttachedTo ( startdelmark, 51 ) --blip on the spawn marker. delivmark = nil local deliverBlip = nil TruckVehiclesTable = {} function spawntruck (truckElement) if ( isElement(truckElement) and getElementType(truckElement) == 'player' ) then local truckVeh = getPedOccupiedVehicle(truckElement) local x, y, z = getElementPosition (truckElement) local rotX, rotY, rotZ = getElementRotation (truckElement) TruckVehiclesTable[truckElement] = createVehicle (515, x-5, y, z+2) setElementRotation (TruckVehiclesTable[truckElement], rotX, rotY, 90) warpPedIntoVehicle (truckElement, TruckVehiclesTable[truckElement]) delivmark = createMarker(-1355.6999511719, -506.20001220703, 13.10000038147, "cylinder", 3, 42, 214, 153, 100) --this is the location. deliverBlip = createBlipAttachedTo ( delivmark, 52 ) --the blip I want on the destination marker. setBlipSize ( myBlip, 1 ) outputChatBox ("You have took on the role of goods courier, deliver the goods to the dollar blip to get your reward", truckElement, 0, 255, 0) outputChatBox ("Do NOT leave the vehicle or it will be destroyed and your mission will fail!", truckElement, 255, 0, 0) end end addEventHandler("onMarkerHit", startdelmark, spawntruck) You'll need to be more detailed about your last question, in what table are the trailers, how do you want them to spawn etc. Hope I helped.
  14. You didn't really define what do you want to do. The provided code looks fine so if I got it right you want to update player's (his character actually) weapon stat in an SQL table? If so, simply add (and adjust if needed) the following code into the function that handles player logging out of his character: function onCharacterLogOut(player) -- just an example --normal code goes first, that you already should have local uzi_stat = getPedStat(player, 75) local mp5_stat = getPedStat(player, 76) local query = mysql:query_free("UPDATE `character-system` SET `uzi_skill`=" .. mysql:escape_string(uzi_stat) .. ", `mp5_skill`=" .. mysql:escape_string(mp5_stat) .. " WHERE id=" .. mysql:escape_string(getElementData(player, "dbid"))) if not query then outputDebugString("Failed saving weapon stats for " .. getPlayerName(player), 2) end end
  • Create New...