Jump to content

Script Errors..help


Recommended Posts

Posted

Hello guys :) .. I made this script to set Levels every 100 Points in weapon skills...but i got some script ERRORS...may you help me with it?

Client:

function WeaponLevels (killer, weapon, bodypart) 
  
  
local Nothing = tonumber(getPedStat(killer, 69)) 
if Nothing = 100 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 1",Nothing) 
elseif Nothing = 200 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 2",Nothing) 
elseif Nothing = 300 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 3",Nothing) 
elseif Nothing = 400 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 4",Nothing) 
elseif Nothing = 500 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 5",Nothing) 
elseif Nothing = 600 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 6",Nothing) 
elseif Nothing = 700 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 7",Nothing) 
elseif Nothing = 800 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 8",Nothing) 
elseif Nothing = 900 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 9",Nothing) 
elseif Nothing = 1000 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 10",Nothing) 
end 
    end 
addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 
  

ERROR:

WeaponPoints.lua:125: 'then' expected near '=' 

Please help :(

Posted

try this:

function WeaponLevels (killer, weapon) 
  
  
local Nothing = tonumber(getPedStat(killer, 69)) 
if Nothing = 100 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 1",Nothing) 
elseif Nothing == 200 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 2",Nothing) 
elseif Nothing == 300 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 3",Nothing) 
elseif Nothing == 400 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 4",Nothing) 
elseif Nothing == 500 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 5",Nothing) 
elseif Nothing == 600 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 6",Nothing) 
elseif Nothing == 700 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 7",Nothing) 
elseif Nothing == 800 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 8",Nothing) 
elseif Nothing == 900 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 9",Nothing) 
elseif Nothing == 1000 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 10",Nothing) 
end 
    end 
addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 
  

To Visit Us

Press Here: mtasa://5.9.206.180:22002

b648040241b8f01.png

0d0a7bb38ca13e5.png

Posted

Use dxDrawText instead of guiSetText.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)

Try this:

function WeaponLevels (killer, weapon, bodypart) 
  
local Nothing = tonumber(getPedStat(killer, 69)) 
    if Nothing <= 100 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 1",Nothing) 
    elseif Nothing <= 200 and Nothing > 100 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 2",Nothing) 
    elseif Nothing <= 300 and Nothing > 200 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 3",Nothing) 
    elseif Nothing <= 400 and Nothing > 300 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 4",Nothing) 
    elseif Nothing <= 500 and Nothing > 400 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 5",Nothing) 
    elseif Nothing <= 600 and Nothing > 500 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 6",Nothing) 
    elseif Nothing <= 700 and Nothing > 600 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 7",Nothing) 
    elseif Nothing <= 800 and Nothing > 700 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 8",Nothing) 
    elseif Nothing <= 900 and Nothing > 800 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 9",Nothing) 
    elseif Nothing <= 1000 and Nothing > 900 and weapon == 22 then 
        guiSetText (GUIEditor.label[3], "Level: 10",Nothing) 
    end 
end 
addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 

Edited by Guest

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
try this:
function WeaponLevels (killer, weapon) 
  
  
local Nothing = tonumber(getPedStat(killer, 69)) 
if Nothing = 100 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 1",Nothing) 
elseif Nothing == 200 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 2",Nothing) 
elseif Nothing == 300 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 3",Nothing) 
elseif Nothing == 400 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 4",Nothing) 
elseif Nothing == 500 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 5",Nothing) 
elseif Nothing == 600 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 6",Nothing) 
elseif Nothing == 700 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 7",Nothing) 
elseif Nothing == 800 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 8",Nothing) 
elseif Nothing == 900 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 9",Nothing) 
elseif Nothing == 1000 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 10",Nothing) 
end 
    end 
addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 
  

Now i got another ERROR:

WeaponPoints_c.lua:128: 'then' expected near '=' 

Posted (edited)
try this:
function WeaponLevels (killer, weapon) 
  
  
local Nothing = tonumber(getPedStat(killer, 69)) 
if Nothing = 100 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 1",Nothing) 
elseif Nothing == 200 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 2",Nothing) 
elseif Nothing == 300 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 3",Nothing) 
elseif Nothing == 400 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 4",Nothing) 
elseif Nothing == 500 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 5",Nothing) 
elseif Nothing == 600 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 6",Nothing) 
elseif Nothing == 700 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 7",Nothing) 
elseif Nothing == 800 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 8",Nothing) 
elseif Nothing == 900 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 9",Nothing) 
elseif Nothing == 1000 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 10",Nothing) 
end 
    end 
addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 
  

Now i got another ERROR:

WeaponPoints_c.lua:128: 'then' expected near '=' 

The ERROR is here in :128:...Just shows because it's not the full script

    if Nothing = 100 and weapon = 22 then 

Edited by Guest
Posted
try this:
function WeaponLevels (killer, weapon) 
  
  
local Nothing = tonumber(getPedStat(killer, 69)) 
if Nothing = 100 and weapon = 22 then 
guiSetText (GUIEditor.label[3], "Level: 1",Nothing) 
elseif Nothing == 200 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 2",Nothing) 
elseif Nothing == 300 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 3",Nothing) 
elseif Nothing == 400 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 4",Nothing) 
elseif Nothing == 500 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 5",Nothing) 
elseif Nothing == 600 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 6",Nothing) 
elseif Nothing == 700 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 7",Nothing) 
elseif Nothing == 800 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 8",Nothing) 
elseif Nothing == 900 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 9",Nothing) 
elseif Nothing == 1000 and weapon == 22 then 
guiSetText (GUIEditor.label[3], "Level: 10",Nothing) 
end 
    end 
addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 
  

Now i got another ERROR:

WeaponPoints_c.lua:128: 'then' expected near '=' 

The ERROR is here in :128:...Just shows because it's not the full script

    if WeaponLevels = 100 and weapon = 22 then 

HEllo?!!! Are you here guys?

Posted

Try the code I edited above.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

I fixed an error, try it again.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
I fixed an error, try it again.

Again........Same ERROR...I think the error with Nothing = 100 ... about

local Nothing = tonumber(getPedStat(killer, 69))

if Nothing = 100

I think it's not correct? Please check :( ... I want the 100 Means....the Weapon Skill Points..Understand what i mean?

Posted

I did not put 'if Nothing = 100 ...' in my code.

Make sure you updated that resource on the server.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)
I did not put 'if Nothing = 100 ...' in my code.

Make sure you updated that resource on the server.

Okay now Tested your Script...ERROR:

WeaponPoints_c.lua:116: Bad Argument @ 'guiSetText' [Expected gui-element at argument 1,got nil 

Edited by Guest
Posted

Show us where is GUIEditor.label[3] defined.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
In guiSetText, remove ",Nothing"

lol!! look :116: is

function WeaponPoints() 
local WeaponPoints = getPedStat( localPlayer, 69 ); 
guiSetText( GUIEditor.label[2],"Points: "..WeaponPoints ); 
end 
addEventHandler( "onClientRender", root, WeaponPoints ); 

it's the script i use to set player points in the label...it was working 1000000% before i put this new script

    function WeaponLevels (killer, weapon) 
      
    local Nothing = tonumber(getPedStat(killer, 69)) 
        if Nothing <= 100 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 1") 
        elseif Nothing <= 200 and Nothing > 100 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 2") 
        elseif Nothing <= 300 and Nothing > 200 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 3") 
        elseif Nothing <= 400 and Nothing > 300 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 4") 
        elseif Nothing <= 500 and Nothing > 400 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 5") 
        elseif Nothing <= 600 and Nothing > 500 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 6") 
        elseif Nothing <= 700 and Nothing > 600 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 7") 
        elseif Nothing <= 800 and Nothing > 700 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 8") 
        elseif Nothing <= 900 and Nothing > 800 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 9") 
        elseif Nothing <= 1000 and Nothing > 900 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 10") 
        end 
    end 
end 
    addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 

Posted

it won't works

try this

function WeaponLevels (killer, weapon) 
      
    local Nothing = tonumber(getPedStat(killer, 69)) 
        if Nothing <= 100 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 1") 
        elseif Nothing <= 200 and Nothing > 100 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 2") 
        elseif Nothing <= 300 and Nothing > 200 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 3") 
        elseif Nothing <= 400 and Nothing > 300 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 4") 
        elseif Nothing <= 500 and Nothing > 400 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 5") 
        elseif Nothing <= 600 and Nothing > 500 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 6") 
        elseif Nothing <= 700 and Nothing > 600 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 7") 
        elseif Nothing <= 800 and Nothing > 700 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 8") 
        elseif Nothing <= 900 and Nothing > 800 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 9") 
        elseif Nothing <= 1000 and Nothing > 900 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 10") 
        end 
    end 
    addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 

To Visit Us

Press Here: mtasa://5.9.206.180:22002

b648040241b8f01.png

0d0a7bb38ca13e5.png

Posted
it won't works

try this

function WeaponLevels (killer, weapon) 
      
    local Nothing = tonumber(getPedStat(killer, 69)) 
        if Nothing <= 100 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 1") 
        elseif Nothing <= 200 and Nothing > 100 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 2") 
        elseif Nothing <= 300 and Nothing > 200 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 3") 
        elseif Nothing <= 400 and Nothing > 300 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 4") 
        elseif Nothing <= 500 and Nothing > 400 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 5") 
        elseif Nothing <= 600 and Nothing > 500 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 6") 
        elseif Nothing <= 700 and Nothing > 600 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 7") 
        elseif Nothing <= 800 and Nothing > 700 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 8") 
        elseif Nothing <= 900 and Nothing > 800 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 9") 
        elseif Nothing <= 1000 and Nothing > 900 and weapon == 22 then 
            guiSetText (GUIEditor.label[3], "Level: 10") 
        end 
    end 
    addEventHandler( "onClientRender",getRootElement(), WeaponLevels) 

ERROR:

:124: attempt to compare nil with number 

Warning:

:123: Bad Argument @ 'getPedStat' 

:116: Bad Argument @ 'guiSetText' [Expected gui-element at argument 1,got nil 

:123:...Script

        local Nothing = tonumber(getPedStat(killer, 69)) 

:116: Script

guiSetText( GUIEditor.label[2],"Points: "..WeaponPoints ); 

:116: its another function...but it was working 100% before i add this new script for levels...also i think this levels need server side or what?..please help

Posted
at 116 be sure that the label name is correct
        GUIEditor.label[2] = guiCreateLabel(80, 52, 87, 17, "Points: 0", false, GUIEditor.tab[1]) 

It's the Label...Correct right?

look Nevermind about this script problem...it's because i was puted guisetVisible... it was making A lot of ERRORS...

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...