Jump to content

Objects and texts


Piorun

Recommended Posts

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

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

@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

@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 :P

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...