Why not work my code?
shared.lua:
[code]
if ply:Player1() then
ply:StripWeapon("weapon_hands")
ply:Give("weapon_leg")
end
[/CODE]
give but not remove. What is the reason?
Hi giraff,
Have you tried replacing "ply:Player1()" with "ply:IsAlive()"? Also is "weapon_leg" a defined weapon?
Kind regards,
GriefMoDz
Player1 isn't a function (AFAIK)...
What are you trying to check with that? If they're the first player on the server? If their name is Player1? What are you trying to do?
[QUOTE=MPan1;49636336]Player1 isn't a function (AFAIK)...
What are you trying to check with that? If they're the first player on the server? If their name is Player1? What are you trying to do?[/QUOTE]
this is a functions
[QUOTE=giraff;49636352]this is a function[/QUOTE]
Well, it wasn't on the wiki so I just assumed it wasn't...
Anyway, have you tried doing
[CODE]
ply:StripWeapon("weapon_fists")
[/CODE]
Instead? Maybe you got the weapon name wrong
[QUOTE=MPan1;49636369]Well, it wasn't on the wiki so I just assumed it wasn't...
Anyway, have you tried doing
[CODE]
ply:StripWeapon("weapon_fists")
[/CODE]
Instead? Maybe you got the weapon name wrong[/QUOTE]
I'm trying to add code to the weapon
shared.lua:
[code]
function SWEP:Think()
if ply:Player1() then
ply:StripWeapon("weapon_hands")
ply:Give("weapon_leg")
end
end
[/code]
Well, did you try changing the strip weapon code from [B]weapon_hands[/B] to [B]weapon_fists[/B]?
In the code you just posted it wasn't changed and I think you have the weapon names wrong
Okay, so you're trying to strip "weapon_hands" and replace it with "weapon_leg"?
If that's correct, you should change the "ply:Player1()" function to "ply:HasWeapon("weapon_hands").
That should resolve the following issue you're having troubles with.
[QUOTE=GriefMoDz;49636400]Okay, so you're trying to strip "weapon_hands" and replace it with "weapon_leg"?
If that's correct, you should change the "ply:Player1()" function to "ply:HasWeapon("weapon_hands").
That should resolve the following issue you're having troubles with.[/QUOTE]
Except he said that in the OP that his code
[QUOTE]
give but not remove
[/QUOTE]
So the ply:Player1 function [B]would[/B] be working (since the other weapon gets given), but the[B] weapon removal code[/B] isn't (since the weapon isn't removed)
It's literally impossible to determine/establish that this specific function is outstanding, since he's only provided a small piece of his code rather than a full version...
Could you please provide a pastebin of your 'shared.lua' file? I'm certain that it'll make things easier for all of us.
giraff, did you try replacing
[CODE]
ply:StripWeapon("weapon_hands")
[/CODE]
With
[CODE]
ply:StripWeapon("weapon_fists")
[/CODE]
Yet? If you're trying to remove the default Garry's Mod hands SWEP that you can punch with and all that, then weapon_fists is the right name for it.
I know I said this about 3 times already, but in the other code you posted before (for some reason), it wasn't changed and I really think that's the problem.
Sorry, you need to Log In to post a reply to this thread.