Jump to content

How to write a condition so that when you enter the marker when you press E function is triggered (example go to another interior)


Recommended Posts

Posted

I'm new to scripting and need your help!I can not understand how the Colshape system works .Or as for example to create a job, which the player runs on the markers when he stood on the marker character is any emotion, and then there is another, and the old disappears.


 

Posted (edited)

I am not a friend of telling a full working solution as of people should learn it itself. So you should find it out completely your own. For smaller questions I can suggest to use discord or you can ask me later :D But now to an short explanation how I would write something like that (in words of cause)

  1. Let's image you have an event or command (doesn't matter) that get's triggered and you want now tp start the job. What you do are the following steps:
    • Create a new marker with https://wiki.rage.mp/index.php?title=Marker::Marker 
      You should store the marker in a variable or in a variable space that you can access it later again. When you want to have a marker that only reacts to that player you should take in consideration to store it in a user space like a variable on the player entity or in an array with the player id as index (or something like that - there are a lot of opportunities)
    • if you want to have it only visible to a specific player or some other options there are different marker functions in wiki
    • As of there is not any Marker event you have additionally to create a Colshape. I suggest here to create a cylinder with same size like the marker. The function to do that is https://wiki.rage.mp/index.php?title=Colshapes::newTube  - again save the colshape in a variable you can access later like the marker
  2. Either you add now to same function the creation of the event listener and destroy it later or what I would do you introduce a general event that listens to https://wiki.rage.mp/index.php?title=PlayerEnterColshape (event listers are explained here: https://wiki.rage.mp/index.php?title=Getting_Started_with_Events)
  3. As of the event listener has a variable that tells you which colshape and which player it is, you can compare it with the stored values from 1. - if the colshape is the correct one and also the player (if you want to check that) you destroy the marker and the colshape - for that you do simply  marker.destroy() and colshape.destroy() like it is documented here: https://wiki.rage.mp/index.php?title=Entity::destroy
  4. Now marker and colshape are gone, so if you want to have a new one (for a job for example) you can go back to 1. go again through loop just with the adjustments you want to have (like position or whatever)

I hope that helps you a bit to get an idea how to do that. All functions I wrote here are server-sided, but a similar variant can also be done client-side. It's up to you now to do what ever you want to do.

 

// edit: 

I you question you mention interior markers: I this case I suggest to create all markers and colshapes to store them in an array together with the position you want to put the player. After the player hots the colshape (see 2.) you don't destroy the colshape you just set him the new position - thats it

Edited by Geramy92
  • 2 months later...
Posted (edited)
On 4/9/2019 at 2:05 PM, tonihenkel said:

@Geramy92 Very Cool Turtorial! And how  I can message the 'Press E Button' in the Colshape and trigger a event (I will show html-site) ?

Check clientside if player has entered any colshape and store that colshape in a variable -> Add a method call for each tick and check that the variable is not null, then check for  keypress with RAGE.Game.Pad (Default bind E is INPUT_CONTEXT) -> If key pressed, CallRemote() to call the server with an event of your choosing, then perform whatever necessary.

If you want to show an html site you'll have to create a CEF and display it on the keypress rather than calling a remote event.

Edited by introzen

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