Custom Weapons

Started by PsyChO_KiLLeR, Mar 02, 2015, 01:23 PM

Previous topic - Next topic

PsyChO_KiLLeR

Description:Well i have added custom weapons they are working well but i have to type /exec FindPlayer(0).SetWeapon( weaponid,ammo); i want it to change into /wep id how i change?

MacTavish

else if (cmd == "wep1" )
{
player.SetWeapon( weaponid. Ammo);
MessagePlayer("Wow You've Got Custom Weapon Its Amazing Nah",player);
}


Weaponid // put your custom weapon id here
Ammo // How much ammo you wanna give to player

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

You can use GetWeaponID(string); and pass the weapon name instead of prefixing your commands with the weapon ID. You simply have one command /wep that takes a string (the weapon name) and then use that string to get the actual weapon ID.

And example is available here but for the player skins.
.

PsyChO_KiLLeR

can i get like /wep name/id
can i add this like?

.

Quote from: PsyChO_KiLLeR on Mar 02, 2015, 01:45 PMcan i get like /wep name/id
can i add this like?

Yes, you can. You just need to do a few more checks to know when the argument is an ID or just a string. I'll be back later with an example.
.

PsyChO_KiLLeR


BigcaT_

player.SetWeapon( IsNum(text) ? text.tointeger() : GetWeaponID( text ), ammo );

PsyChO_KiLLeR

what your mean?
where i add this?

BigcaT_

Quote from: PsyChO_KiLLeR on Mar 02, 2015, 01:52 PMwhat your mean?
where i add this?
else if ( cmd == "wep" || cmd == "buy" ) // command
{
if ( !text ) MessagePlayer( "[Syntax] - !wep <Wep Name/ID>", player );
else if ( !player.IsSpawned ) MessagePlayer("You aren't Spawned.",player); // check player if spawn
else
{
MessagePlayer( "You Bought [#ffffff]" + text , player );
player.SetWeapon( IsNum(text) ? text.tointeger() : GetWeaponID( text ),ammo );     
                        // if text is numbers ,  tointeger.        else, GetWeaponid from text
                }
}

PsyChO_KiLLeR

its not working i want it for all weps inculding previous like stu and my custom weps in one cmd

.

Quote from: PsyChO_KiLLeR on Mar 02, 2015, 03:15 PMits not working i want it for all weps inculding previous like stu and my custom weps in one cmd

You mean like Player.GiveWeapon(); ? instead of Player.SetWeapon();
.

PsyChO_KiLLeR

yes Like when i type/wep stu it come then how to add in this wep command /wep ak /wep blah blah all in one command

Thijn

You're going to need to add a function that will first try to get the weapon ID by using GetWeaponID. If that fails (For "ak", for example), you can add a switch that will go through your custom weapons and return their ID.

Try to use your brain this time and make it yourself. I've told you everything you need to know. Feel free to post when you encounter an error which you need help with, though.

PsyChO_KiLLeR

well i create a cmd for these custom weapons but it give me error i cant post screenshot because its not working so error is expression expected


There is Command
  else if ( cmd == "wep" || cmd == "buy" ) // command
{
if ( !text ) MessagePlayer( "[Syntax] - !wep <Wep Name/ID>", player );
else if ( !player.IsSpawned ) MessagePlayer("You aren't Spawned.",player); // check player if spawn
if ( text.tolower() == "100" )
{
MessagePlayer( "You Bought Custom Weapon", player );
SetWeapon( 100,999);
else if ( text.tolower() == "101" )
{
MessagePlayer( "You Bought Custom Weapon", player );
SetWeapon( 101,999);
}
}
}

MacTavish

#14
Change SetWeapon( 100,999); SetWeapon( 101,999);  to player.SetWeapon( 100,999); player.SetWeapon( 101,999);

If it not solve your problem then try else if ( cmd == "wep" || cmd == "buy" ) // command
{
if ( text )
{
if (player.IsSpawned)
{
if ( text.tointeger() == "100" )
{
MessagePlayer( "You Bought Custom Weapon", player );
player.SetWeapon( 100,999);
}
else if ( text.tointeger() == "101" )
{
MessagePlayer( "You Bought Custom Weapon", player );
player.SetWeapon( 101,999);
}
else MessagePlayer( "[Error] - ID must be in numbers", player );
}
else MessagePlayer( "[Error] - You have'nt spawned yet!", player );
}
else MessagePlayer( "[Syntax] - /wep <Wep Name/ID>", player );
}

UPDATED

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P