Jump to content

[Resolved]Unexpected Symbol Near


MrDante

Recommended Posts

Well in the line 21 I have this:

function show_wanted_players(plr) 
    local c = 0 
    local cx,cy,cz = getElementPosition(plr) 
    for k,v in pairs(getElementsByType("player")) do 
        local x,y = getWl(v) 
        local px,py,pz = getElementPosition(v) 
        if x > 0 then 
            local dist = getDistanceBetweenPoints3D(px,py,pz, cx,cy,cz) 
            if getElementData(v, "Jailed") == "Yes" then 
                outputChatBox(getPlayerName(v)..": Está com o nivel de procurado: "..round(x, 2).."e o tempo de Violência: ".. 
                    round(y, 2)..", Location: "..getZoneName(px,py,pz).." ("..getZoneName(px,py,pz,true)..") "..math.floor(dist).."m", plr, 0, 200, 0) 
            elseif (tonumber(getElementData(v, "violent_seconds")) or 0) > 0 then 
                outputChatBox(getPlayerName(v)..": Está com o nivel de procurado: "..round(x, 2).."e o tempo de Violência: "..round(y, 2)..", Location: " 
                ..getZoneName(px,py,pz).." ("..getZoneName(px,py,pz,true)..") "..math.floor(dist).."m", plr, 200, 0, 0) 
            else 
                outputChatBox(getPlayerName(v)..": Está com o nivel de procurado: "..round(x, 2).."e o tempo de Violência: ".. 
                    round(y, 2)..", Visto Cometendo Crime Em: "..getZoneName(px,py,pz).." ("..getZoneName(px,py,pz,true)..") "..math.floor(dist).."m", plr, 255, 100, 0) 
            if showWho ~= true then 
            outputChatBox("#1E90FFVocê está revistando o Jogador #FF0000[ #FFFFFF"..getPlayerName(thePlayer).. 
            outputChatBox(getPlayerName(source).."#1E90FFEstá revistando o jogador #FF0000[ #FFFFFF"..getPlayerName(thePlayer).. 
            end 
        end 
        c = c + 1 
    end 
    end 
    if c == 0 then 
        outputChatBox("Jogador Limpo!", plr, 255, 100, 0) 
    end 
end 
addCommandHandler("revistar", show_wanted_players, setRootElement(), getPlayerFromPartialName) 

I am a beginner and is giving the error:Unexpected Symbol Near

If someone can help me thank you very much

Edited by Guest
Link to comment

There are several problems:

1.)

addCommandHandler("revistar", show_wanted_players, setRootElement(), getPlayerFromPartialName) 

This line doesn't make sense as addCommandHandler expects the command name as first argument and the function as second argument. The other parameters are not relevant in this context.

So it should be as follows:

addCommandHandler("revistar", show_wanted_players) 

2.) I'm not sure what you want to achieve exactly, but I guess plr should be the player element that was passed through the command. But plr is the player who typed the command here (see addCommandHandler's wiki page)

function show_wanted_players(player, cmd, playerName) 
    -- Get the player by partial name 
    local plr = getPlayerFromPartialName(playerName) 
    -- do all the other stuff here 

3.)

outputChatBox("#1E90FFVocê está revistando o Jogador #FF0000[ #FFFFFF"..getPlayerName(thePlayer).. 

.. is the string concatenation operator and expects a string at both the right and left.

So probably something like this:

outputChatBox("#1E90FFVocê está revistando o Jogador #FF0000[ #FFFFFF"..getPlayerName(thePlayer).."]") 

4.) Missing ends. Indentation helps here.

Fixed and correctly indented version:

function show_wanted_players(player, cmd, playerName) 
    local plr = getPlayerFromPartialName(playerName) 
    local c = 0 
    local cx,cy,cz = getElementPosition(plr) 
    for k,v in pairs(getElementsByType("player")) do 
        local x,y = getWl(v) 
        local px,py,pz = getElementPosition(v) 
        if x > 0 then 
            local dist = getDistanceBetweenPoints3D(px,py,pz, cx,cy,cz) 
            if getElementData(v, "Jailed") == "Yes" then 
                outputChatBox(getPlayerName(v)..": Está com o nivel de procurado: "..round(x, 2).."e o tempo de Violência: ".. 
                    round(y, 2)..", Location: "..getZoneName(px,py,pz).." ("..getZoneName(px,py,pz,true)..") "..math.floor(dist).."m", plr, 0, 200, 0) 
            elseif (tonumber(getElementData(v, "violent_seconds")) or 0) > 0 then 
                outputChatBox(getPlayerName(v)..": Está com o nivel de procurado: "..round(x, 2).."e o tempo de Violência: "..round(y, 2)..", Location: " 
                  ..getZoneName(px,py,pz).." ("..getZoneName(px,py,pz,true)..") "..math.floor(dist).."m", plr, 200, 0, 0) 
            else 
                outputChatBox(getPlayerName(v)..": Está com o nivel de procurado: "..round(x, 2).."e o tempo de Violência: ".. 
                  round(y, 2)..", Visto Cometendo Crime Em: "..getZoneName(px,py,pz).." ("..getZoneName(px,py,pz,true)..") "..math.floor(dist).."m", plr, 255, 100, 0) 
            end 
            if showWho ~= true then 
              outputChatBox("#1E90FFVocê está revistando o Jogador #FF0000[ #FFFFFF"..getPlayerName(thePlayer).."]") 
              outputChatBox(getPlayerName(source).."#1E90FFEstá revistando o jogador #FF0000[ #FFFFFF"..getPlayerName(thePlayer).."]") 
            end 
        end 
        c = c + 1 
    end 
    if c == 0 then 
        outputChatBox("Jogador Limpo!", plr, 255, 100, 0) 
    end 
end 
addCommandHandler("revistar", show_wanted_players) 

Link to comment

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