Custom Weapons

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

Previous topic - Next topic

BigcaT_

and numbers can't use xx.tolower()

PsyChO_KiLLeR

i add command that u give me but again error
Expresion Expected

When i remove your command server works fine
error in your cmd of expression expected

MacTavish

Quote from: Beztone on Mar 03, 2015, 08:42 AMChange 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


I updated code try again

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

Retired VC:MP Player/Scripter :P

Kratos_

#18
I'm seeing that you guys are writing something like this :-
if( text.tointeger() == "100" ) player.SetWeapon( 100,999);

Lets say you added a custom weapon named "Dragonuv" of logical id 100 in your server . Will converting "Dragonuv" to integer return 100 ? Ofcourse not . I guess , you got this idea of converting to integer from this code-section of Findplayer :-

if(IsNum(text)) FindPlayer( text.tointeger());

IsNum(9);  // will throw error [ parameter has invalid type. status : integer, expected : string ]
IsNum("9");  // will succeed [ IsNum itself expects a numeric value in double quotes ]

"Dragonuv".tointeger()     // will throw error [ Error converting the string ]
"100".to integer()     // will succeed [ will return a value of type int ]

So , you can make use of GetweaponID( string ) as S.L.C is saying .  Try to check that whether it works for custom weapon too or not .
If it works for custom weapons too then its ok otherwise make a custom function for switching the weapon ID from its name and then set him the weapon using player.SetWeapon( <id>, <ammo> ) as Thijn stated above .
Since Custom weapon XML config takes the weapon name & ID , so both the methods should work .  Do not forget to eliminate any invalid weapon id through creating conditions  .  I do not remember those condition well .  Stormeus have made such a condition in PB#3 to throw the message of invalid weapon ID  .  He released somewhere this . You can check that condition from there .
In the middle of chaos , lies opportunity.

PsyChO_KiLLeR

not working when i type /wep 100 or /wep 101 it say Id must be in number

PsyChO_KiLLeR

so what is solution Kratos?

MacTavish

#21
So what about this kratos :)
else if ( cmd == "wep" || cmd == "buy" ) // command
{
if ( text )
{
if (player.IsSpawned)
{if (IsNum ( text ))
{
if ( text == "100" )
{
MessagePlayer( "You Bought Custom Weapon", player );
player.SetWeapon( 100,999);
}
else if ( text == "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 );
}

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

Retired VC:MP Player/Scripter :P

PsyChO_KiLLeR

Thank u Beztone and other also for help
Problem Solve
Topic Locked