Jump to content

Problem with any command I'm trying to create.


Recommended Posts

Posted (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 by XpoZzA
Posted (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 by 0xNull
Posted
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" ?

Posted

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

     

     

Posted

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

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