Jump to content
RAGE Multiplayer Community

request and response issue via commands [node]


MeChill
 Share

Recommended Posts

Hey, Node issue

I'm trying to make it so if playerA is (1. in Faction and 2. is Faction leader), he then is able to /invite playerB ( who is NOT in a faction )

I'm having no issues at all with this but then, I try to send a request from playerA to playerB in order to ask playerB if he wants to join and if he does, he then can use /accept and then playerB will get into the faction.

down below you can see my current code:

mp.events.addCommand('invite', (player, target) => {
    if(target === undefined){
        player.outputChatBox('SERVER: /invite [Name]')
    } else {
        whatFaction(player).then(results => { //whatFaction gets player's faction and factionRank and (faction 0 means Civilian or no faction )
            let theTarget = mp.players.at(target)
            if(results[0].faction === 1 && results[0].factionRank > 5) {
                isInFaction(theTarget).then(results => {
                    if(results[0].faction !== 0) {
                        player.outputChatBox('SERVER: Invited player is already in a faction.')
                    } else {
                        theTarget.outputChatBox('SERVER: You have been invited to a faction, in order to join use /accept')
                      // code??
                    }
                })
            }
        })
    }
}) // by the way, usernames ( ingame names ) are unique

At this point I'm really out of clue on how to:

1- 'get the entered information from ONLY theTarget' ( since he's the only one who's getting invited )

2- 'use that specific information'

Thanks for reading and I really appreciate any response.

Link to comment
Share on other sites

12 hours ago, MeChill said:

Hey, Node issue

 

Nope, not a node issue. Basic programming and logic issue? Maybe. You've been told two times on discord how to do that but you ignored the answers. Just set a variable on the target data with which faction he was invited to, and when he runs command "accept invite"(for example) then check if variable is there and if it is then get it's value(which would be the faction) and put him there.

Link to comment
Share on other sites

I'd like to add that you should check whether entity exists in pool before going any further. Also I'm wondering how do you expect to get the target player's object here

let theTarget = mp.players.at(target)
            

since you're referring to players by their names and not ids (https://wiki.rage.mp/index.php?title=Pool::at)

If you insist on using unique names then make a function that loops the player pool, match names and return player.

 

Edited by Doom
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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