How to give a player a weapon? :D

Started by NicusorN5, Mar 30, 2016, 06:21 PM

Previous topic - Next topic

NicusorN5

:D I'm scripting my server called Romania Roleplay.
I will use this
if(cmd == "wep")
{
 if(!text == "Minigun")
 {
  (gives the player a minigun :D )
 {
{

Can you help me? :)

.

#1
The server name is really not necessary. And the answer to your question is GetWeaponID("weapon name"); Which attempts to find the weapon ID from the name you gave it. Works the same way as this command to change the player skin. You just need to adjust it for weapons.

NOTE: Some weapon names could give unexpected results. I think there is a topic on the forum discussing that. Forgot which :-\
.

Thijn

@Luis_Labarca please stop double posting. If you have something to add to your post just use the Modify button.
I'm not even gonna start about the horrible code you posted. I feel sorry for anyone who's going to play in a server made by you.

MaTaDeToR

#3
Quote from: NicusorN5 on Mar 30, 2016, 06:21 PM:D I'm scripting my server called Romania Roleplay.
I will use this
if(cmd == "wep")
{
 if(!text == "Minigun")
 {
  (gives the player a minigun :D )
 {
{

Can you help me? :)
Alright without making any mess! i'm just gonna simply give you an example with an explanation....
if ( cmd =="wep" )
{
 if ( text ) // simply text...
      {
         if ( IsNum( text ) ) // we are gonna check that if it's a ID, if not it will give a error
               {   local wep = text; // simply creating a variable...
                   if ( wep.tointeger() < 34 ) // The IDS shouldn't be above than 33!
                      {
                        if ( GetWeaponName(wep.tointeger()) != "Minigun" ) // we also don't want it to be a //Minigun
                                    {
                                 ClientMessage("You have recieved a " + GetWeaponName(wep.tointeger()) + "",player,255,255,0);
                                 player.SetWeapon( wep.tointeger(), 250 ); // a function in WIKI to set the weapon
                                  }// let's work on the errors now in the row
                   else ClientMessage("You can't spawn MiniGun",player,255,255,0); // if the id is 33, we //don't want Mini
                    }
          else ClientMessage("You can also use the ids within <1-32>",player,255,255,0);// it should be //under 1-32
          }
   else ClientMessage("ID should be in number <1-33>",player,255,255,0);//IDS <1-33> here....
   }
else ClientMessage("" + cmd + " <1-32>",player,255,255,0);//Check text, it should be more than one //len
}
MORE: Well, simply we just have to check that The ID  is in integer or not, else we also have to check the len, it should be 1, simply as you want Weapon, the id's are not more than, 33! their are, but not, for the shooting purpose. As i've seen your code, you want to disable the Mini, so we have simply disabled/ not allowing Minigun's ID, and then simply just use the function to give Weapon from the WIKI

NicusorN5