Floriian Posted May 9, 2020 Posted May 9, 2020 (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 May 9, 2020 by Floriian
Floriian Posted May 11, 2020 Author Posted May 11, 2020 (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 May 11, 2020 by Floriian
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now