login
March 28, 2024, 05:17:49 pm

Author Topic: [SNIPPED] Simple Wep commad  (Read 1324 times)

0 Members and 1 Guest are viewing this topic.

kennedy

  • Fanatic
  • ****
  • Posts: 144
  • Country: ve
  • American Roleplay
    • View Profile
[SNIPPED] Simple Wep commad
« on: April 12, 2017, 08:44:40 pm »
Wep Commad with client-side

Hello guys here I have made a simple command so that the player can choose his favorite weapon.

How Install 

Step 1)

Put the command in

function onPlayerCommand( player, cmd, text )
Code: [Select]
{
         cmd = cmd.tolower();
         if(cmd=="wep")
{
        Stream.StartWrite()
Stream.WriteInt(1)
Stream.SendStream(player)
  }


else MessagePlayer("[#FFFFFF]Invalid command Use",player)
if ( text == null ) text = "Nothing";
return 1;
}

And this at the end of the script

Code: [Select]
//============================== C L I E N T  S I D E  D A T A ==============================================//
function onClientScriptData(player)
{
local string = Stream.ReadString(), int = Stream.ReadInt();
    if(string == "wep0") player.SetWeapon(0,9999)
else if (string == "wep1") player.SetWeapon(1,9999)
else if (string == "wep2" ) player.SetWeapon(2,9999)
else if (string == "wep3") player.SetWeapon(3,9999)
else if (string == "wep4") player.SetWeapon(4,9999)
else if (string == "wep5") player.SetWeapon(5,9999)
else if (string == "wep6") player.SetWeapon(6,9999)
else if (string == "wep7") player.SetWeapon(7,9999)
else if (string == "wep8") player.SetWeapon(8,9999)
else if (string == "wep9") player.SetWeapon(9,9999)
else if (string == "wep10") player.SetWeapon(10,9999)
    else if (string == "wep11") player.SetWeapon(11,9999)
else if (string == "wep12") player.SetWeapon(12,9999)
else if (string == "wep13") player.SetWeapon(13,9999)
else if (string == "wep14") player.SetWeapon(14,9999)
else if (string == "wep15") player.SetWeapon(15,9999)
else if (string == "wep16") player.SetWeapon(16,9999)
else if (string == "wep17") player.SetWeapon(17,9999)
else if (string == "wep18") player.SetWeapon(18,9999)
else if (string == "wep19") player.SetWeapon(19,9999)
else if (string == "wep20") player.SetWeapon(20,9999)
else if (string == "wep21") player.SetWeapon(21,9999)
else if (string == "wep22") player.SetWeapon(22,9999)
else if (string == "wep23") player.SetWeapon(23,9999)
else if (string == "wep24") player.SetWeapon(24,9999)
else if (string == "wep25") player.SetWeapon(25,9999)
else if (string == "wep26") player.SetWeapon(26,9999)
else if (string == "wep27") player.SetWeapon(27,9999)
else if (string == "wep28") player.SetWeapon(28,9999)
else if (string == "wep29") player.SetWeapon(29,9999)
else if (string == "wep30") player.SetWeapon(30,9999)
else if (string == "wep31") player.SetWeapon(31,9999)
else if (string == "wep32") player.SetWeapon(32,9999)
else if (string == "disarm")
{
MessagePlayer("[#FF1111][DISARM] [#FFFFFF]You've been disarmed",player);
            player.Disarm();
}
}

Step 2)
Download and paste this into store / script

Step 3) Enjoy

ScreenShot

« Last Edit: April 23, 2017, 01:53:31 pm by kennedy »
Artistic Artistic x 5 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


HeLLHounD

  • Crazy Man
  • *****
  • Posts: 1333
  • Country: be
  • 666
    • View Profile
Re: [SNIPPED] Simple Wep commad
« Reply #1 on: April 12, 2017, 10:10:33 pm »
Why no switch stmt? Lul
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


Thijn

  • Forum Administrator
  • Crazy Man
  • *
  • *
  • *
  • Posts: 2946
  • Country: nl
    • View Profile
Re: [SNIPPED] Simple Wep commad
« Reply #2 on: April 13, 2017, 07:55:21 pm »
Why even use strings? Just send an int and check that for valid weapon ID and set that. Only a few lines of code, instead of this piece of poo.
Agree Agree x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

I'm not totally useless,
I can be used as an bad example ;)

"Never do Today, What you can do Tomorrow"


kennedy

  • Fanatic
  • ****
  • Posts: 144
  • Country: ve
  • American Roleplay
    • View Profile
Re: [SNIPPED] Simple Wep commad
« Reply #3 on: April 13, 2017, 08:52:22 pm »
Why even use strings? Just send an int and check that for valid weapon ID and set that. Only a few lines of code, instead of this piece of poo.

Done thx
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


Radon

  • Guest
Re: [SNIPPED] Simple Wep commad
« Reply #4 on: April 20, 2017, 05:42:19 pm »
Nice one ken. Keep it up.  8)
Cannot rate own posts


Thomas

  • Guest
Re: [SNIPPED] Simple Wep commad
« Reply #5 on: April 21, 2017, 07:25:17 am »
Little clean up in code
Code: [Select]
function onPlayerCommand( player, cmd, text )
{
         cmd = cmd.tolower();
         if(cmd=="wep")
{
        Stream.StartWrite();
Stream.WriteInt(GetWeaponID(text.tolower()));
Stream.SendStream(player);
  }
          else if( cmd == "disarm" )
          {
            Stream.StartWrite();
Stream.WriteInt(255);
Stream.SendStream(player);
          }

}

And this at the end of the script

Code: [Select]
//============================== C L I E N T  S I D E  D A T A ==============================================//

function onClientScriptData(player)
{
wep_id = Stream.ReadInt();

if( wep_id >= 0 && wep_id <= 32 )
{
player.SetWeapon(wep_id,9999);
MessagePlayer("[#FF1111][Weapon] [#FFFFFF]You've been given "+GetWeapoName(wep_id)+" with 9999 ammo",player);
}
else
{

MessagePlayer("[#FF1111][DISARM] [#FFFFFF]You've been disarmed",player);
            player.Disarm();
}
}
P.S i have never used 0.4 server before. so i guess its okay.
« Last Edit: April 21, 2017, 08:04:08 am by Thomas »
Winner Winner x 1 Useful Useful x 1 (list)
Cannot rate own posts