Jump to content

Object Check


lolek123

Recommended Posts

This will work after your resource starts.

Server-side:

  
function CheckMyObject(res) 
if res==getThisResource() then 
for _,object in ipairs(getElementsByType("object")) do 
if getElementModel(object)==2916 then 
local x,y,z=getElementPosition(object) 
local int=getElementInterior(object) 
local dim=getElementDimension(object) 
myMarker=createMarker(x,y,z,"cylinder",2.0,255,0,0,125) 
setElementInterior(myMarker,int) 
setElementDimension(myMarker,dim) 
end 
end 
end 
end 
addEventHandler("onResourceStart",getRootElement(),CheckMyObject) 
  

Link to comment
This will work after your resource starts.

Server-side:

  
function CheckMyObject(res) 
if res==getThisResource() then 
for _,object in ipairs(getElementsByType("object")) do 
if getElementModel(object)==2916 then 
local x,y,z=getElementPosition(object) 
local int=getElementInterior(object) 
local dim=getElementDimension(object) 
myMarker=createMarker(x,y,z,"cylinder",2.0,255,0,0,125) 
setElementInterior(myMarker,int) 
setElementDimension(myMarker,dim) 
end 
end 
end 
end 
addEventHandler("onResourceStart",getRootElement(),CheckMyObject) 
  

Hi, how you know how many "end" will add ?

Link to comment

I'm not good at explaining the lua basics. For that you can find more with google or tutorials on MTA wiki. And I made an example above for lolek123. But here is one more:

  
function outputForPerfect(player) 
for i,player in ipairs(getElementsByType("player") do -- Here's looping through all player elements in order to find what we want. Loops are usually used to check tables or to shorten a code so you can write several lines of your script instead of writing hundred. 
if getPlayerName(player)=="Perfect" then -- We wanted to find a player with nickname "Perfect". Here we are 
outputChatBox("Bla-bla-bla...",player,0,255,0) -- And finally we output a message to him. 
end 
end 
end 
addCommandHandler ( "loop", outputForPerfect ) 
  

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...