Giovanni Posted June 13, 2011 Share Posted June 13, 2011 Hello, I want to create a little function, that can be called by another function. I really don't know if this what I am doing is even possible but I wanna give it a try. So I mean it like this: function myfunc(Float:x,Float:y,Float:z) createPickup(Float:x,Float:y,Float:z); end And then it shall be called by another function: function mainfunc() myfunc(MyPosX,MyPosY,MyPosZ); end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), mainfuncl) I do know that there are more parameters for createPickup but this is just an example. Anyway: Question #1: How do I implent Float's ? If I try it on this way then my editor gives out an error. That error doesn't really help me. Question #2: Is it even possible to use one function in a other function? If not, then how can I do this? Thanks. Link to comment
AHSS Posted June 13, 2011 Share Posted June 13, 2011 i bet you used to script in samp. first: you dont need to do any thing to make a float you just do this local floatX, floatY, floatZ = getElementPosition(element) floatX, floatY, floatZ is the 3 floats representing the element position they could be named any thing like local x, y, z = getElementPosition another example local health = getElementHealth(element) now the health is stored in the "health" variable but remember we used local so the health vartiable is only inside the function or whatever its inside can be used inside only. about the function here it is function createMyPickup(x, y, z) -- x, y, z is the position of the pickups cna also be named anything createPickup(x, y, z, 0, 100) --another function or event or command function createthepickup(player) local posX, posY, posZ = getElementPosition(player) -- 3 floats representing the player position createMyPickup(posX, posY, posZ) -- create the pick up at the player's position end and main wiki page : https://wiki.multitheftauto.com/wiki/Main_Page hope this helps. Link to comment
Giovanni Posted June 13, 2011 Author Share Posted June 13, 2011 i bet you used to script in samp. Aww is it really so obviously? Lol, so in my case I don't want the pickup to be created at the player's position. I just need to put the X, Y and Z positions here (instead of posX, posY...) ? : createMyPickup(posX, posY, posZ) Link to comment
JR10 Posted June 13, 2011 Share Posted June 13, 2011 Yes its obvious because Float:x are used in pwn and ; are also used in pwn. he just gave u an example, createMyPickup function will create a health pickup at the x, y, z you specify like this createMyPickup(0, 0, 0) will create a health pickup at 0, 0, 0, coordinates. Link to comment
karlis Posted June 13, 2011 Share Posted June 13, 2011 the difference in lua is that all variables is defined automatically, you don't have to. lua decides itself is it string, number, table or whatever. 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