Jump to content

Why this error?


Clydian

Recommended Posts

Posted
function removeOOC(text) 
    return text:gsub("%s*%(%(([^)]+)%)%)%s*","") 
end 

debugscript3 says that that line return text:gsub("%s*%(%(([^)]+)%)%)%s*","") is the error, why?

Posted

Looks alright to me. Maybe you didn't pass "text" as string?

function removeOOC(text) 
    return tostring(text):gsub("%s*%(%(([^)]+)%)%)%s*","") 
end 

Posted
Looks alright to me. Maybe you didn't pass "text" as string?

Indeed, it is in fact working fine here. So yeah, perhaps it is not a string. What is the debug error either way?

Posted
Looks alright to me. Maybe you didn't pass "text" as string?
function removeOOC(text) 
    return tostring(text):gsub("%s*%(%(([^)]+)%)%)%s*","") 
end 

Thank you so so much.. oh and theres another problem, posted it yesterday noone helped me.. maybe you have any ideas?

function givePlayerBadge(thePlayer, commandName, targetPlayer, ... ) 
    local badgeNumber = table.concat( { ... }, " " ) 
    badgeNumber = #badgeNumber > 0 and badgeNumber 
    local theTeam = getPlayerTeam(thePlayer) 
    local teamID = getElementData(theTeam, "id") 
     
    local badge = nil 
    local itemID = nil 
    local prefix = "" 
    for k, v in pairs(badges) do 
        for ka, va in pairs(v[3]) do 
            if ka == teamID then 
                badge = v 
                itemID = k 
                prefix = type(va) == "string" and ( va .. " " ) or "" 
            end 
        end 
    end 
    if not badge then return end 
     
    local leader = getElementData(thePlayer, "factionleader") 
     
    if not (tonumber(leader)==1) then 
        outputChatBox("You must be a faction leader to issue badges.", thePlayer, 255, 0, 0) 
    else 
        if not targetPlayer or not badgeNumber then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [badge Number]", thePlayer, 255, 194, 14) 
        else 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) 
            if targetPlayer then 
                local targetPlayerName = targetPlayerName:gsub("_", " ") 
                local logged = getElementData(targetPlayer, "loggedin") 
                if (logged==0) then 
                    outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0) 
                else 
                    local x, y, z = getElementPosition(thePlayer) 
                    local tx, ty, tz = getElementPosition(targetPlayer) 
                    if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)>4) then 
                        outputChatBox("You are too far away to issue this player a badge.", thePlayer, 255, 0, 0) 
                    else 
                        exports.global:sendLocalMeAction(thePlayer, "issues "..targetPlayerName.." " .. badge[2] .. ", reading " .. badgeNumber .. ".") 
                        exports.global:giveItem(targetPlayer, itemID, prefix .. badgeNumber) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("issuebadge", givePlayerBadge, false, false) 

Posted

That's because the badge number you entered either does not exist or your factions aren't configured correctly. (Is this from Valhalla?) Show me badges table. Also tell me what it outputs:

function givePlayerBadge(thePlayer, commandName, targetPlayer, ... ) 
    local badgeNumber = table.concat( { ... }, " " ) 
    badgeNumber = #badgeNumber > 0 and badgeNumber 
    local theTeam = getPlayerTeam(thePlayer) 
    local teamID = getElementData(theTeam, "id") 
    
    local badge = nil 
    local itemID = nil 
    local prefix = "" 
    for k, v in pairs(badges) do 
        for ka, va in pairs(v[3]) do 
            if ka == teamID then 
                badge = v 
                itemID = k 
                prefix = type(va) == "string" and ( va .. " " ) or "" 
            end 
        end 
    end 
    if not badge then outputChatBox("Badge number does not exist!", thePlayer, 255, 0, 0) return end 
    
    local leader = getElementData(thePlayer, "factionleader") 
    
    if not (tonumber(leader)==1) then 
        outputChatBox("You must be a faction leader to issue badges.", thePlayer, 255, 0, 0) 
    else 
        if not targetPlayer or not badgeNumber then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [badge Number]", thePlayer, 255, 194, 14) 
        else 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) 
            if targetPlayer then 
                local targetPlayerName = targetPlayerName:gsub("_", " ") 
                local logged = getElementData(targetPlayer, "loggedin") 
                if (logged==0) then 
                    outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0) 
                else 
                    local x, y, z = getElementPosition(thePlayer) 
                    local tx, ty, tz = getElementPosition(targetPlayer) 
                    if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)>4) then 
                        outputChatBox("You are too far away to issue this player a badge.", thePlayer, 255, 0, 0) 
                    else 
                        exports.global:sendLocalMeAction(thePlayer, "issues "..targetPlayerName.." " .. badge[2] .. ", reading " .. badgeNumber .. ".") 
                        exports.global:giveItem(targetPlayer, itemID, prefix .. badgeNumber) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("issuebadge", givePlayerBadge, false, false) 

