I am no professional coder, but have been running and developing a gmod server (Stranded gamemode) very successfully with custom stuff and some code written from scratch, and I’m having a blast learning some lua
On to the help needed:
Stranded is a survival mode, for those who don’t know, and when a player Mines on a rock, they get ores. K, great.
When they do so, a menu called Skills gets an entry called “Mining”. awesome.
Once that player hits the max value for skill level in “Mining” I’d like the word in their skill menu “Mining” to become “Mining II”.
The code I originally used was an attempt to add the " II" prefix to the already existing “Mining” string. That resulted in lua created an additional entry under “Mining” skill as “Mining II” instead of appending it.
The code was similar to this:
ply:setSkill( "Mining" .. " II" )
Here is the gmod lua that should assist you all in helping me getting the correct syntax for this to work properly…
All of this is default code from the gamemode all I have added is the last “if” statement. Will that work for me??
p.s. the self.Owner:HasUnlock( “Mining_II” ) works elsewhere in game and I have other unlocks that I’ve used successfully. The part I need help with is getting the Mining to change to Mining II once they’ve unlocked a certain level of Mining.
function PlayerMeta:SetSkill( skill, int )
skill = string.Capitalize( skill )
if ( !self.Skills[ skill ] ) then self.Skills[ skill ] = 0 end
if ( skill != "Survival" ) then
int = math.Clamp( int, 0, 200 )
else
self.MaxResources = ( int * 5 ) + 25
end
self.Skills[ skill ] = int
umsg.Start( "gms_SetSkill", self )
umsg.String( skill )
umsg.Short( self:GetSkill( skill ) )
umsg.End()
end
function PlayerMeta:GetSkill( skill )
skill = string.Capitalize( skill )
if ( skill == "Survival" ) then self:SetNWInt( skill, self.Skills[skill] ) end
return self.Skills[ skill ] or 0
end
function PlayerMeta:IncSkill( skill, int )
skill = string.Capitalize( skill )
if ( !self.Skills[ skill ] ) then self:SetSkill( skill, 0 ) end
if ( !self.Experience[ skill ] ) then self:SetXP( skill, 0 ) end
if ( skill != "Survival" ) then
int = math.Clamp( int, 0, 200 )
for id = 1, int do self:IncXP( "Survival", 20 ) end
self:SendMessage( string.Replace( skill, "_", " " ) .. " +" .. int, 3, Color( 10, 200, 10, 255 ) )
else
self.MaxResources = self.MaxResources + 5
self:SendAchievement( "Level Up!" )
end
self.Skills[skill] = self.Skills[skill] + int
umsg.Start( "gms_SetSkill", self )
umsg.String( skill )
umsg.Short( self:GetSkill( skill ) )
umsg.End()
self:CheckForUnlocks()
if self.Owner:HasUnlock( "Mining_II" ) then self.Skills["Mining"] = self.Skills["Mining II"] end -- Will this do what I want it to do? or am I way off base here? This seems to easy for it to work like i want.
end
Will update if i figure it out before I get a response. Thanks all!!!