DiGiTal Posted June 3, 2017 Share Posted June 3, 2017 (edited) Hi, i have added the code of "isPlayerInTeam" on folder"confirm" i created there a meta and lua i copyed there function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end and i see this ERROR: Roob\Safe.lua:11: call: failed to call 'SADZconfirm:isPlayerInTeam' [string "?"] function startUp() if exports.SADZconfirm:isPlayerInTeam( thePlayer, "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp) Edited June 3, 2017 by Ridden Link to comment
^iiEcoo'x_) Posted June 3, 2017 Share Posted June 3, 2017 Show me exports from SADZconfirm resource and the meta Link to comment
DiGiTal Posted June 3, 2017 Author Share Posted June 3, 2017 local moneyMultiplier = 1 function giveMoney(player, amount) if player then if isElement(player) then if tonumber(amount) then local currentMoney = tonumber(getElementData(player, "money")) or 0 local newMoney = math.floor(currentMoney + tonumber(amount)) setPlayerMoney(player, newMoney) setElementData(player, "money", tostring(newMoney)) return true else outputDebugString("Amount not number.",1) return false end else outputDebugString("Invalid player.", 1) return false end else outputDebugString("Missing argument.",1) return false end end addEvent("giveMoney", true) addEventHandler("giveMoney", root, giveMoney) function takeMoney(player, amount) if player then if isElement(player) then if tonumber(amount) then local currentMoney = tonumber(getElementData(player, "money")) or 0 local newMoney = math.floor(currentMoney - tonumber(amount)) setPlayerMoney(player, newMoney) setElementData(player, "money", tostring(newMoney)) return true else outputDebugString("Amount not number.",1) return false end else outputDebugString("Invalid player.", 1) return false end else outputDebugString("Missing argument.",1) return false end end addEvent("takeMoney", true) addEventHandler("takeMoney", root, takeMoney) function setMoney(player, amount) if player then if isElement(player) then if tonumber(amount) then local newMoney = math.floor(tonumber(amount)) setPlayerMoney(player, newMoney) setElementData(player, "money", tostring(newMoney)) return true else outputDebugString("Amount not number.",1) return false end else outputDebugString("Invalid player.", 1) return false end else outputDebugString("Missing argument.",1) return false end end addEvent("setMoney", true) addEventHandler("setMoney", root, setMoney) function formatNumber(amount) if type(amount) ~= "string" then amount = tostring(amount) end local outcome = amount while true do outcome,k = string.gsub(outcome,"^(-?%d+)(%d%d%d)","%1,%2") if k == 0 then break end end return outcome end function subString(str,chunkSize) if not str or type(str) ~= "string" or not chunkSize or type(chunkSize) ~= "number" then return false end local returnTable = {} while #str >= chunkSize do table.insert(returnTable,str:sub(1,chunkSize)) str = str:sub(chunkSize+1) if #str < chunkSize then table.insert(returnTable,str) end end return returnTable end function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end Link to comment
^iiEcoo'x_) Posted June 3, 2017 Share Posted June 3, 2017 Add in the meta , in SADZconfirm resource <export function="isPlayerInTeam" type="server"/> Line 2 if exports["SADZconfirm"]:isPlayerInTeam ( thePlayer , "Criminals") then -- or if exports["SADZconfirm"]:isPlayerInTeam ( thePlayer ) == "Criminals" then Link to comment
DiGiTal Posted June 3, 2017 Author Share Posted June 3, 2017 (edited) Must to be into [,] ??? Edited June 3, 2017 by Ridden Link to comment
idarrr Posted June 3, 2017 Share Posted June 3, 2017 function startUp() for _, thePlayer in ipairs(getElementsByType("player")) do if exports.SADZconfirm:isPlayerInTeam( thePlayer, "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp) Link to comment
^iiEcoo'x_) Posted June 3, 2017 Share Posted June 3, 2017 function startUp() for k,v in ipairs ( getElementsByType ( 'player' ) ) do if exports["SADZconfirm"]:isPlayerInTeam ( thePlayer , "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp) 1 Link to comment
DiGiTal Posted June 3, 2017 Author Share Posted June 3, 2017 i've this eror, the code have the eror,?.? [18:26:45] ERROR: SADZconfirm\exports_server.lua:102: Bad argument 1 @ isPlayerInTeam [player expected, got nil] [DUP x2] [18:26:45] ERROR: SADZRoob\Safe.lua:11: call: failed to call 'SADZconfirm:isPlayerInTeam' [string "?"] [DUP x2] [18:26:45] INFO: wrong [DUP x2] thx Link to comment
DiGiTal Posted June 3, 2017 Author Share Posted June 3, 2017 function startUp() for k,v in ipairs ( getElementsByType ( 'player' ) ) do if exports["SADZcommands"]:isPlayerInTeam ( thePlayer , "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp) Link to comment
idarrr Posted June 3, 2017 Share Posted June 3, 2017 Variable thePlayer is not defined. Try this. function startUp() for k,v in ipairs ( getElementsByType ( 'player' ) ) do if exports["SADZcommands"]:isPlayerInTeam(v, "Criminals") then safeTable = createObject (1829 ,2580.619140625, 2328.5845703125, 17.222208404541) createBlipAttachedTo ( safeTable, 38, 3, 0, 117 , 0 , 255, 0, 99999.0 ) loadConfig() else outputDebugString("wrong") end end end addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startUp) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now