Posted
That's because the badge number you entered either does not exist or your factions aren't configured correctly. (Is this from Valhalla?) Show me badges table. Also tell me what it outputs:
function givePlayerBadge(thePlayer, commandName, targetPlayer, ... ) 
    local badgeNumber = table.concat( { ... }, " " ) 
    badgeNumber = #badgeNumber > 0 and badgeNumber 
    local theTeam = getPlayerTeam(thePlayer) 
    local teamID = getElementData(theTeam, "id") 
    
    local badge = nil 
    local itemID = nil 
    local prefix = "" 
    for k, v in pairs(badges) do 
        for ka, va in pairs(v[3]) do 
            if ka == teamID then 
                badge = v 
                itemID = k 
                prefix = type(va) == "string" and ( va .. " " ) or "" 
            end 
        end 
    end 
    if not badge then outputChatBox("Badge number does not exist!", thePlayer, 255, 0, 0) return end 
    
    local leader = getElementData(thePlayer, "factionleader") 
    
    if not (tonumber(leader)==1) then 
        outputChatBox("You must be a faction leader to issue badges.", thePlayer, 255, 0, 0) 
    else 
        if not targetPlayer or not badgeNumber then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [badge Number]", thePlayer, 255, 194, 14) 
        else 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) 
            if targetPlayer then 
                local targetPlayerName = targetPlayerName:gsub("_", " ") 
                local logged = getElementData(targetPlayer, "loggedin") 
                if (logged==0) then 
                    outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0) 
                else 
                    local x, y, z = getElementPosition(thePlayer) 
                    local tx, ty, tz = getElementPosition(targetPlayer) 
                    if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)>4) then 
                        outputChatBox("You are too far away to issue this player a badge.", thePlayer, 255, 0, 0) 
                    else 
                        exports.global:sendLocalMeAction(thePlayer, "issues "..targetPlayerName.." " .. badge[2] .. ", reading " .. badgeNumber .. ".") 
                        exports.global:giveItem(targetPlayer, itemID, prefix .. badgeNumber) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("issuebadge", givePlayerBadge, false, false) 

It outputs nothing, and where should i fint this badge table?

Posted

It should output something in any case... Any errors in debugscript? Are you sure you're entering the right command? Is resource even started? I need more informations, not just "doesn't work".

This should output "test", if it doesn't, then I've no idea.

function givePlayerBadge(thePlayer, commandName, targetPlayer, ... ) 
    outputChatBox"test" 
    local badgeNumber = table.concat( { ... }, " " ) 
    badgeNumber = #badgeNumber > 0 and badgeNumber 
    local theTeam = getPlayerTeam(thePlayer) 
    local teamID = getElementData(theTeam, "id") 
    
    local badge = nil 
    local itemID = nil 
    local prefix = "" 
    for k, v in pairs(badges) do 
        for ka, va in pairs(v[3]) do 
            if ka == teamID then 
                badge = v 
                itemID = k 
                prefix = type(va) == "string" and ( va .. " " ) or "" 
            end 
        end 
    end 
    if not badge then outputChatBox("Badge number does not exist!", thePlayer, 255, 0, 0) return end 
    
    local leader = getElementData(thePlayer, "factionleader") 
    
    if not (tonumber(leader)==1) then 
        outputChatBox("You must be a faction leader to issue badges.", thePlayer, 255, 0, 0) 
    else 
        if not targetPlayer or not badgeNumber then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [badge Number]", thePlayer, 255, 194, 14) 
        else 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) 
            if targetPlayer then 
                local targetPlayerName = targetPlayerName:gsub("_", " ") 
                local logged = getElementData(targetPlayer, "loggedin") 
                if (logged==0) then 
                    outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0) 
                else 
                    local x, y, z = getElementPosition(thePlayer) 
                    local tx, ty, tz = getElementPosition(targetPlayer) 
                    if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)>4) then 
                        outputChatBox("You are too far away to issue this player a badge.", thePlayer, 255, 0, 0) 
                    else 
                        exports.global:sendLocalMeAction(thePlayer, "issues "..targetPlayerName.." " .. badge[2] .. ", reading " .. badgeNumber .. ".") 
                        exports.global:giveItem(targetPlayer, itemID, prefix .. badgeNumber) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("issuebadge", givePlayerBadge, false, false) 

