brocky Posted October 14, 2015 Share Posted October 14, 2015 I made a function to unlock a house and it works perfectly, but it doesn't show the message "House unlocked", What's the problem? function unlockHouse() if button6 == source then guiSetEnabled(button4, true) guiSetEnabled(button5, true) outputChatBox("House Unlocked", source, 246, 8, end end addEventHandler("onClientGUIClick", button6, unlockHouse, false) Link to comment
HUNGRY:3 Posted October 14, 2015 Share Posted October 14, 2015 function unlockHouse() if button6 == source then guiSetEnabled(button4, true) guiSetEnabled(button5, true) outputChatBox("House Unlocked", 246, 8, end end addEventHandler("onClientGUIClick", button6, unlockHouse, false) Link to comment
Valentin3526 Posted October 14, 2015 Share Posted October 14, 2015 You don't need to specify the player in most client functions Link to comment
brocky Posted October 14, 2015 Author Share Posted October 14, 2015 I also have problem with this code, I want to set the player who "enters" the marker, Anyone who enters the marker will get to interior 3, but I can't make it and I am forced to specify my own name in this function. out = createMarker ( 418.794921875, -84.074752807617, 1001.8046875, "arrow", 1.5, 236, 229, 30 ) setElementInterior ( out, 3, 418.794921875, -84.074752807617, 1001.8046875 ) function outside() if out == source then setElementInterior( getPlayerFromName("nope") , 0, 209, -63 , 2 ) else end end addEventHandler ( "onMarkerHit", root, outside ) As you can see I am forced to put my name in "setElementInterior" to set my postion, but I want to set the position of the player who enters the marker, but i can't get it and I added my name in "setElementInterior". I need help to set the interior of the player who hit that marker not only me. Link to comment
SpecT Posted October 14, 2015 Share Posted October 14, 2015 I also have problem with this code, I want to set the player who "enters" the marker, Anyone who enters the marker will get to interior 3, but I can't make it and I am forced to specify my own name in this function. out = createMarker ( 418.794921875, -84.074752807617, 1001.8046875, "arrow", 1.5, 236, 229, 30 ) setElementInterior ( out, 3, 418.794921875, -84.074752807617, 1001.8046875 ) function outside() if out == source then setElementInterior( getPlayerFromName("nope") , 0, 209, -63 , 2 ) else end end addEventHandler ( "onMarkerHit", root, outside ) As you can see I am forced to put my name in "setElementInterior" to set my postion, but I want to set the position of the player who enters the marker, but i can't get it and I added my name in "setElementInterior". I need help to set the interior of the player who hit that marker not only me. This should work. out = createMarker ( 418.794921875, -84.074752807617, 1001.8046875, "arrow", 1.5, 236, 229, 30 ) setElementInterior ( out, 3, 418.794921875, -84.074752807617, 1001.8046875 ) function outside() if out == source then setElementInterior( localPlayer , 0, 209, -63 , 2 ) end end addEventHandler ( "onMarkerHit", root, outside ) Also don't forget to use [ lua ] function .... [ /lua ] ! Link to comment
KariiiM Posted October 14, 2015 Share Posted October 14, 2015 (edited) local out = createMarker ( 418.794921875, -84.074752807617, 1001.8046875, "arrow", 1.5, 236, 229, 30 ) function outside(hitElement,matchingDim) if (hitElement and matchingDim and getElementType(hitElement) == "player") then setElementInterior ( hitElement, 3, 418.794921875, -84.074752807617, 1001.8046875 ) setElementInterior( getPlayerFromName("nope") , 0, 209, -63 , 2 ) end end addEventHandler ( "onMarkerHit", out , outside ) Edited October 15, 2015 by Guest Link to comment
KariiiM Posted October 14, 2015 Share Posted October 14, 2015 out = createMarker ( 418.794921875, -84.074752807617, 1001.8046875, "arrow", 1.5, 236, 229, 30 ) setElementInterior ( out, 3, 418.794921875, -84.074752807617, 1001.8046875 ) function outside() if out == source then setElementInterior( localPlayer , 0, 209, -63 , 2 ) end end addEventHandler ( "onMarkerHit", root, outside ) Also don't forget to use [ lua ] function .... [ /lua ] ! @Toni you're wrong, it's server side look at 'onMarkerHit' event so localPlayer won't works there Link to comment
brocky Posted October 14, 2015 Author Share Posted October 14, 2015 Can you explain me a bit more about "permetres" because thats the only thing I don't understand in MTA Lua. @KariiiM Link to comment
brocky Posted October 14, 2015 Author Share Posted October 14, 2015 Magically, the "localPlayer" thing worked and so did Kariim one, but Kariim, I need some more explanation about Perimeters like you used in your code. Please explain Perimeter, It really confuses me, Are they Arguments......Are they just some words added randomly...What are they? Link to comment
AMARANT Posted October 14, 2015 Share Posted October 14, 2015 Magically, the "localPlayer" thing worked and so did Kariim one, but Kariim, I need some more explanation about Perimeters like you used in your code. Please explain Perimeter, It really confuses me, Are they Arguments......Are they just some words added randomly...What are they? There aro no random words and no "magic" in Lua. And not "perimeters" but parameters. And yes, they are actually arguments you mentioned. Link to comment
brocky Posted October 15, 2015 Author Share Posted October 15, 2015 Magically, the "localPlayer" thing worked and so did Kariim one, but Kariim, I need some more explanation about Perimeters like you used in your code. Please explain Perimeter, It really confuses me, Are they Arguments......Are they just some words added randomly...What are they? There aro no random words and no "magic" in Lua. And not "perimeters" but parameters. And yes, they are actually arguments you mentioned. So you mean to say they are arguments? I mean like givePlayerMoney(argument1(the player who you want to give the money), argument2(the amount of money). Now I am ok with that but..... How do i know the arguments of function that i made? for example function goingOut() how the heck do i use argument in these? if so how can i add them? what are their uses?, This is my own function not MTA function how can i add arguments from myself? How will they be used and why will they be used? In which kind of scripts are they necessary? I am pretty confused in this part. Link to comment
ALw7sH Posted October 15, 2015 Share Posted October 15, 2015 Magically, the "localPlayer" thing worked and so did Kariim one, but Kariim, I need some more explanation about Perimeters like you used in your code. Please explain Perimeter, It really confuses me, Are they Arguments......Are they just some words added randomly...What are they? There aro no random words and no "magic" in Lua. And not "perimeters" but parameters. And yes, they are actually arguments you mentioned. So you mean to say they are arguments? I mean like givePlayerMoney(argument1(the player who you want to give the money), argument2(the amount of money). Now I am ok with that but..... How do i know the arguments of function that i made? for example function goingOut() how the heck do i use argument in these? if so how can i add them? what are their uses?, This is my own function not MTA function how can i add arguments from myself? How will they be used and why will they be used? In which kind of scripts are they necessary? I am pretty confused in this part. The parameters based on the event you are using with your function for example you are using onMarkerHit mtasa wiki->ServerEvents->MarkerEvents->onMarkerHit and here you can find the event parameters Link to comment
KariiiM Posted October 15, 2015 Share Posted October 15, 2015 Can you explain me a bit more about "permetres" because thats the only thing I don't understand in MTA Lua. @KariiiM Hello zacknope, Each event has some parameters those parameters can be bool , element (player,vehicle,objects..etc) , string, float, integer, account..etc I will give you an example with the event onMarkerHit, i'm sure you will understand it just follow me step by step Let's start with onMarkerHit or onClientMarkerHit they're with the same parameters the different between those two events the first one is server sided and the second one is client sided so the server sided one can't be used in client side and the same thing to other one. So as i said, onMarkerHit / onClientMarkerHit or onMarkerLeave / onClientMarkerLeave are with two parameters let's defines them! Those two parameters are: hitElement and dimension, hitElement mean the element that hit the marker it can be player or vehicle...etc dimension mean if the element is in the same as the marker's dimension then it will return true else it will return false Now after defining those parameters let's do some practice: function onPlayerHitMarker (hitElement, dimension) --Let's enter the two arguments of our event 'onMarkerHit' if getElementType( hitElement ) == "player" then --Let's exist our element type and check if it's a player outputChatBox(getPlayerFromName(hitElement).. " hit the marker.",getRootElement(),255,0,0) end --end of if end --end of the function addEventHandler("onMarkerHit",markerName,onPlayerHitMarker) ~Regards,KariM Link to comment
brocky Posted October 15, 2015 Author Share Posted October 15, 2015 OMG Thanks, Kariim and everyone else Link to comment
KariiiM Posted October 15, 2015 Share Posted October 15, 2015 OMG Thanks, Kariim and everyone else You're welcome my friend 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