SA-MP Forums Archive
Remove melee weapons? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Remove melee weapons? (/showthread.php?tid=616554)



Remove melee weapons? - RomanianProjectCommunity - 06.09.2016

Hello, it seems that ResetPlayerWeapons or SetPlayerAmmo won't effect melee weapons.
How can i remove them? I want the player to not have them when they write a command.


Re: Remove melee weapons? - SickAttack - 06.09.2016

ResetPlayerWeapons does, though.


Re: Remove melee weapons? - RomanianProjectCommunity - 06.09.2016

No, ResetPlayerWeapons does not work for melee weapons


Re: Remove melee weapons? - SickAttack - 06.09.2016

Are you sure?

pawn Код:
// ** INCLUDES

#include <a_samp>
#include <zcmd>

// ** MAIN

main()
{
    print("Loaded \"blank.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// ** COMMANDS

CMD:melee(playerid)
{
    GivePlayerWeapon(playerid, WEAPON_KATANA, 1);
    return 1;
}

CMD:remove(playerid)
{
    ResetPlayerWeapons(playerid);
    return 1;
}
http://imgur.com/a/yO9oI


Re: Remove melee weapons? - RomanianProjectCommunity - 06.09.2016

http://imgur.com/a/prfTQ

pretty sure it doesn't work, i tested it with 3 guys


Re: Remove melee weapons? - RomanianProjectCommunity - 06.09.2016

new iCurWeap = GetPlayerWeapon(playerid),ammo = GetPlayerAmmo(playerid); // Return the player's current weapon
if(iCurWeap != GetPVarInt(playerid, "iCurrentWeapon")) // If he changed weapons since the last update
{
OnPlayerChangeWeapon(playerid, GetPVarInt(playerid, "iCurrentWeapon"), ammo);
//SetPVarInt(playerid, "iCurrentWeapon", iCurWeap);//Update the weapon variable
}

stock OnPlayerChangeWeapon(playerid, oldweapon, ammo)
{
if(oldweapon)GivePlayerWeapon(playerid,oldweapon,a mmo);
}

i think the problem could be this, because i don't let players to have more than one weapon in their inventory.. but the problem is only with the melee weapons


Re: Remove melee weapons? - SickAttack - 06.09.2016

Try the code I posted alone, you'll see that it does. It's most likely a problem with your script.


Re: Remove melee weapons? - RomanianProjectCommunity - 06.09.2016

Yes, it works that way. Now i have to check the script i posted above, because that's the problem.

Do you have any idea why that script works only with non-melee weapons?


Re: Remove melee weapons? - SickAttack - 06.09.2016

Yeah, it's pretty obvious.

SetPVarInt(playerid, "iCurrentWeapon", 0);


Re: Remove melee weapons? - RomanianProjectCommunity - 06.09.2016

and where should i put SetPVarInt(playerid, "iCurrentWeapon", 0); ?

it works perfect with non-meele weapons