Jump to content

Recommended Posts

Posted
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

Posted

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`)
    }
});

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