Jump to content

[BUG]Roob script


DiGiTal

Recommended Posts

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 by Ridden
Link to comment

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

 

  • Like 1
Link to comment

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

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

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

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