Jump to content

I need help about interior checking


Hero192

Recommended Posts

Hello guys, I am scripting a mission, but i face a problem, I want to check when the player is on interior 0

I tried this way

if getElementInterior(source) == 0 then -- code end 

But doesn't work.

This way in below works but it cause lags, I want a proper way please

addEvent("remove",true) 
addEventHandler("remove", root, 
function() 
    setPedAnimation(source) 
    getPlayerInterior(source, 0) 
end)  
  
local timer = nil 
  
function getPlayerInterior(player, int) 
   timer = setTimer( 
    function() 
        if getElementInterior(player) == tonumber(int) then  
            if isTimer(timer) then killTimer(timer) end 
        end    
    end,1000,0) 
end  

-Thanks in advance.

Link to comment

Just modify setElementInterior like that:

local _setElementInterior = setElementInterior  
  
function setElementInterior ( element, int ) 
     if isElement ( element ) and getElementType ( element ) == "player" and int == 0 then 
          -- Do whatever you want here -- 
     end 
     return _setElementInterior ( element, int ) 
end 

Link to comment
... It works ... why shouldn't it work?!

I know it works in another way, but doesn't work because, I am doing a mission inside an interior > 0, so I have to make a timer untill the player leave the interior to continue what I wanted to do,

and you know this timer cause lags ..

so anyway?

Link to comment

Are you talking about this code that you had sent to me? it set player's interior not checking it :roll:

local _setElementInterior = setElementInterior 
  
function setElementInterior ( element, int ) 
     if isElement ( element ) and getElementType ( element ) == "player" and int == 0 then 
          -- Do whatever you want here -- 
     end 
     return _setElementInterior ( element, int ) 
end 

Anyone?

Link to comment

Oh god ...

Do you even know LUA and read that code?

I mean do you even know what the code does?!

You don't even give all informations.

"Just use the code after setElementInterior ..."

I mean your own fkin code you want to use.

Just use it AFTER setElementInterior, what is the problem?!

Your way:

Ask the whole time if his interior is 0.

My way:

1. There is a "setElementInterior" in use to get the player into interior 0.

So just get the marker/colshape or whatever, search for setElementInterior ( player, 0 ) and use your code after that.

2. setElementInterior HAS TO BE USED to get the player into interior 0 (or spawnPlayer, but don't think so).

So you can modify setElementInterior and ask if the element is the player doing the mission.

If it's the player, just use your code.

My Code from 1. comment does the 2. way.

Link to comment

Dude sorry if i didnt explain my problem but I wont set the player his interior into 0 but i want to check if the player is out of interior.

For example when the player rob a store and he left the store then give him a reward..

I hope you can undetstand what i mean

Link to comment
You won't set his interior to 0 but talk about "he left the store".

What are you using to get him out of the store?

There is a fkin setElementInterior ( element, 0 ) to get the player out of the store.

Chill your massive manboobs, jesus.. no need to go all badguy on him. If you can't handle people who don't understand a lot of LUA or if you lose your temper so freakin' fast, don't help them. There are others out there which can and will help them..

@OP; I've replied to your other topic, that should work. :wink:

Link to comment
You won't set his interior to 0 but talk about "he left the store".

What are you using to get him out of the store?

There is a fkin setElementInterior ( element, 0 ) to get the player out of the store.

Chill your massive manboobs, jesus.. no need to go all badguy on him. If you can't handle people who don't understand a lot of LUA or if you lose your temper so freakin' fast, don't help them. There are others out there which can and will help them..

@OP; I've replied to your other topic, that should work. :wink:

Read the whole page.

If someone wants help and doesn't know how to do something, he should listen to others. I wrote the same thing over and over, but he always didnt listen and said it would be wrong.

Do we have to get 1000+ posts to help people?!

I already wrote so many things and really waited for his responses, a "then don't help" is to late, I already wasted my time and he still thought he knows it better, didnt want to listen to me.

Oh and you didnt really help someone by sending a code. He doesnt seem to understand everything, I tried to teach him what interior is. The same questions will continue if no he never learns about how to switch interiors.

Link to comment
You won't set his interior to 0 but talk about "he left the store".

What are you using to get him out of the store?

There is a fkin setElementInterior ( element, 0 ) to get the player out of the store.

Chill your massive manboobs, jesus.. no need to go all badguy on him. If you can't handle people who don't understand a lot of LUA or if you lose your temper so freakin' fast, don't help them. There are others out there which can and will help them..

@OP; I've replied to your other topic, that should work. :wink:

Read the whole page.

If someone wants help and doesn't know how to do something, he should listen to others. I wrote the same thing over and over, but he always didnt listen and said it would be wrong.

Do we have to get 1000+ posts to help people?!

I already wrote so many things and really waited for his responses, a "then don't help" is to late, I already wasted my time and he still thought he knows it better, didnt want to listen to me.

Oh and you didnt really help someone by sending a code. He doesnt seem to understand everything, I tried to teach him what interior is. The same questions will continue if no he never learns about how to switch interiors.

Overwriting the entire function wasn't the option for him. He wanted a simple way of doing it, sure your way works but if he doesn't want to use your way or doesn't like your way, so be it. all he wanted to know is some kind of even trigger that got fired when the player is outside the interior AND the distance is bigger than a certain amount.

You're not wrong, I would've gone for the same actual overruling function too. But that's something you do in complicated systems, not in a tiny robbery where the user wants to see if the distance is bigger than 100 meters or something like that. :lol:

Link to comment

Well guys, you both thanks alot for your hard works, I see how you help people and I personally appreciate that.

Continue helping you're totally usefull to the community.

@Bonus, sorry if I didn't explain my problem aswell, in that moment I was kinda confused.

And I have no problem with how to deal with Lua, I just didn't find a way to check if the player is left an interior, I won't force him to leave from the interior.

But by tosfera, my issue is fixed, thanks all.

@Tosfera, special thanks to you dude, I wish all helpers to be like you, I never got an ignore by you, even sometime I was asking you alot and I felt that I was annoying but you just kept helping, that's why you are my favorit person in this community, personally I wish you to be an admin on this community and you deserve more.

Link to comment

You didn't understand me.

Let me show you again:

A player can switch between interiors.

But there are only 2 ways a player can switch the interior:

1. setElementInterior

2. spawnPlayer

But spawnPlayer would (as I know) remove your weapons etc.

So if someone switches interiors, there is nearly always a setElementInterior.

Thats why my first plan was to change setElementInterior.

You should never use setElementInterior by yourself, I only changed it so you know when exactly someone changes the interior.

There you could use something like

function setElementInterior ... 
     triggerEvent ( "onPlayerChangeInterior", player, getPlayerInterior ( player ), newinterior ) 
end 
  
addEvent ( "onPlayerChangeInterior", true ) 
addEventHandler ( "onPlayerChangeInterior", root, function ( oldint, newint ) 
       outputChatBox ( getPlayerName ( source ) .. " left interior "..oldint.." and is now in "..newint ) 
end ) 

And then you could have used onPlayerChangeInterior for that type of problems.

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