Sign in to follow this  
XpoZzA

Problem with any command I'm trying to create.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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" ?

Share this post


Link to post
Share on other sites

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

     

     

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.