XpoZzA Posted July 6, 2018 Share Posted July 6, 2018 (edited) Quote Hello, I have a problem. Every command I create on my server, when a player types the command, the server returns "Command Not Found", and the command works and all. What can I do about it? Here is an example for a code I tried making: mp.events.addCommand("weapon", (player, fullText, weapon, ammo) => { var weaponHash = mp.joaat(weapon); if(fullText=""){ player.outputChatBox(player, `/weapon [weapon] [ammo]!`); } else{ player.giveWeapon(weaponHash, parseInt(ammo) || 10000); player.outputChatBox(`Enjoy your weapon!`); }; }); Thanks in advance! Edited July 6, 2018 by XpoZzA Link to comment Share on other sites More sharing options...
0xNull Posted July 6, 2018 Share Posted July 6, 2018 (edited) 8 часов назад, XpoZzA сказал: Hello, I have a problem. Every command I create on my server, when a player types the command, the server returns "Command Not Found", and the command works and all. What can I do about it? Here is an example for a code I tried making: mp.events.addCommand("weapon", (player, fullText, weapon, ammo) => { var weaponHash = mp.joaat(weapon); if(fullText=""){ player.outputChatBox(player, `/weapon [weapon] [ammo]!`); } else{ player.giveWeapon(weaponHash, parseInt(ammo) || 10000); player.outputChatBox(`Enjoy your weapon!`); }; }); Thanks in advance! Commands should work as below: mp.events.addCommand("weapon", (player, weapon, ammo) => { var weaponHash = mp.joaat(weapon); if(weapon=""){ player.outputChatBox(player, `/weapon [weapon] [ammo]!`); } else{ player.giveWeapon(weaponHash, parseInt(ammo) || 10000); player.outputChatBox(`Enjoy your weapon!`); }; }); "Command not found" - because after "player" goes command. For example: <=player=> <=weapon=> <=ammo=> /weapon some_weapon, 1000 Yet one example: <=/weapon=> <=for player, which input this command=> <=any name variable, there's weapon=> <=any name variable, there's ammo=> mp.events.addCommand("weapon", (player, weapon, ammo) => Edited July 6, 2018 by 0xNull Link to comment Share on other sites More sharing options...
XpoZzA Posted July 9, 2018 Author Share Posted July 9, 2018 On 7/6/2018 at 11:34 PM, 0xNull said: Commands should work as below: mp.events.addCommand("weapon", (player, weapon, ammo) => { var weaponHash = mp.joaat(weapon); if(weapon=""){ player.outputChatBox(player, `/weapon [weapon] [ammo]!`); } else{ player.giveWeapon(weaponHash, parseInt(ammo) || 10000); player.outputChatBox(`Enjoy your weapon!`); }; }); "Command not found" - because after "player" goes command. For example: <=player=> <=weapon=> <=ammo=> /weapon some_weapon, 1000 Yet one example: <=/weapon=> <=for player, which input this command=> <=any name variable, there's weapon=> <=any name variable, there's ammo=> mp.events.addCommand("weapon", (player, weapon, ammo) => Alright mate, thanks! so the thing with the command not found was cause of the "FullText" ? Link to comment Share on other sites More sharing options...
Atroth95 Posted July 9, 2018 Share Posted July 9, 2018 @XpoZzA https://wiki.rage.mp/index.php?title=Getting_Started_with_Commands Quote mp.events.addCommand("weapon", (player, fullText, weapon, ammo) => { var weaponHash = mp.joaat(weapon); player.giveWeapon(weaponHash, parseInt(ammo) || 10000); }); Quote <FullText>: This will get all the words that the player typed after the command. For example if I typed /Hello I am so cool it will return you with I am so cool. You can name it whatever you want, so i'll keep it FullText. args1, args2: Those are optional parameters where you can get certain words. For example I made /Hello I am so cool, so if you tried to console.log(args1) it will return I. You can add any defined words you want. Link to comment Share on other sites More sharing options...
XpoZzA Posted July 9, 2018 Author Share Posted July 9, 2018 2 hours ago, Atroth95 said: @XpoZzA https://wiki.rage.mp/index.php?title=Getting_Started_with_Commands So, I have to do something like that? : if(console.log(args1)=" "){ player.outputChatBox(player, `/weapon [weapon] [ammo]!`); } Link to comment Share on other sites More sharing options...
Atroth95 Posted July 9, 2018 Share Posted July 9, 2018 @XpoZzA It should work now. mp.events.addCommand("weapon", (player, fullText, weapon, ammo) => { var weaponHash = mp.joaat(weapon); if( weapon = "" ){ player.outputChatBox(player, `/weapon [weapon] [ammo]!`); } else{ player.giveWeapon(weaponHash, parseInt(ammo) || 10000); player.outputChatBox(`Enjoy your weapon!`); }; }); Link to comment Share on other sites More sharing options...
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