gmodlife / stronghold

Automatically exported from code.google.com/p/stronghold
0 stars 0 forks source link

Hats is not Equip (Me Fixed) #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
This Error : 
[garrysmod\gamemodes\stronghold\gamemode\loadout.lua:64] attempt to call method 
'IsDonator' (a nil value)

Plz Fix this code : 

(loadout.lua) 64 lines

local function SH_EquipHat( ply, cmd, args )
    if !GAMEMODE.ValidHats[args[1]] then args[1] = "" end
    --if !ply:IsDonator() and GAMEMODE.DonatorHats[args[1]] then args[1] = "" end
    ply:EnableHat( args[1] )
end
concommand.Add( "sh_equiphat", SH_EquipHat )

fixed :)

What version of the product are you using? On what operating system?

svn 22 lastest

Please provide any additional information below.

This is good mode
plz add intro song and more maps ..
death drop weapon   to use (Now is not use)

Original issue reported on code.google.com by jinnin1...@gmail.com on 23 Nov 2011 at 8:36

GoogleCodeExporter commented 8 years ago
Hi. I didn't know about this website. I just found it.

But for this issue I would say do not just comment the line as I guess setting 
args[1] to empty for non donators must be done for a reason (I didn't check 
further but actually I suppose giving empty to 'EnableHat' just doesn't do 
anything, or would only warn the player that he's not allowed). Here I think 
the method was given to donators but not to other players so it cannot be 
called. I would just add a check like this instead :

local function SH_EquipHat( ply, cmd, args )
    if !GAMEMODE.ValidHats[args[1]] then args[1] = "" end
    if ply.IsDonator and !ply:IsDonator() and GAMEMODE.DonatorHats[args[1]] then args[1] = "" end
    ply:EnableHat( args[1] )
end
concommand.Add( "sh_equiphat", SH_EquipHat )

'ply.IsDonator' will return nil and thus be considered false by the check.

Original comment by greg.bl...@hotmail.com on 18 Apr 2012 at 12:05

GoogleCodeExporter commented 8 years ago
Also I had started this thread on the forums : 
http://g4p.org/Forum/showthread.php?tid=51. But it might just remain useless 
now. But still it can be good to keep things at multiple places.

Original comment by greg.bl...@hotmail.com on 18 Apr 2012 at 12:07