Jump to content

Patrick

Moderators
  • Posts

    1,143
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by Patrick

  1. I am not sure, but I think this is worse, because the loop check all players on the server. My script is check only players which near to you. (I don't know which better)
  2. You save a bool value to elementdata and not the old skin id. -- enter to job setElementData(player, "astronaut:Skin", getElementModel(player)) -- save old setElementModel(player, 264) -- leave job setElementModel(player, getElementData(player, "astronaut:Skin")) -- load back removeElementData(player, "astronaut:Skin")
  3. Yes, there are many, but there is no better solution. Only the images.
  4. At the onVehicleStartEnter event source is the vehicle and not the player. The event first argument is the player. addEventHandler ("onVehicleStartEnter", getRootElement(), function(enteringPlayer) bindKey (enteringPlayer, "j", "down", engine) end)
  5. Patrick

    Gui Theme

    You can't modify client's gui theme.
  6. Impossible. I think one of your resources is modify it.
  7. I can't belive that. addEventHandler("onClientVehicleDamage", root, function(_, wpn) if wpn ~= 51 then -- explosive cancelEvent() end end) Try that.
  8. I missed. If you want to block all damage and enable only the rockets, place a not before explosiveWeapon[wpn] at line 13. if not explosiveWeapon[wpn] then
  9. Patrick

    setTimer help

    I think the first problem is, the source is not definied before setTimer. The second problem, you need to trigger the getArmour event, because this function using source and not the function's first argument. Somethink like that: playerElement = getPlayerFromName("Asmgol") setTimer(function() triggerEvent("getArmour", playerElement) end, 1000, 1)
  10. I don't know why, but if I shoot the vehicle with rocket laucher it get damage by weapon id 51. But weapon with id 51 is not exists. (51 is the explosion's damage id) local explosiveWeapon = { [16] = true, [18] = true, [35] = true, [36] = true, [37] = true, -- fire [39] = true, [51] = true, -- explosion } addEventHandler("onClientVehicleDamage", root, function(_, wpn) if explosiveWeapon[wpn] then cancelEvent() end end)
  11. Ha van egy táblázatod, amiben a megállók helyei vannak, akkor csináld azt, hogy az adott táblában sorban adod meg a megállókat, úgy ahogy haladnia kell. (Neked ez a busStops tábla) Ilyenkor az első sor lesz az első megálló. A második a második megálló.. stb. Ezután már csak valahol számolnod kell, hogy melyik megállónál tart. (Valószínűleg elementdata, de client oldalon lehet egy szimpla változó is.) Megnéztem a csatornáját és ebben a videóban részben megtalálsz megoldást is. https://www.youtube.com/watch?v=WQChPqJo-28
  12. local id_farm = {} local farmdata = {} local dbpTime = 500 local ids = 0 function CreateFarm(dbRow) local id = dbRow['ID'] id_farm[id] = createColSphere(row['Posx'],row['Posy'],row['Posz'], 1.5) setElementData(id_farm[id], "farm", true) farmdata[id] = dbRow -- paste all database data to farmdata table. farmdata[id]["infocols"] = createColSphere(dbRow['Posxinf'], dbRow['Posyinf'], dbRow['Poszinf'], 1.5) farmdata[id]["Combaine"] = createVehicle(532, dbRow['532x'], dbRow['532y'], dbRow['532z']) createPickup(row['Posx'],row['Posy'],row['Posz'], 3, 1318, 100) createPickup(row['Posxinf'],row['Posyinf'],row['Poszinf'], 3, 1239, 100) createBlip(row['Posx'],row['Posy'],row['Posz'], 56, 2, 255, 0, 0, 255, 0, 250) addEventHandle("onVehicleStartEnter", farmdata[id]["Combaine"], function(thePlayer) -- start to enter to Combaine if id ~= getElementData(thePlayer,"fjobs") then cancelEvent() -- cancel the event and not enter outputChatBox("Вы не фермер!", thePlayer, 255, 255, 255, true) -- info return end if farmdata[id]["CornPlant"] ~= 0 then cancelEvent() -- cancel the event and not enter outputChatBox("На поле достаточно урожая!", thePlayer, 255, 255, 255, true) -- info else triggerClientEvent(thePlayer, "Go_plan_corn", thePlayer, "create") end end) addEventHandler("onColShapeHit", farmdata[id]["infocols"], function(hitElement) if (getElementType(hitElement) == "player") and (getElementData(hitElement, "online") == 1) then triggerClientEvent(hitElement, "Show_infof", hitElement, dbRow['ID'], dbRow["Owner"], dbRow["zOwner1"], dbRow["zOwner2"], dbRow["zOwner3"], dbRow["Farmer1"], dbRow["Farmer2"], dbRow["Farmer3"], dbRow["Farmer4"], dbRow["Farmer5"], dbRow["Balance"], dbRow["PriceJob"], dbRow["BuyCorn"], dbRow["CornSklad"], dbRow["CornPlant"], dbRow["SellProd"], dbRow["ProdSklad"], dbRow["PriceProd"]) end end) addEventHandler("onColShapeLeave", farmdata[id]["infocols"], function(hitElement) if (getElementType(hitElement) == "player") and (getElementData(hitElement, "online") == 1) then triggerClientEvent(hitElement, "Show_informfarm", hitElement) end end) outputServerLog("Farm number "..id.." is loaded!") end addEvent("farms_stop",true) addEventHandler("farms_stop", root, function(id) local vehicle = getPedOccupiedVehicle(client) if vehicle then removePedFromVehicle(client) respawnVehicle(vehicle, false) end outputChatBox("Вы успешно накосили урожай!", client, 255, 255, 255, true) if (farmdata[id]["CornSklad"] < 5000) and farmdata[id]["CornPlant"] == 0 then farmdata[id]["CornPlant"] = farmdata[id]["CornSklad"] farmdata[id]["CornSklad"] = 0 elseif farmdata[id]["CornSklad"] >= 5000 and farmdata[id]["CornPlant"] == 0 then farmdata[id]["CornPlant"] = 5000 farmdata[id]["CornSklad"] = farmdata[id]["CornSklad"]-5000 end end) -- Place the load function end of the script, almost always function loadfarm() outputServerLog("_________________Load to farm_________________") local query = dbQuery(connect_db, "SELECT * FROM farm;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then for _, row in ipairs(result) do CreateFarm(row) end dbFree(query) else outputServerLog("Houses Table not Found/empty!") end outputServerLog("Farm load: "..numrows) outputServerLog("_________________End Load to farm_________________") end addEventHandler("onResourceStart", resourceRoot, loadfarm) You need to modify the client side, when you trigger the farms_stop event, you need to send the farm's ID back. (It's not working 100%, but you can to compare with your code and find your faults.)
  13. This is a client side script.
  14. local startMarker = createMarker(0,0,3, "cylinder", 1, 0, 255, 0) -- The start marker (Here you can change the marker's position and color) local endMarker = createMarker(0,10,3, "cylinder", 1, 255, 0, 0) -- The end marker (Here you can change the marker's position and color) local sx, sy = guiGetScreenSize() function renderTime() local currentTime = getTickCount() local elapsedTime = (currentTime - startTime) / 1000 dxDrawText(elapsedTime, 0, 0, sx, sy/4, tocolor(255,255,255,255), 2, "default-bold", "center", "center") end addEventHandler("onClientMarkerHit", startMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to startMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- timer already started, need to reset it startTime = getTickCount() else -- timer not running, you need to start the onClientRender and display time on client's screen started = true startTime = getTickCount() addEventHandler("onClientRender", root, renderTime) end end end) addEventHandler("onClientMarkerHit", endMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to endMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- if the timer is running need to stop it. local currentTime = getTickCount() local elapsedTime = currentTime - startTime outputChatBox("Your time is: " .. elapsedTime) removeEventHandler("onClientRender", root, renderTime) started = false end end end)
  15. local sx, sy = guiGetScreenSize() function renderTime() local currentTime = getTickCount() local elapsedTime = (currentTime - startTime) / 1000 dxDrawText(elapsedTime, 0, 0, sx, sy/4, tocolor(255,255,255,255), 2, "default-bold", "center", "center") end addEventHandler("onClientMarkerHit", startMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to startMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- timer already started, need to reset it startTime = getTickCount() else -- timer not running, you need to start the onClientRender and display time on client's screen started = true startTime = getTickCount() addEventHandler("onClientRender", root, renderTime) end end end) addEventHandler("onClientMarkerHit", endMarker, function(hitPlayer, matchingDimension) -- Attach onClientMarkerHit event to endMarker if hitPlayer == localPlayer and matchingDimension then -- You need the check the player who hit the marker is the client. AND localPlayers's dimension is matching with marker's dimension if started then -- if the timer is running need to stop it. local currentTime = getTickCount() local elapsedTime = currentTime - startTime outputChatBox("Your time is: " .. elapsedTime) removeEventHandler("onClientRender", root, renderTime) started = false end end end)
  16. Every walking style have different "sneak style".
  17. Same, how you calculate the blip's position. But try to download a radar from community and see in it
  18. You can change the face's texture only. https://wiki.multitheftauto.com/wiki/EngineApplyShaderToWorldTexture
  19. Patrick

    Ped Chasing

    Maybe try something like that: -- CLIENT SIDE addEventHandler("onClientPedDamage", getRootElement(), function(attacker) if attacker == localPlayer then triggerServerEvent("startFollow", localPlayer, source, localPlayer) end end) -- SERVER SIDE local ped = createPed(0, 0, 0, 3) function startFollow(pedElement, playerElement) if isElement(pedElement) then setPedAnimation(pedElement, "muscular", "musclerun") setTimer(function() local x1, y1 = getElementPosition(playerElement) local x2, y2 = getElementPosition(pedElement) local rot = findRotation( x2, y2, x1, y1 ) setPedRotation(pedElement, rot) end, 250, 0) end end addEvent("startFollow", true) addEventHandler("startFollow", root, startFollow) function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end
×
×
  • Create New...