Piorun Posted August 19, 2010 Share Posted August 19, 2010 Hi again. My next problem is - i want to write a code like this: addEvent ( "tworzenieObiektu", true ) function obiekt ( ) for k,v in ipairs(getElementsByType("player")) do local px,py,pz = getPedBonePosition(v,54) local rx,ry,rz = getElementRotation(v) local ox,oy,oz = createObject ( 346, px, py, pz, 90, 0, rz+135) end end addEventHandler ("tworzenieObiektu", rootElement, obiekt) function obText ( ) triggerEvent("tworzenieObiektu", rootElement, ox, oy, oz) local x,y = getScreenFromWorldPosition(ox,oy,oz) if x then dxDrawText("Pistolet",x,y) end end function object ( ) addEventHandler("onClientRender", rootElement, obText) addEventHandler ("tworzenieObiektu", rootElement, obiekt) end addCommandHandler ("objekt", object) I want to write a command, and then object will be created with the text "Pistol". Please, help. Now if i'm typping this command an object is creating without text, and the object is creating when i'm walking. Link to comment
NotAvailable Posted August 19, 2010 Share Posted August 19, 2010 I cannot fully understand you? Link to comment
Piorun Posted August 19, 2010 Author Share Posted August 19, 2010 When player use command "objekt" object should be created at the place where player have right foot bone with a text. Link to comment
dzek (varez) Posted August 19, 2010 Share Posted August 19, 2010 your code is a mess and wrong.. You are trying to read local variables inside function that handles onClientRender, it will not work with more than one object. And its a good thing to use ENGLISH variable names, functions, events etc. This is really something recommended in coding. I know it´s your code for you-but when you are giving your code and want ua to help - a lot of strange looking name is confusing and causing bad readability of your code. Trust me. And i believe you should write "obiekt" not "objekt" in your language. Try to rewrite it from scratch. Focus on that you probably want more than one object at once-dont use global variables for coordinates storing Link to comment
50p Posted August 20, 2010 Share Posted August 20, 2010 @Piorun triggerEvent in onClientRender event? Smart move... Creating tens of objects (depends how many players there are) at 1 single frame? Another smar move... How many objects would it create after a minute of playing? How much time would you be able to play before it starts to lag you? How quickly would the MTA elements limit be reached? Think about what your code is doing at the moment and then think again. Your code is totally messed up. local ox, oy, oz = createObject(....) -- What the...?! createObject returns object element that was created, so what oy and oz are for? And what do you need it for if you don't use it anywhere after this line? @varez And i believe you should write "obiekt" not "objekt" in your language. Why do you say "in your language" if you speak the same language? Link to comment
dzek (varez) Posted August 20, 2010 Share Posted August 20, 2010 @50p: I don´t want to everybody know my primary lang, probably same as you. Why? Cause ppl from our country are annoying as hell, asking for help and doing requests via pm, IM´s etc. You should know something about it. Actually you didnt reply to question about from where you are in another topic created by one Pole 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