No ESC plugin

Discussion in 'Plugins' started by Carlos Carvalho, Apr 28, 2016.

  1. Carlos Carvalho

    Carlos Carvalho Registered

    Joined:
    Oct 19, 2015
    Messages:
    23
    Likes Received:
    2
    Hey,

    First of all i never developed a plugin for either rF1 or rF2 so i don´t really know how hard will it be but i´ll give it a try anyway.
    Since this is my first contact with rF plugins i will appreciate all the help possible from experienced developers.

    My idea is very simple but will bring another touch of realism to our rF2 races.

    As you all know, rFactor lets drivers press ESCAPE during sessions and return to the track in a blink of an eye. This is something very unreal and allows everyone to "hotlap" with no fear of "killing" the vehicle.

    My intention is to create a plugin that prevents drivers from returning to the track, in a given session (besides Testing), after they press ESCAPE outside the pitlane.


    As i can see in the InternalsPlugin.hpp there is a way to know if the car is in the pitlane:
    bool mInPits;// between pit entrance and pit exit (not always accurate for remote vehicles)
    or
    unsigned char mPitState; // 0=none, 1=request, 2=entering, 3=stopped, 4=exiting


    There is also a way to know the type of the current session:
    long mSession; // current session (0=testday 1-4=practice 5-8=qual 9=warmup 10-13=race)

    So my questions are:
    - Is there a way to block(grey) the Race button? (maybe: bool mServerScored;// whether vehicle is allowed to participate in current session)
    - How can i detect the ESC button was pressed to exit to pits.


    Thanks in advance,
    Carlos Carvalho
     
  2. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    9,492
    Likes Received:
    4,515
    Yep, that'd be the one. You want to make sure you implement InternalsPluginV07, so you get access to the rules stuff (return true from WantsMultiSessionRulesAccess()). Then, in AccessMultiSessionRules, you can set MultiSessionParticipantV01->mServerScored to false for the appropriate driver (note the definition comments show which are input/output, vs input only). I think this will disable the Race button for that driver.

    Any car that goes from not being in the pits (mInPits), to being in the pits, without at least having their mPitState change from 0 (None) to 2 (entering), has probably pressed Esc. You'd need to do some tests and think of ways this might get tricked though. But I'm pretty sure as soon as they cross the pit entry line mPitState will change to 2, which is about as good as you'll get unless there's some other way I haven't thought of.
     
  3. Woodee

    Woodee Registered

    Joined:
    Oct 4, 2010
    Messages:
    3,544
    Likes Received:
    631
    I'd love the ability to not escape at all until back to the pits. If you can't get back to the pits, then you have to retire the car from the session :)
     
  4. Carlos Carvalho

    Carlos Carvalho Registered

    Joined:
    Oct 19, 2015
    Messages:
    23
    Likes Received:
    2
    Thanks for your reply. Im starting to understand the example but there are a few things i still dont get. I will investigate a bit more and send you a message if i have any doubts

    Best regards
     
  5. argo0

    argo0 Registered

    Joined:
    Jan 22, 2012
    Messages:
    624
    Likes Received:
    8
    I like this idea a lot
     
  6. WiZPER

    WiZPER Member

    Joined:
    Oct 5, 2010
    Messages:
    1,521
    Likes Received:
    186
    But without the server being able to enforce clients having the plugin installed, it's useless - I like the idea though :)
     
  7. DuRiN

    DuRiN Registered

    Joined:
    Oct 12, 2010
    Messages:
    36
    Likes Received:
    10
    IMHO If you install the plugin in server side it should work... Lets check it!!!

    Enviado desde mi LG-D620 mediante Tapatalk
     
  8. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    9,492
    Likes Received:
    4,515
    Yeah, the Multisession rules should take effect from the server side no worries at all. Whether my method would be totally reliable remotely I'm not sure, but maybe there's another way.
     
  9. Boldaussie

    Boldaussie Registered

    Joined:
    Aug 16, 2015
    Messages:
    125
    Likes Received:
    21
    Shhhhhhhhhhhhhh don't anyone tell DD about this possibly happening ;)
     
  10. WiZPER

    WiZPER Member

    Joined:
    Oct 5, 2010
    Messages:
    1,521
    Likes Received:
    186
    Ohh, cool then, didn't think that was possible - for server to disallow a specific client to press 'race'
     
  11. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    9,492
    Likes Received:
    4,515
    Yeah, was a recent addition to the plugin interface :)
     
  12. WiZPER

    WiZPER Member

    Joined:
    Oct 5, 2010
    Messages:
    1,521
    Likes Received:
    186
    Super! (y)
     
  13. MaD_King

    MaD_King Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,830
    Likes Received:
    611
    Very interesting, so this plug-in can be very good to "lock" the Esc from users on some chosen Session !!
     
  14. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    9,492
    Likes Received:
    4,515
    Well, when it's working it'll stop people jumping back in the car after the fact. The game itself having the option to stop people escaping accidentally (users can make it more difficult already by forcing to have a prompt first), and working out when people have done it properly, and when people have too much damage to reasonably continue despite making it back to the pits, would be better. Still, beggars, choosers, blah.

    I was probably being slightly generous when I said "recent". This was put in to enable the KnockoutQualifying plugin, which uses the same facility to stop some drivers jumping in the car.
     
  15. Ho3n3r

    Ho3n3r Registered

    Joined:
    Feb 18, 2012
    Messages:
    530
    Likes Received:
    98
    EDIT: Nvm
     
  16. benmttf

    benmttf Registered

    Joined:
    May 15, 2013
    Messages:
    91
    Likes Received:
    0
    Hello! That sound very cool! Any update?
     
  17. machine

    machine Registered

    Joined:
    Jan 31, 2011
    Messages:
    389
    Likes Received:
    262
    If someone gets damage and pits, they have to sit and wait for it to be fixed. Better than stopping escape would be to force this repair time regardless of whether they pit in their pit spot or not. Get 300 secs damage...if you pit you have to wait, if you escape you don't! Hold on, now you have to wait even if you escape.
     
  18. Ho3n3r

    Ho3n3r Registered

    Joined:
    Feb 18, 2012
    Messages:
    530
    Likes Received:
    98
    :confused:

    In practice/quali, you don't wait for repairs to complete even if you don't escape before entering the pits.

    In the race, if you press Escape, you're out anyway, so does it matter that your car gets fixed?
     
  19. benmttf

    benmttf Registered

    Joined:
    May 15, 2013
    Messages:
    91
    Likes Received:
    0
    Hello. Any news?
     
  20. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    9,492
    Likes Received:
    4,515
    Can't speak for the OP, but having done a little playing with the rules code I'm not sure this is feasible - you can only 'disable' a car when the game asks for a multi session update, and that may not happen very often. For this to work you'd need to be able to stop scoring a car almost immediately after detecting it has pitted prematurely.


    *An alternative would be a client-side plugin that 'presses' ESC when it's detected that the driver has ESCed and then got back in the car, but obviously that's only useful for leagues and then you need to do some verifying with the server to make sure everyone's running it etc.
     
    Last edited by a moderator: Sep 8, 2016

Share This Page