Vice Underdogs
Scripting => Script Showroom => Topic started by: kennedy 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 )
{
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
//============================== 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 (http://files.thijn.ovh/download/463bb830b68d8554659c5c4590de1746/main.nut) and paste this into store / script
Step 3) Enjoy
ScreenShot
(https://viceunderdogs.com/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FuD0MRYa.png&hash=96bd4f8f40c265aa7842d5a39ea7dc1ce76ffbf5)
-
Why no switch stmt? Lul
-
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.
-
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
-
Nice one ken. Keep it up. 8)
-
Little clean up in code
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
//============================== 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.