Jump to content

[HELP] entrance to interiors


eoL Shady

Recommended Posts

Posted (edited)

hello mta community, I've been dealing with a new script for a few days, but I need some information, I'm waiting for your nice comments for your help on this.

I will make some interiors private for admins, only admins will be able to login.

Edited by eoL|Shady
wrong code
Posted
function createTeleportMarker(startX, startY, startZ, endX, endY, endZ, teleportInterior, markerInterior)
   local marker = createMarker(startX, startY, startZ, "cylinder", 2.0, 255, 255, 255, 0)
   setElementInterior(marker, markerInterior)
   teleportDatas[marker] = {startX = startX, startY = startY, startZ = startZ, endX = endX, endY = endY, endZ = endZ, teleportInterior = teleportInterior}
   table.insert(InteriorMarkers, marker)
end

addEventHandler("onResourceStart", resourceRoot,
    function()
       for _,player in ipairs(getElementsByType("player")) do
       	  bindKey(player, "F", "down", teleportPlayer)
       end
addEventHandler("onPlayerJoin", root,
    function()
       bindKey(source, "F", "down", teleportPlayer)
    end
)

addEventHandler("onMarkerHit", root,
    function(hitElement, matchingDimension)
       if(getElementType(hitElement) == "player") then
       	  local isVehicle = getPedOccupiedVehicle(hitElement)
          if(isVehicle) then return end

          for i=1,#InteriorMarkers do
       	     if(source == InteriorMarkers[i]) then
                triggerClientEvent(hitElement, "InteriorInfoVisible", hitElement, true)
       	     end
          end

       end
    end
)

addEventHandler("onMarkerLeave", root,
    function(leaveElement, matchingDimension)
       if(getElementType(leaveElement) == "player") then
       	  local isVehicle = getPedOccupiedVehicle(leaveElement)
          if(isVehicle) then return end

          for i=1,#InteriorMarkers do
       	     if(source == InteriorMarkers[i]) then
                triggerClientEvent(leaveElement, "InteriorInfoVisible", leaveElement, false)
       	     end
          end

       end
    end
)

function teleportPlayer(player)
   for i=1,#InteriorMarkers do
   	  if(isElementWithinMarker(player, InteriorMarkers[i])) then
   	  	 triggerClientEvent(player, "InteriorInfoVisible", player, false)
   	     setElementInterior(player, teleportDatas[InteriorMarkers[i]].teleportInterior)
         setElementPosition(player, teleportDatas[InteriorMarkers[i]].endX, teleportDatas[InteriorMarkers[i]].endY, teleportDatas[InteriorMarkers[i]].endZ)
         break
   	  end
   end
end

forgot to send codes.

client
 

function drawInteriorInfo()
   if(isInteriorInfoVisible) then
      dxDrawBorderedText(1.5 * relX, "Press 'F' to Use Door.", screenW/2, 850 * relY, screenW/2, 850 * relY, tocolor(255, 255, 255, 255), 2.2 * relX, "default-bold", "center", "center")
   end
end
addEventHandler("onClientRender", root, drawInteriorInfo)

only admin login and "Press 'F' to Use Door." Only admins can see this post

Posted (edited)

Hello eoL|Shady,

I recommend you to use the hasObjectPermissionTo function on the player to check for privilege about entering the special interior or even receiving/showing the interior information. To achieve that you should conditionally-enclose related code for teleportation, marker-hit and marker-leave. But considering that you have not shown us the entire code, there is more to disable for non-admins than we can know.

Edited by The_GTA
Posted (edited)

I understood your post and I will try this.

When I came to the door, this text on the screen was "Press 'F' to Use Door." I have to use this code for only admins to see "hasObjectPermissionTo"

Edited by eoL|Shady
Posted
1 minute ago, eoL|Shady said:

When I came to the door, this text on the screen was "Press 'F' to Use Door." I have to use this code for only admins to see "hasObjectPermissionTo"

Yes, you do. Check on the player element in the marker events. What is your problem?

Posted

I just wanted to have an admin login to some interiors, I had no idea how to do this, you helped,In the second question, I wanted only the admin to see the article..

I will look at the code we sent,normally i don't use this code much :=)

Posted
Just now, eoL|Shady said:

I just wanted to have an admin login to some interiors, I had no idea how to do this, you helped,In the second question, I wanted only the admin to see the article..

You have to use the same function in the marker-hit and marker-leave event handlers.

German: du sollst die gleiche Funktion in den Marker-Treffer und Marker-Verlassen Ereignis-Behandlern nutzen.

  • Like 1
Posted (edited)
2 minutes ago, eoL|Shady said:

Mein Englisch ist vielleicht ein bisschen schlecht, aber jetzt verstehe ich es,Danke.

No Problem. The solution to your inquiry is that simple. And I know from your background that you are of German heritage. Thus if you want to have German-only support requests answered by me, please post threads in the German sub-forums and mention my name. I am fully competent to answer in German only if it helps you understand the topics much better.

Edited by The_GTA
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...