Thehookerkiller01 Posted April 2, 2009 Share Posted April 2, 2009 Hey i just have made a script and when you walk into a marker there should be a box show. But i dont works. Script: createMarker ( 1174, -1319, 16, "cylinder", 1, 0, 0, 255, 200 ) addEventHandler("onMarkerHit", getRootElement (), openbox) What did i just do wrong? Link to comment
Lordy Posted April 2, 2009 Share Posted April 2, 2009 You know that we'd need to see openbox function and all other relevant things too. And a bit information what doesn't work etc. Link to comment
Thehookerkiller01 Posted April 2, 2009 Author Share Posted April 2, 2009 You know that we'd need to see openbox function and all other relevant things too. And a bit information what doesn't work etc. Openbox don't matters, it only don't works. I only want that if you enter a marker that openbox should open. (It's a function in the rest of the script) Link to comment
Vivalavido Posted April 2, 2009 Share Posted April 2, 2009 yourMarker = createMarker ( 1174, -1319, 16, "cylinder", 1, 0, 0, 255, 200 ) function YourFunction ( ) outputChatBox("Yay it works!") end addEventHandler("onMarkerHit", yourMarker, YourFunction, false) Basicly: Your addEventHandler doesnt make any sence at all. Link to comment
Lordy Posted April 2, 2009 Share Posted April 2, 2009 Oh you are correct, I didn't think of that before, but you INDEED have managed to make a mistake in only those two lines. Now since you didn't give me any relevant information You know that we'd need to see openbox function and all other relevant things too I can't help more than saying that you got a problem with client/server side syntax. Since you didn't tell me if it's server or client side, can't help you anymore. (Actually I could, but to make you debug your code yourself, I'll give you just a hint.) HINT: onMarkerHit works just as it's supposed to. Triggers a serverside event for serverside markers. EDIT: @vivalavido yourMarker = createMarker ( 1174, -1319, 16, "cylinder", 1, 0, 0, 255, 200 ) function YourFunction ( ) outputChatBox("Yay it works!") end addEventHandler("onMarkerHit", yourMarker, YourFunction, false) Basicly: Your addEventHandler doesnt make any sence at all. Actually he CAN attach the event handler to root element, so I didn't whine about that Link to comment
Thehookerkiller01 Posted April 3, 2009 Author Share Posted April 3, 2009 Oh you are correct, I didn't think of that before, but you INDEED have managed to make a mistake in only those two lines. Now since you didn't give me any relevant information You know that we'd need to see openbox function and all other relevant things too I can't help more than saying that you got a problem with client/server side syntax. Since you didn't tell me if it's server or client side, can't help you anymore. (Actually I could, but to make you debug your code yourself, I'll give you just a hint.) HINT: onMarkerHit works just as it's supposed to. Triggers a serverside event for serverside markers. EDIT: @vivalavido yourMarker = createMarker ( 1174, -1319, 16, "cylinder", 1, 0, 0, 255, 200 ) function YourFunction ( ) outputChatBox("Yay it works!") end addEventHandler("onMarkerHit", yourMarker, YourFunction, false) Basicly: Your addEventHandler doesnt make any sence at all. Actually he CAN attach the event handler to root element, so I didn't whine about that Doesn't work. Should I add it server side? Or only 1 thing, only the local player who walk into the marker should get the screen, and if the rest of the script is in the client.lue and if i do it in server.lua you can't open the box. Link to comment
Lordy Posted April 3, 2009 Share Posted April 3, 2009 Hmm you didn't get the hint then Here is another one: READ WIKI FFS! "onMarkerHit" is CLEARLY marked as serverside event, but you are using client side syntax for createMarker (READ WIKI TO SEE THAT). So you are either having a clientside marker with serverside event or serverside event called on a nil value, since for serverside, your createMarker syntax is wrong. And it all could be achieved by just LOOKING AT WIKI. Link to comment
Thehookerkiller01 Posted April 3, 2009 Author Share Posted April 3, 2009 Hmm you didn't get the hint thenHere is another one: READ WIKI FFS! "onMarkerHit" is CLEARLY marked as serverside event, but you are using client side syntax for createMarker (READ WIKI TO SEE THAT). So you are either having a clientside marker with serverside event or serverside event called on a nil value, since for serverside, your createMarker syntax is wrong. And it all could be achieved by just LOOKING AT WIKI. Yesh, but there is nothing on wiki about addEventHandler("onMarkerHit", yourMarker, yourFunction, true) Link to comment
Lordy Posted April 3, 2009 Share Posted April 3, 2009 (edited) bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true] ) There is. And I already told you that vivalavido didn't give you a correct example. You also might want to read this article: http://development.mtasa.com/index.php?title=Event Edited April 3, 2009 by Guest Link to comment
Thehookerkiller01 Posted April 3, 2009 Author Share Posted April 3, 2009 bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true] ) There is. And I already told you that vivalavido didn't give you a correct example. What is bool? Link to comment
Thehookerkiller01 Posted April 3, 2009 Author Share Posted April 3, 2009 This is a bool I don't understand that. Link to comment
Mr.Hankey Posted April 3, 2009 Share Posted April 3, 2009 http://development.mtasa.com/index.php?title=Bool Link to comment
Thehookerkiller01 Posted April 5, 2009 Author Share Posted April 5, 2009 bool addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true] ) There is. And I already told you that vivalavido didn't give you a correct example. What is bool? : bool="true" addEventHandler ( string eventName, element attachedTo, function handlerFunction, [bool getPropagated = true] ) ? Link to comment
Thehookerkiller01 Posted April 5, 2009 Author Share Posted April 5, 2009 yourMarker = createMarker ( 1174, -1319, 16, "cylinder", 1, 0, 0, 255, 200 )addEventHandler("onMarkerHit", yourMarker, YourFunction, false) What's false? And it have to be on my marker hit. In this function it uses on marker hit (doesn't matter wich marker) Link to comment
Lordy Posted April 5, 2009 Share Posted April 5, 2009 PLEASE READ WIKI! Bool is not a string, it's a boolean value, either 1 or 0, true or false. You can't use onMarkerHit because it's server side event. While your code is client side. Now I'm not going to waste more of my time if you continue ignoring everything we try to say.. Link to comment
robhol Posted April 5, 2009 Share Posted April 5, 2009 Ok, you definitely need to learn the basics. http://lua.org/pil Please stop bothering us until you have. Link to comment
50p Posted April 5, 2009 Share Posted April 5, 2009 PLEASE READ WIKI! Bool is not a string, it's a boolean value, either 1 or 0, true or false... This is actually wrong. 1 and 0 are numbers and will always return true. It's not C based language. Lua is different language and 1 and 0 don't count as boolean values. nil and false will always be false, everything else is true, even 0. Link to comment
Thehookerkiller01 Posted April 6, 2009 Author Share Posted April 6, 2009 PLEASE READ WIKI! Bool is not a string, it's a boolean value, either 1 or 0, true or false... This is actually wrong. 1 and 0 are numbers and will always return true. It's not C based language. Lua is different language and 1 and 0 don't count as boolean values. nil and false will always be false, everything else is true, even 0. Ah, ok. And robhol, I can learn, but I don't see the 'overeenkomst' between print("Hello World") and a script in MTA. Link to comment
robhol Posted April 6, 2009 Share Posted April 6, 2009 PLEASE READ WIKI! Bool is not a string, it's a boolean value, either 1 or 0, true or false... This is actually wrong. 1 and 0 are numbers and will always return true. It's not C based language. Lua is different language and 1 and 0 don't count as boolean values. nil and false will always be false, everything else is true, even 0. Ah, ok. And robhol, I can learn, but I don't see the 'overeenkomst' between print("Hello World") and a script in MTA. Then you've either not read enough, or you're too dumb - hope it's the former and keep reading. Link to comment
Lordy Posted April 6, 2009 Share Posted April 6, 2009 PLEASE READ WIKI! Bool is not a string, it's a boolean value, either 1 or 0, true or false... This is actually wrong. 1 and 0 are numbers and will always return true. It's not C based language. Lua is different language and 1 and 0 don't count as boolean values. nil and false will always be false, everything else is true, even 0. Yes I'm aware of that. I just wanted to imply about the concept of a boolean not how it's done in lua. That it's a boolean value in like in binary(1 true, 0 false). I know that they are just numbers in lua. What I didn't think about though is that he has probably no idea what binary is Link to comment
Thehookerkiller01 Posted April 6, 2009 Author Share Posted April 6, 2009 PLEASE READ WIKI! Bool is not a string, it's a boolean value, either 1 or 0, true or false... This is actually wrong. 1 and 0 are numbers and will always return true. It's not C based language. Lua is different language and 1 and 0 don't count as boolean values. nil and false will always be false, everything else is true, even 0. Yes I'm aware of that. I just wanted to imply about the concept of a boolean not how it's done in lua. That it's a boolean value in like in binary(1 true, 0 false). I know that they are just numbers in lua. What I didn't think about though is that he has probably no idea what binary is Binary is another thing than Decimaal. 0 = 0 1 = 1 10 = 2 11 = 3 100 = 4 101 = 5 110 = 6 111 = 7 1000 = 8 etc Link to comment
robhol Posted April 6, 2009 Share Posted April 6, 2009 A boolean value is either 1, or 0, obviously. When you're talking about it from an electronics perspective, this is represented by high/low voltage, from a programming perspective by true/false.. you can also think of it as one bit of data (one binary digit), yes/no, etc. Link to comment
Lordy Posted April 6, 2009 Share Posted April 6, 2009 Binary is another thing than Decimaal. 0 = 0 1 = 1 10 = 2 11 = 3 100 = 4 101 = 5 110 = 6 111 = 7 1000 = 8 etc Haven't stated otherwise. For example 1000 = because 1 * 2^3 + 0 * 2^2 + 0 * 2^1 + 0 * 2^0 = 8 1000 basically means [true false false false], so only 2^3 is added to 0 and no other 2^n, because all other are false Similarly 1001 ([true false false true]) means that you add 2^3 and 2^0 and no others. Which will make it 9. So binary is a boolean system. I know I explained it pretty rubbishly, but that's related to my relatively low English skills not relatively low knowledge Link to comment
Thehookerkiller01 Posted April 7, 2009 Author Share Posted April 7, 2009 Binary is another thing than Decimaal. 0 = 0 1 = 1 10 = 2 11 = 3 100 = 4 101 = 5 110 = 6 111 = 7 1000 = 8 etc Haven't stated otherwise. For example 1000 = because 1 * 2^3 + 0 * 2^2 + 0 * 2^1 + 0 * 2^0 = 8 1000 basically means [true false false false], so only 2^3 is added to 0 and no other 2^n, because all other are false Similarly 1001 ([true false false true]) means that you add 2^3 and 2^0 and no others. Which will make it 9. So binary is a boolean system. I know I explained it pretty rubbishly, but that's related to my relatively low English skills not relatively low knowledge Yeh, but im talking about it from an electronics perspective. 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