Jump to content

Help In turf erro


thegost

Recommended Posts

Hello people I have one problem in my script turf I did not understand why when i /turf make does not create the area and appears this: (Turf Error: Provide: leftX bottomY Height Width Red Green and Blue!)

and does not understand that and to do

function turfCommands(source, gangCmd, cmd, name, var1, var2, var3, var4, var5, var6, var7) -- Function for everything

if (not exports.Thegostacl:isPlayerInGroup(source, "Admin")) then outputChatBox("insufficient privileges", source, MSG_RED, MSG_GRN, MSG_BLU) return end

local name = tostring(name)

if (not name) then outputChatBox("Turf Error: No name specified!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

if (cmd == "make") then -- Function for creating new gang areas

leftX, bottomY, width, height, red, green, blue = tonumber(var1), tonumber(var2), tonumber(var3), tonumber(var4), tonumber(var5), tonumber(var6), tonumber(var7)

if (gangArea[name]) then outputChatBox("Turf Error: Gang Area already using this name!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

if (name and leftX and bottomY and width and height and red and green and blue) then

gangArea[name] = createRadarArea(leftX, bottomY, width, height, red, green, blue, TURF_ALPHA)

outputChatBox("Turf Success: Area created! (Not saved to database)", source, MSG_RED, MSG_GRN, MSG_BLU)

else

outputChatBox("Turf Error: Provide: leftX bottomY Height Width Red Green and Blue!", source, MSG_RED, MSG_GRN, MSG_BLU)

end

elseif (cmd == "save" or cmd == "update") then -- Function to save a created gang area to SQL

if (not gangArea[name]) then outputChatBox("Turf Error: No Radar Area with that name!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

local queryGangArea = executeSQLSelect("gang_turf", "turf_name", "turf_name='"..name.."'") -- Time to get its details for storing to SQL.

local width, height = getRadarAreaSize(gangArea[name])

local red, green, blue, alpha = getRadarAreaColor(gangArea[name])

local leftX, botY, Z = getElementPosition(gangArea[name])

if (cmd == "save") then

if (#queryGangArea > 0) then outputChatBox("Turf Error: That name is already in use!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

executeSQLInsert("gang_turf", " '"..name.."', '"..leftX.."', '"..botY.."', '"..width.."', '"..height.."', '"..red.."', '"..green.."', '"..blue.."', 'nobody' ", "'turf_name', 'turf_x', 'turf_y', 'turf_width', 'turf_height', 'turf_red', 'turf_green', 'turf_blue', 'turf_owner'")

outputChatBox("Turf Success: Saved to database!", source, MSG_RED, MSG_GRN, MSG_BLU)

gangCol[name] = createColRectangle(leftX, botY, width, height)

addEventHandler("onColShapeHit", gangCol[name], elementHitGangArea)

setElementData(gangCol[name], "owner", owner, false)

setElementData(gangCol[name], "provocation", "0", false)

setElementData(gangCol[name], "name", name, false)

elseif (cmd == "update") then

if (#queryGangArea == 0) then outputChatBox("Turf Error: That name is not stored on database! (Use saveturf)", source, MSG_RED, MSG_GRN, MSG_BLU) return end

executeSQLUpdate("gang_turf", " turf_x='"..leftX.."', turf_y='"..botY.."', turf_width='"..width.."', turf_height='"..height.."', turf_red='"..red.."', turf_green='"..green.."', turf_blue='"..blue.."'", "turf_name='"..name.."'")

outputChatBox("Turf Success: Updated database!", source, MSG_RED, MSG_GRN, MSG_BLU)

if isElement(gangCol[name]) then destroyElement(gangCol[name]) gangCol[name] = nil end

gangCol[name] = createColRectangle(leftX, botY, width, height)

addEventHandler("onColShapeHit", gangCol[name], elementHitGangArea)

setElementData(gangCol[name], "owner", owner, false)

setElementData(gangCol[name], "provocation", "0", false)

end

elseif (cmd == "mod") then -- Function for modifying width/height

width, height = tonumber(var1), tonumber(var2)

if (not name) then outputChatBox("Turf Error: No name specified!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

if (not gangArea[name]) then outputChatBox("Turf Error: Radar Area with that name not found!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

if (not width or not height) then outputChatBox("Turf Error: Width and Height not specified!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

setRadarAreaSize(gangArea[name], width, height)

outputChatBox("Turf Success: Width/Height changed!", source, MSG_RED, MSG_GRN, MSG_BLU)

elseif (cmd == "colour") then -- Function for modifying colour

red, green, blue = tonumber(var1), tonumber(var2), tonumber(var3)

if (not gangArea[name]) then outputChatBox("Turf Error: Radar Area with that name not found!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

if (not name or not red or not green or not blue) then outputChatBox("Turf Error: Specify: turfName red green blue (0-255)", source, MSG_RED, MSG_GRN, MSG_BLU) return end

setRadarAreaColor(gangArea[name], red, green, blue, TURF_ALPHA)

outputChatBox("Turf Success: Colour changed!", source, MSG_RED, MSG_GRN, MSG_BLU)

elseif (cmd == "delete") then -- Function for removing gang turf

if (not name) then outputChatBox("Turf Error: Provide a turf name!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

if (not gangArea[name]) then outputChatBox("Turf Error: Radar Area with that name not found!", source, MSG_RED, MSG_GRN, MSG_BLU) return end

local queryGangArea = executeSQLSelect("gang_turf", "turf_name", "turf_name='"..name.."'")

if (#queryGangArea >= 1) then

executeSQLDelete("gang_turf", "turf_name='"..name.."'")

outputChatBox("Turf Success: Radar Area Deleted from database!", source, MSG_RED, MSG_GRN, MSG_BLU)

end

destroyElement(gangArea[name])

gangArea[name] = nil

outputChatBox("Turf Success: Radar Area deleted from map!", source, MSG_RED, MSG_GRN, MSG_BLU)

elseif (cmd == "reload") then -- Function for reloading turfs

for colname, colshape in pairs(gangCol) do

destroyElement(colshape)

end

for radarname, radararea in pairs(gangArea) do

destroyElement(radararea)

end

onTurfResourceStart()

outputChatBox("Turf Success: Reloading turfs!", source, MSG_RED, MSG_GRN, MSG_BLU)

elseif (cmd == "loc") then -- Function for finding out what turf you're stood in

local theCols = getElementsByType("colshape")

for colname, colshape in pairs(gangCol) do

if (isElementWithinColShape(source, colshape)) then

outputChatBox("Name of turf you're stood in: "..tostring(colname), source, MSG_RED, MSG_GRN, MSG_BLU)

end

end

else

outputChatBox("Turf Error: Turf commands are: make/save/update/mod/colour/delete/reload/loc", source, MSG_RED, MSG_GRN, MSG_BLU)

end

end

addCommandHandler("turf", turfCommands)

Link to comment
Hello people I have one problem in my script turf I did not understand why when i /turf make does not create the area and appears this: (Turf Error: Provide: leftX bottomY Height Width Red Green and Blue!)

and does not understand that and to do

function turfCommands(source, gangCmd, cmd, name, var1, var2, var3, var4, var5, var6, var7) -- Function for everything 
    if (not exports.Thegostacl:isPlayerInGroup(source, "Admin")) then outputChatBox("insufficient privileges", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
    local name = tostring(name) 
    if (not name) then outputChatBox("Turf Error: No name specified!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
     
    if (cmd == "make") then -- Function for creating new gang areas 
        leftX, bottomY, width, height, red, green, blue = tonumber(var1), tonumber(var2), tonumber(var3), tonumber(var4), tonumber(var5), tonumber(var6), tonumber(var7) 
        if (gangArea[name]) then outputChatBox("Turf Error: Gang Area already using this name!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        if (name and leftX and bottomY and width and height and red and green and blue) then 
            gangArea[name] = createRadarArea(leftX, bottomY, width, height, red, green, blue, TURF_ALPHA) 
            outputChatBox("Turf Success: Area created! (Not saved to database)", source, MSG_RED, MSG_GRN, MSG_BLU) 
        else 
            outputChatBox("Turf Error: Provide: leftX bottomY Height Width Red Green and Blue!", source, MSG_RED, MSG_GRN, MSG_BLU) 
        end 
         
    elseif (cmd == "save" or cmd == "update") then -- Function to save a created gang area to SQL 
        if (not gangArea[name]) then outputChatBox("Turf Error: No Radar Area with that name!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        local queryGangArea = executeSQLSelect("gang_turf", "turf_name", "turf_name='"..name.."'") -- Time to get its details for storing to SQL. 
        local width, height = getRadarAreaSize(gangArea[name]) 
        local red, green, blue, alpha = getRadarAreaColor(gangArea[name]) 
        local leftX, botY, Z = getElementPosition(gangArea[name]) 
        if (cmd == "save") then 
            if (#queryGangArea > 0) then outputChatBox("Turf Error: That name is already in use!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
            executeSQLInsert("gang_turf", " '"..name.."', '"..leftX.."', '"..botY.."', '"..width.."', '"..height.."', '"..red.."', '"..green.."', '"..blue.."', 'nobody' ", "'turf_name', 'turf_x', 'turf_y', 'turf_width', 'turf_height', 'turf_red', 'turf_green', 'turf_blue', 'turf_owner'") 
            outputChatBox("Turf Success: Saved to database!", source, MSG_RED, MSG_GRN, MSG_BLU) 
            gangCol[name] = createColRectangle(leftX, botY, width, height) 
            addEventHandler("onColShapeHit", gangCol[name], elementHitGangArea) 
            setElementData(gangCol[name], "owner", owner, false) 
            setElementData(gangCol[name], "provocation", "0", false) 
            setElementData(gangCol[name], "name", name, false) 
        elseif (cmd == "update") then 
            if (#queryGangArea == 0) then outputChatBox("Turf Error: That name is not stored on database! (Use saveturf)", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
            executeSQLUpdate("gang_turf", " turf_x='"..leftX.."', turf_y='"..botY.."', turf_width='"..width.."', turf_height='"..height.."', turf_red='"..red.."', turf_green='"..green.."', turf_blue='"..blue.."'", "turf_name='"..name.."'") 
            outputChatBox("Turf Success: Updated database!", source, MSG_RED, MSG_GRN, MSG_BLU) 
            if isElement(gangCol[name]) then destroyElement(gangCol[name]) gangCol[name] = nil end 
            gangCol[name] = createColRectangle(leftX, botY, width, height) 
            addEventHandler("onColShapeHit", gangCol[name], elementHitGangArea) 
            setElementData(gangCol[name], "owner", owner, false) 
            setElementData(gangCol[name], "provocation", "0", false) 
        end 
         
    elseif (cmd == "mod") then -- Function for modifying width/height 
        width, height = tonumber(var1), tonumber(var2) 
        if (not name) then outputChatBox("Turf Error: No name specified!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        if (not gangArea[name]) then outputChatBox("Turf Error: Radar Area with that name not found!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        if (not width or not height) then outputChatBox("Turf Error: Width and Height not specified!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        setRadarAreaSize(gangArea[name], width, height) 
        outputChatBox("Turf Success: Width/Height changed!", source, MSG_RED, MSG_GRN, MSG_BLU) 
         
    elseif (cmd == "colour") then -- Function for modifying colour 
        red, green, blue = tonumber(var1), tonumber(var2), tonumber(var3) 
        if (not gangArea[name]) then outputChatBox("Turf Error: Radar Area with that name not found!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        if (not name or not red or not green or not blue) then outputChatBox("Turf Error: Specify: turfName red green blue (0-255)", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        setRadarAreaColor(gangArea[name], red, green, blue, TURF_ALPHA) 
        outputChatBox("Turf Success: Colour changed!", source, MSG_RED, MSG_GRN, MSG_BLU) 
         
    elseif (cmd == "delete") then -- Function for removing gang turf 
        if (not name) then outputChatBox("Turf Error: Provide a turf name!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        if (not gangArea[name]) then outputChatBox("Turf Error: Radar Area with that name not found!", source, MSG_RED, MSG_GRN, MSG_BLU) return end 
        local queryGangArea = executeSQLSelect("gang_turf", "turf_name", "turf_name='"..name.."'") 
        if (#queryGangArea >= 1) then 
            executeSQLDelete("gang_turf", "turf_name='"..name.."'") 
            outputChatBox("Turf Success: Radar Area Deleted from database!", source, MSG_RED, MSG_GRN, MSG_BLU) 
        end 
        destroyElement(gangArea[name]) 
        gangArea[name] = nil 
        outputChatBox("Turf Success: Radar Area deleted from map!", source, MSG_RED, MSG_GRN, MSG_BLU) 
         
    elseif (cmd == "reload") then -- Function for reloading turfs 
        for colname, colshape in pairs(gangCol) do 
            destroyElement(colshape) 
        end 
        for radarname, radararea in pairs(gangArea) do 
            destroyElement(radararea) 
        end 
        onTurfResourceStart() 
        outputChatBox("Turf Success: Reloading turfs!", source, MSG_RED, MSG_GRN, MSG_BLU) 
         
    elseif (cmd == "loc") then -- Function for finding out what turf you're stood in 
        local theCols = getElementsByType("colshape") 
        for colname, colshape in pairs(gangCol) do 
            if (isElementWithinColShape(source, colshape)) then 
                outputChatBox("Name of turf you're stood in: "..tostring(colname), source, MSG_RED, MSG_GRN, MSG_BLU) 
            end 
        end 
         
    else 
        outputChatBox("Turf Error: Turf commands are: make/save/update/mod/colour/delete/reload/loc", source, MSG_RED, MSG_GRN, MSG_BLU) 
    end 
end 
addCommandHandler("turf", turfCommands) 

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