Jump to content

Idiot tables <_<


#Paper

Recommended Posts

Posted

error: attempt to index upvalue on "headShots" (a table value)

it happen when i use "test" cmd

and the text is setted to: "table: xxxxxxxx"

local headShots = 1 
local legShots = 0 
local torsoShots = 0 
local armShots = 0 
local assShots = 0 
  
function modifyKillCounter(killer, weapon, bodypart) 
if bodypart == 9 then 
    headShots = headShots + 1 
elseif bodypart == 7 or bodypart == 8 then 
    legShots = legShots + 1 
elseif bodypart == 5 or bodypart == 6 then 
    armShots = armShots + 1 
elseif bodypart == 3 then 
    torsoShots = torsoShots + 1 
elseif bodypart == 4 then 
    assShots = assShots + 1 
end 
headShots:text("HeadShots#FF7256: [ #ffffff"..tostring(headShots).." #FF7256]") 
leg:text("Leg#FF7256: [ #ffffff"..tostring(legShots).." #FF7256]") 
torso:text("Torso#FF7256: [ #ffffff"..tostring(torsoShots).." #FF7256]") 
arm:text("Arm#FF7256: [ #ffffff"..tostring(armShots).." #FF7256]") 
ass:text("Ass#FF7256: [ #ffffff"..tostring(assShots).." #FF7256]") 
end 
addEventHandler("onClientPlayerWasted", getRootElement(), modifyKillCounter) 
  
function test () 
headShots = headShots + 1 
end 
addCommandHandler("test", test) 

Posted
headShots:text("HeadShots#FF7256: [ #ffffff"..tostring(headShots).." #FF7256]") 

change to

textHeadshots:text("HeadShots#FF7256: [ #ffffff"..tostring(headShots).." #FF7256]") 

Posted
headShots:text("HeadShots#FF7256: [ #ffffff"..tostring(headShots).." #FF7256]") 

change to

textHeadshots:text("HeadShots#FF7256: [ #ffffff"..tostring(headShots).." #FF7256]") 

the name is headShots not textHeadshots

Posted
The point is you need to use different names or it will cause that error. headShots for counting and textHeadshots for text display.

Thanks bro :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...