[YARDIM] Araçtan İnince Otomatik Silinme

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı GreeN

  • Yeni Üye
  • *
    • İleti: 24
: 28 Temmuz 2019, 20:10:54
Daha önce konu açmıştım o koddaki trailer değiştirerek vehicle denedim fakat olmadı.Sörf tahtasından inince otomatik silinsin istiyorum

« Son Düzenleme: 13 Eylül 2019, 03:06:08 Gönderen: Narkoz »
 


MTASATURK

[YARDIM] Araçtan İnince Otomatik Silinme
« : 28 Temmuz 2019, 20:10:54 »

Çevrimdışı Ky

  • Uzman Üye
  • *
    • İleti: 614
Yanıtla #1 : 31 Temmuz 2019, 13:53:08
Kodlarını atarmısın yardımcı olayım.
 


Çevrimdışı GreeN

  • Yeni Üye
  • *
    • İleti: 24
Yanıtla #2 : 03 Ağustos 2019, 09:41:37
Client:

Spoiler for Hiden:
--Below is the actual shop script that creates the markers, the blips, and the gui. this can be easily adapted to other script if you read the comments i have left. simply replace all instances of the word "surf" with whatever you want your shop to be named.

cost = 0 --The price of whatever the player is getting

--below is the initial setup
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()),
   function()
--The location of the markers and blips. you can have as many as you want, but you must change the location and the "purpose" elementdata MUST be unique
      local theMarker = createMarker ( 359.70001220703, -1910.1999511719, 0.10000000149012, "cylinder", 1, 126, 254, 0, 170 )
      setElementData ( theMarker, "purpose", "surf_shop" )
      
--the gui that allows players to say yes or no after entering a marker
      surf_shop_Window = {}
      surf_shop_Button = {}
      surf_shop_Label = {}
      surf_shop_Window1 = guiCreateWindow(0.35,0.45,0.3162,0.1717,"Sistema de Surf",true) --the title of the window i sset here
      guiWindowSetSizable(surf_shop_Window1,false)
      surf_shop_YesButton = guiCreateButton(0.087,0.5631,0.3676,0.3107,"Sim",true,surf_shop_Window1)
      surf_shop_NoButton = guiCreateButton(0.5375,0.5534,0.3676,0.3107,"Não",true,surf_shop_Window1)
      surf_shop_Label1 = guiCreateLabel(0.17,0.2524,0.668,0.2233,"Deseja comprar uma prancha de surf?" .. cost .."$",true,surf_shop_Window1)   
      surf_shop_Label1 = guiCreateLabel(553, 460, 270, 22, "Dr.Zuda - Todos os direitos reservados", false,surf_shop_Window1)   
      guiLabelSetVerticalAlign(surf_shop_Label1,"top")
      guiLabelSetHorizontalAlign(surf_shop_Label1,"left",false)
      guiSetVisible ( surf_shop_Window1, false )
      addEventHandler ( "onClientGUIClick", surf_shop_YesButton, surf_shop_Start)
      addEventHandler ( "onClientGUIClick", surf_shop_NoButton, surf_shop_Cancel)
      
--this sets the blips to be streamed out using the blipstreamer resource. (as long as blipstreamer is on, so you might want to include it in the meta)
      local blips = getElementsByType ( "blip" )
      for theKey,theBlip in ipairs(blips) do
         if (getElementData ( theBlip, "purpose" ) == "surf_shop_blip" ) then
            call(getResourceFromName"blipstreamer","setBlipStreamable",theBlip, true, 90 )
         end
      end
   end
)

--this function triggers the gui to open when a player walks into the marker
function surf_shopMarkerHit ( hitPlayer, matchingDimension )
   if (hitPlayer == getLocalPlayer()) and (isPedOnGround ( getLocalPlayer())) then
      if (getElementData ( source, "purpose" ) == "surf_shop" ) then
         if getPlayerMoney(getLocalPlayer()) >= cost then
            guiSetVisible ( surf_shop_Window1, true )
            guiBringToFront ( surf_shop_Window1 )
            showCursor ( true )   
         end
      end
   end
end
addEventHandler ( "onClientMarkerHit", getRootElement(), surf_shopMarkerHit )

--this function removes the gui if a player leaevs the marker
function surf_shopMarkerLeave ( hitPlayer, matchingDimension )
   if (hitPlayer == getLocalPlayer()) then
      if (getElementData ( source, "purpose" ) == "surf_shop" ) then
         guiSetVisible ( surf_shop_Window1, false )
         showCursor ( false )
      end
   end
end
addEventHandler ( "onClientMarkerLeave", getRootElement(), surf_shopMarkerLeave )

--this function gets triggered if a player clicks "no"
function surf_shop_Cancel ()
   guiSetVisible ( surf_shop_Window1, false )
   showCursor ( false )
end

--this is the function that gets triggered if the player clicks "yes"
function surf_shop_Start ()
   guiSetVisible ( surf_shop_Window1, false )
   showCursor ( false )
   takePlayerMoney ( cost )
