Jump to content
RAGE Multiplayer Community

Recommended Posts

Posted (edited)

Hello,

So I moved to JAVASCRIPT from C# 'cause C# is too much complicated for me.

mp.events.addCommand("w", (player, target, message) => {
    let newTarget = mp.players.at(target)
    player.outputChatBox(`${player.name} to ${newTarget.name}: ${message}`);
    newTarget.outputChatBox(`From ${player.name}: ${message}`);
});

and i always get this:

TypeError: Cannot read property 'name' of undefined
    player.outputChatBox(`${player.name} to ${newTarget.name}: ${message}`);

when I remove player.outputChatBox, and only have newTarget.outputChatbox, get this:
 

TypeError: Cannot read property 'outputChatBox' of undefined
    newTarget.outputChatBox(`From:${player.name}: ${message}`);

 

Edited by Floriian
Link to post
Share on other sites
Posted (edited)

Some problem, another command...
Another command got deleted

mp.events.addCommand("mute", (player, target, reason) => {
    if(player.admin >= 3) 
    {
        if(target == null) return player.outputChatBox(`!{32a852}[HASZNÁLAT]: !{ffffff} /mute [Játékos] [Indok]`);
        if(reason == null) return player.outputChatBox(`!{32a852}[HASZNÁLAT]: !{ffffff} /mute [Játékos] [Indok]`);
        let newTarget = mp.players.at(target);
        console.log(newTarget); //<--- OUTPUT UNDEFINED
        if(newTarget === null) return player.outputChatBox(`!{b82e2e}[HIBA]: !{ffffff} Nem elérhető játékos!`);
        newTarget.muted = true; 
        newTarget.outputChatBox(`!{b82e2e}[ADMIN]: Lelettél muteolva ${player.name} által! Indok: ${reason}`);
    }
    else
    {
        player.outputChatBox(`!{b82e2e}[HIBA]: !{ffffff} Nincs ehhez jogosultságod!`);
    }
});

 

Edited by Floriian
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...