Moony Posted March 1, 2020 Share Posted March 1, 2020 Here's the script: inFourD = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function inFourDragons (player, matchingDimension) if (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == true) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", hitPlayer, 0, 0, 0, true) elseif (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == false) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Ingresaste al casino '#DD0000Four Dragons#FFFFFF'.", hitPlayer, 0, 0, 0, true) setElementInterior (player, 10) setElementPosition (player, 2016.9376220703, 1017.0843505859, 996.875 ) setElementRotation (player, 0, 0, 90) end end addEventHandler ("onMarkerHit", getRootElement(), inFourDragons) Doing it client-side gives the invisible players. I read an old post that this had to be done server-side to fix the invisible players; however, I can't pinpoint the problem. As of this moment, with this script: - When in vehicle, player + vehicle is teleported to the same coords and interior 10, which results in an invisible world, player and vehicle, and it outputs "You've entered FDC.", when it should enter "Cars are not allowed". - When on foot, nothing happens. What could be the problem? Link to comment
_Ace Posted March 1, 2020 Share Posted March 1, 2020 line 1 change the Z position to 9.9203125 or make a bigger marker, if its base is below ground it wont trigger onfoot (tested) change line 4 and 6 to player in isPedOnVehicle, localPlayer is clientside only, also ==true is not needed 1 Link to comment
Blast3r Posted March 1, 2020 Share Posted March 1, 2020 (edited) Basically as _Ace mentioned == true and == false is the wrong way of checking the vehicle. inFourD = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function inFourDragons (player, matchingDimension) if ( source == inFourD and getElementType(player) == "player" and isPedInVehicle(player) ) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", player, 0, 0, 0, true) return; -- this return isn't completely necessary but it simply stops the rest of the code being read / checked unecessarily. elseif ( source == inFourD and getElementType(player) == "player" and not isPedInVehicle(player) ) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Ingresaste al casino '#DD0000Four Dragons#FFFFFF'.", player, 0, 0, 0, true) setElementInterior (player, 10) setElementPosition (player, 2016.9376220703, 1017.0843505859, 996.875 ) setElementRotation (player, 0, 0, 90) end end addEventHandler ("onMarkerHit", getRootElement(), inFourDragons) Try that code. EDIT: As for the invisible world, are your map objects set to interior 10? Edited March 1, 2020 by Blast3r 1 Link to comment
Moony Posted March 1, 2020 Author Share Posted March 1, 2020 4 hours ago, Blast3r said: Basically as _Ace mentioned == true and == false is the wrong way of checking the vehicle. inFourD = createMarker (2019.76953125, 1007.0116577148, 9.7203125, "cylinder", 1, 255, 0, 0, 153) function inFourDragons (player, matchingDimension) if ( source == inFourD and getElementType(player) == "player" and isPedInVehicle(player) ) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: No se permiten vehículos dentro.", player, 0, 0, 0, true) return; -- this return isn't completely necessary but it simply stops the rest of the code being read / checked unecessarily. elseif ( source == inFourD and getElementType(player) == "player" and not isPedInVehicle(player) ) then outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: Ingresaste al casino '#DD0000Four Dragons#FFFFFF'.", player, 0, 0, 0, true) setElementInterior (player, 10) setElementPosition (player, 2016.9376220703, 1017.0843505859, 996.875 ) setElementRotation (player, 0, 0, 90) end end addEventHandler ("onMarkerHit", getRootElement(), inFourDragons) Try that code. We've got it, guys! Alright, so let me get this straight. First, my newly acquired knowledge: 1. Why is it better to use 'isPedInVehicle(player)' to get the boolean, instead of what I was using? What was my error in that statement? This was my thought process: if (source == inFourD) and (getElementType(player) == "player") and (isPedInVehicle(localPlayer) == true) -- if the marker is 'inFourD' (true); if the player is, in fact, a player (true); if there is a player in a vehicle (true), then -- do whatever 2. What's the specific function of 'Return'? Does it save process of going through the whole function, thus, reducing the process and, therefore, the lag as well? How does it know when to reach the end of the function? I realized that I made a recurring mistake in my scripts: getting the elements right. Is there any "Elements for Dummies" tutorial out there? Clearly one of my biggest problems is that subject. And, finally, to my understanding: if ( source == inFourD and getElementType(player) == "player" and isPedInVehicle(player) ) then -- if the marker is 'inFourD' (true); if the element to affect called 'player' is, in fact, a player (true); is the ped in a vehicle (true) then -- not let in -- stop here (return) if the above happens. If not, then -- if the marker is 'inFourD' (true); if the element to affect called 'player' is, in fact, a player (true); is the ped in a vehicle (false) then -- let in. -- that false result in isPedInVehicle is what works the magic. Is it right? Link to comment
Blast3r Posted March 2, 2020 Share Posted March 2, 2020 1: Well the code is cleaner, I'm not sure if the way you did it is wrong or not, think that the biggest issue you had was the mixture of element naming in your initial code. 2: "return" stops the code from going any further / being read any further, if you don't need rest of the code (in this example you did what you needed, sent the message to the player and didn't execute the teleport, no need for the code to try and see if the next elseif statement will become true) 3: As for getting the elements right, there isn't exactly a tutorial elements for dummies as far as I know, it's just something that you'll figure out as time passes by, just make sure to keep using the pre-defined by MTA elements or the element names you defined in the function, example function code ( elementA, elementB ), elementA and elementB are the ones you defined yourself. And yeah, your understanding is pretty much right on the last snippet you posted. Link to comment
#\_oskar_/# Posted March 2, 2020 Share Posted March 2, 2020 function teleport(hitElement,int, px, py, pz,msg) if getElementType (hitElement) == "player" then local Vehicle = isPedInVehicle(hitElement) if Vehicle then return outputChatBox("No Car", hitElement, 0, 0, 0, true) end setElementInterior (hitElement, int, px, py, pz ) outputChatBox (msg or '',hitElement,255,0,0, true) end end local HitMarker = createMarker (2019.5, 1007.7, 10, "cylinder", 1, 255,255, 0,255) local LaveMarker = createMarker (2234, 1714.4, 1011.5, "cylinder", 1, 255, 255, 0, 255) setElementInterior (LaveMarker, 1 ) addEventHandler("onMarkerHit", root, function (hitElement) if source == HitMarker then teleport(hitElement,1, 2235, 1699, 1008,'Welcome To Casino') elseif source == LaveMarker then teleport(hitElement,0, 2026, 1008, 11) --[[Add More elseif source == Marker Name then teleport(hitElement,Interior ID, px, py, pz [,'ChatBox'])]] end end) try this Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now