• Won't give me weapons and thinks a number is a string
    2 replies, posted
Here is my init.lua. I am deriving from sandbox. [lua] ----------Adding lua files---------- AddCSLuaFile( "cl_init.lua" ) //Tell the server that the client need to download cl_init.lua AddCSLuaFile( "shared.lua" ) //Tell the server that the client need to download shared.lua include( 'shared.lua' ) //Tell the server to load shared.lua function GM:PlayerLoadout(ply) ply:Give("weapon_smg1") end function GM:PlayerSpawn(ply) ply:SetPData("Armor", 2) ply:SetWalkSpeed(250) ply:SetRunSpeed(250) ply:SetModel("models/player/kleiner.mdl") end function GM:ScalePlayerDamage(ply, hitgroup, dmginfo) if hitgroup == HITGROUP_HEAD then dmginfo:ScaleDamage(100) end if hitgroup == HITGROUP_CHEST or HITGROUP_STOMACH then if ply:GetPData("Armor") < 1 then dmginfo:ScaleDamage(2) else dmginfo:ScaleDamage(0) ply:SetPData("Armor", ply:GetPData("Armor") - 1) end end if hitgroup == HITGROUP_LEFTARM or HITGROUP_RIGHTARM then local plyweapon = ply:GetActiveWeapon() if plyweapon:IsValid() then local weaponname = plyweapon:GetClass() local plypos = ply:GetPos() ply:StripWeapon(weaponname) local droppedweapon = ents.Create(weaponname) droppedweapon:SetPos(plypos + Vector(0, 10, 0)) droppedweapon:Spawn() --end end end if hitgroup == HITGROUP_LEFTLEG or HITGROUP_RIGHTLEG then ply:SetWalkSpeed(150) ply:SetRunSpeed(150) end end [/lua] When I use this code, however, I don't spawn with an smg1, and when I am shot in the chest it prints and error on line 29, saying I am trying to compare a number and string. Please help, I hope I'm not missing something obvious.
Afaik PData always returns a string, use tonumber.
Really? Wow, I never knew that. . .Thank you! [editline]17th August 2011[/editline] The funny thing is that I thought of that, then was like "Nah, I clearly defined it as a number." [editline]17th August 2011[/editline] I've been testing with NPCs shooting me, and the dmginfo:ScaleDamage won't work. Could this be because C++ HL2 weapons don't use CTakeDamageInfo?
Sorry, you need to Log In to post a reply to this thread.