--alter anything below this line to do whatever you want to happen when yes is clicked, for this scripts purpose, i trigger a server event to spawn a surfboard
   triggerServerEvent ( "onSurf_shopStart", getLocalPlayer(), getLocalPlayer() )
end













--EVERYTHING BELOW HERE IS STRICTLY RELATED TO THE SURFBOARD, AND DOES NOT NEED TO BE USED IN YOUR OWN SCRIPT AT ALL

addEvent("surfboardcreated", true )
function fixboard(surfboard)
   setElementCollisionsEnabled(surfboard, false)
end
addEventHandler("surfboardcreated", getRootElement(), fixboard)


function surfenter(thePlayer, seat)
   if thePlayer == getLocalPlayer() then
      if (getElementData( source, "purpose" ) == "surfboard") then
         setVehicleOverrideLights ( source, 1 )
         showPlayerHudComponent ( "vehicle_name", false )
         setWorldSpecialPropertyEnabled ( "hovercars", true )-- LETS SURFBOARDS GO ON WATER
      else
         setVehicleOverrideLights ( source, 1 )
         showPlayerHudComponent ( "vehicle_name", true )
         setWorldSpecialPropertyEnabled ( "hovercars", false )
      end
   end
end
addEventHandler("onClientVehicleEnter", getRootElement(), surfenter)

function surfexit(thePlayer, seat)
   if thePlayer == getLocalPlayer() and (getElementData( source, "purpose" ) == "surfboard") then
      setWorldSpecialPropertyEnabled ( "hovercars", false )
      setVehicleOverrideLights ( source, 0 )
      showPlayerHudComponent ( "vehicle_name", true )
   end
end
addEventHandler("onClientVehicleExit", getRootElement(), surfexit)

addEvent("surfboardwipeout", true )
function fixboard(theplayer)
   if thePlayer == getLocalPlayer() then
      setWorldSpecialPropertyEnabled ( "hovercars", false )
      setWorldSpecialPropertyEnabled ( "aircars", false )
      showPlayerHudComponent ( "vehicle_name", true )
   end
end
addEventHandler("surfboardwipeout", getRootElement(), fixboard)

Server:

Spoiler for Hiden:
addEvent( "onSurf_shopStart", true )
function spawnboard(playersource)
   local x,y,z = getElementPosition( playersource )
   ridecar = createVehicle ( 441, x, y+3, z)
   surfboard = createObject ( 2410, x, y+3, z, 0, 0, 0 )
   setElementData ( ridecar, "purpose", "surfboard" )
   attachElements ( surfboard, ridecar, 0, 0, 0, 0, 0, 270)
   setElementAlpha(ridecar, 0)
   setElementParent ( surfboard, ridecar)
   triggerClientEvent ( "surfboardcreated", getRootElement(), surfboard )
end
--addCommandHandler ( "surf", spawnboard ) DISABLED BECAUSE ITS LAME TO USE COMMAND HANDLERS
addEventHandler( "onSurf_shopStart", getRootElement(), spawnboard)

function surfOnEnter ( vehicle, seat, jacked )
    if (getElementData( vehicle, "purpose" ) == "surfboard") then
      setPedAnimation(source, "bikeleap", "bk_blnce_in", -1, false, false, false)
      setTimer ( surfanim, 800, 1, source )
    end
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), surfOnEnter )

function surfanim ( player )
   local theVehicle = getPedOccupiedVehicle ( player )
   if ( theVehicle ) then
      setPedAnimation(player, "bikeleap", "bk_blnce_in", -1, false, false, false)
   else
      setPedAnimation(player)
   end
end

function wipeout(loss)
   if (getElementData( source, "purpose" ) == "surfboard") then
      if loss > 5 then
         local thePlayer = getVehicleOccupant(source)
         if thePlayer then
            removePedFromVehicle(thePlayer)
            triggerClientEvent ( "surfboardwipeout", getRootElement(), surfboard )
         end
      end
   end
end
addEventHandler("onVehicleDamage", getRootElement(), wipeout)

function surferhurt ( attacker, weapon, bodypart, loss )
   local theVehicle = getPedOccupiedVehicle ( source )
   if ( theVehicle ) then
      if (getElementData( theVehicle, "purpose" ) == "surfboard") then
         removePedFromVehicle(source)
         triggerClientEvent ( "surfboardwipeout", getRootElement(), surfboard )
      end
   end      
end
addEventHandler ( "onPlayerDamage", getRootElement (), surferhurt )
 


Çevrimdışı neyo-

  • Dev.
  • Yeni Üye
  • *
    • İleti: 7
Yanıtla #3 : 10 Ağustos 2019, 17:47:44
Linki görebilmek için Kayıt olun yada Giriş yapın.
Daha önce konu açmıştım o koddaki trailer değiştirerek vehicle denedim fakat olmadı.Sörf tahtasından inince otomatik silinsin istiyorum


Kod
function sorfCikinca ( vehicle, seat, jacked )
    if (getElementData( vehicle, "purpose" ) == "surfboard") then

      destroyElement(surfboard)
    end
end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), sorfCikinca )
 
Mesajı Beğenenler: #Serius