Jump to content
RAGE Multiplayer Community

Recommended Posts

mp.events.addCommand('pm', (player, _, playerID, msg) => { //mensagem privada
    let sourcePlayer = mp.players.at(parseInt(playerID))

    if(isNaN(parseInt(playerID)) || !msg){
        player.outputChatBox(`!{${info}}[INFO]: Use /pm [id] [msg]`)
    }
    else if (player == sourcePlayer){
        player.outputChatBox(`!{${erro}}[ERRO]: Você não pode mandar pm para você mesmo`)
    }
    else if (sourcePlayer) {
        player.outputChatBox(`!{${pm}} [PM ENVIADA] ${player.name}: ${msg}`)
        sourcePlayer.outputChatBox(`!{${pm}}[PM RECEBIDA] ${player.name}[${player.id}]: ${msg}`)
        console.log(`[PM] ${player.name}[${player.id}]: ${msg}`) //console
    } 
    else{
        player.outputChatBox(`!{${erro}}[ERRO]: Jogador não encontrado com esse ID`)
    }
});

only the first word of the message is sent, help

Link to post
Share on other sites

SOLVED!!

 

mp.events.addCommand('pm', (playermsg=> { //mensagem privada
 
    playerID = msg[0]
    let sourcePlayer = mp.players.at(parseInt(playerID))
 
    if(isNaN(parseInt(playerID)) || !msg.slice(2) || msg[1] != ` `){
        player.outputChatBox(`!{${info}}[INFO]: Use /pm [id] [msg]`)
    }
    else if (player == sourcePlayer){
        player.outputChatBox(`!{${erro}}[ERRO]: Você não pode mandar pm para você mesmo`)
    }
    else if (sourcePlayer) {
        player.outputChatBox(`!{${pm}} [PM ENVIADA] ${player.name}${msg.slice(2)}`)
        sourcePlayer.outputChatBox(`!{${pm}}[PM RECEBIDA] ${player.name}[${player.id}]: ${msg.slice(2)}`)
        console.log(`[PM] ${player.name}[${player.id}]: ${msg.slice(2)}`//console
    } 
    else{
        player.outputChatBox(`!{${erro}}[ERRO]: Jogador não encontrado com esse ID`)
    }
});
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...