Posted
It should output something in any case... Any errors in debugscript? Are you sure you're entering the right command? Is resource even started? I need more informations, not just "doesn't work".

This should output "test", if it doesn't, then I've no idea.

function givePlayerBadge(thePlayer, commandName, targetPlayer, ... ) 
    outputChatBox"test" 
    local badgeNumber = table.concat( { ... }, " " ) 
    badgeNumber = #badgeNumber > 0 and badgeNumber 
    local theTeam = getPlayerTeam(thePlayer) 
    local teamID = getElementData(theTeam, "id") 
    
    local badge = nil 
    local itemID = nil 
    local prefix = "" 
    for k, v in pairs(badges) do 
        for ka, va in pairs(v[3]) do 
            if ka == teamID then 
                badge = v 
                itemID = k 
                prefix = type(va) == "string" and ( va .. " " ) or "" 
            end 
        end 
    end 
    if not badge then outputChatBox("Badge number does not exist!", thePlayer, 255, 0, 0) return end 
    
    local leader = getElementData(thePlayer, "factionleader") 
    
    if not (tonumber(leader)==1) then 
        outputChatBox("You must be a faction leader to issue badges.", thePlayer, 255, 0, 0) 
    else 
        if not targetPlayer or not badgeNumber then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Player Partial Nick / ID] [badge Number]", thePlayer, 255, 194, 14) 
        else 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) 
            if targetPlayer then 
                local targetPlayerName = targetPlayerName:gsub("_", " ") 
                local logged = getElementData(targetPlayer, "loggedin") 
                if (logged==0) then 
                    outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0) 
                else 
                    local x, y, z = getElementPosition(thePlayer) 
                    local tx, ty, tz = getElementPosition(targetPlayer) 
                    if (getDistanceBetweenPoints3D(x, y, z, tx, ty, tz)>4) then 
                        outputChatBox("You are too far away to issue this player a badge.", thePlayer, 255, 0, 0) 
                    else 
                        exports.global:sendLocalMeAction(thePlayer, "issues "..targetPlayerName.." " .. badge[2] .. ", reading " .. badgeNumber .. ".") 
                        exports.global:giveItem(targetPlayer, itemID, prefix .. badgeNumber) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("issuebadge", givePlayerBadge, false, false) 

Well you know what it outputs

Posted

Your factions aren't configured correctly. Go into your item-system then open g_items.lua. You'll see something like this:

{ "LSPD badge",         "a LSPD badge",         {[1] = true},                   {0,100,255},    2} 

Change that number in "[1] = true" to faction ID you are in. To check in which faction ID you're, do /crun getElementData(getPlayerTeam(localPlayer), "id").

Posted
Your factions aren't configured correctly. Go into your item-system then open g_items.lua. You'll see something like this:
{ "LSPD badge",         "a LSPD badge",         {[1] = true},                   {0,100,255},    2} 

Change that number in "[1] = true" to faction ID you are in. To check in which faction ID you're, do /crun getElementData(getPlayerTeam(localPlayer), "id").

OMG THANK YOU!!!!!!! Love you (not in that way). :)

Posted

You're welcome :) Although, some people might say "We do not give support for leaked scripts" but Valhalla is past already... Developers of original Valhalla do not care anymore (or do they?)

Posted
You're welcome :) Although, some people might say "We do not give support for leaked scripts" but Valhalla is past already... Developers of original Valhalla do not care anymore (or do they?)

Dont think they do, cause i think a looot of peaps use it. They haven't sad any words.

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