Jump to content

saving system erorr


orcun99

Recommended Posts

function playerSpawn (spawnX, spawnY, spawnZ, team, permission, skin, weapons, player, skinName, sR, sG, sB, rot, dim, int)
	local playerAccount = getPlayerAccount(player)
	local hasPermission = false
	if getAccountData(playerAccount, "override") then
		hasPermission = true	
	else
		if permission:lower() == "none" then
			hasPermission = true
		end
		local outerPerm = split(permission, ";") or {permission}
		for i,v in ipairs(outerPerm) do
			local permArray = split(v, ",")
			if #permArray == 2 then
				local permType = permArray[1]
				local permTo = permArray[2]
				if permType:lower() == "group" then
					if exports.acl:isPlayerInGroup(player, permTo) then hasPermission = true end
					if isMayhemEnabled and free2[permTo] then hasPermission = true end
				elseif permType:lower() == "gang" then
					local gang = getAccountData(playerAccount, "gang")
					if gang and gang:lower() == permTo:lower() then hasPermission = true end
				end
			end
		end
	end
	if hasPermission then 
		local spawnTeam = getTeamFromName(team)
		if not rot then rot = 0 end
		spawnPlayer (player, spawnX , spawnY, spawnZ + 1, rot, skin, 0, 0, spawnTeam)
		setElementDimension(player, dim or 0)
		setElementInterior(player, int or 0)
		fadeCamera (player, true)
		setCameraInterior (player, int or 0 )
		setCameraTarget (player, player)
		local tR , tG , tB = getTeamColor(spawnTeam)
		local r = sR or tR
		local g = sG or tG
		local b = sB or tB
		local blip = createBlipAttachedTo(player, 0, 2, r, g, b, 255, 0, 300, getRootElement())
		setElementVisibleTo(blip, player, false)
		setPlayerNametagColor(player, r, g, b)
		if(weapons) then
			local weps = split(weapons, ",")
			for i, node in ipairs(weps) do
				--outputConsole(node)
				local wepinfo = split(node, ".")
				local wepid = wepinfo[1]
				--outputConsole(wepid)
				local wepammo = wepinfo[2]
				--outputConsole(wepammo)
				giveWeapon ( player, wepid, wepammo )
				
			exports.commands:giveMoney(localPlayer, 500)
			end
		end
		setAccountData(playerAccount, "lastSpawnPerm", permission)
		setElementData(player, "class", skinName)
		
		if getResourceState(getResourceFromName("hud")) == "running" then
			setPlayerHudComponentVisible(player, "all", false)
			setPlayerHudComponentVisible(player, "crosshair", true)
		end
		
		if armorTeams[team] then
			setPedArmor(player, 100)
		end
		
		triggerClientEvent(player, "onSpawnSuccessful", getRootElement())
	else
		triggerClientEvent(player, "onSpawnError", getRootElement() , "Burda Doðamazsýn.!")
	end
end

addEvent("onPlayerSpawnButton", true)
addEventHandler("onPlayerSpawnButton", getRootElement(), playerSpawn)


function playerDespawn()
	local player = source
	for i,v in ipairs(getAttachedElements(player)) do
		if getElementType(v) == "blip" and getElementParent(getElementParent(v)) == resourceRoot then
			destroyElement(v)
		end
	end
end
addEventHandler("onPlayerWasted", getRootElement(), playerDespawn)
addEventHandler("onPlayerQuit", getRootElement(), playerDespawn)


function saveProperty(a, b, c, playah)
	local player = playah or source
	local playeraccount = getPlayerAccount(player)
	if not isPedDead(player) then
		local x, y, z = getElementPosition(player)
		local rot = getPedRotation(player)
		
		setAccountData(playeraccount, "x", x)
		setAccountData(playeraccount, "y", y)
		setAccountData(playeraccount, "z", z)
		setAccountData(playeraccount, "rot", rot)
		
		local skin = getElementModel(player)
		setAccountData(playeraccount, "skin", skin)
		
		local team = getTeamName(getPlayerTeam(player))
		setAccountData(playeraccount, "team", team)
		
		local weaponsarray = {}
		for i=1, 12 do
			if(getPedWeapon(player, i) ~= 0 and getPedTotalAmmo(player, i) > 0) then
				table.insert(weaponsarray, getPedWeapon(player, i) .. "." .. getPedTotalAmmo(player, i))
			end
		end
		
		local weaponstring = table.concat(weaponsarray,",")
		setAccountData(playeraccount, "weapons", weaponstring)
		setAccountData(playeraccount, "aliveonquit", true)
		setAccountData(playeraccount, "class", getElementData(player, "class"))
		
		local r,g,b = getPlayerNametagColor(player)
		setAccountData(playeraccount, "r", r)
		setAccountData(playeraccount, "g", g)
		setAccountData(playeraccount, "b", b)
		
		local dimension = getElementDimension(player)
		local interior = getElementInterior(player)
		setAccountData(playeraccount, "interior", interior)
		setAccountData(playeraccount, "dimension", dimension)
	else
		setAccountData(playeraccount, "aliveonquit", false)
		setAccountData(playeraccount, "x", nil)
		setAccountData(playeraccount, "y", nil)
		setAccountData(playeraccount, "z", nil)
		setAccountData(playeraccount, "permission", nil)
		setAccountData(playeraccount, "team", nil)
		setAccountData(playeraccount, "skin", nil)
		setAccountData(playeraccount, "weapons", nil)
		setAccountData(playeraccount, "class", nil)
		setAccountData(playeraccount, "r", nil)
		setAccountData(playeraccount, "g", nil)
		setAccountData(playeraccount, "b", nil)
		setAccountData(playeraccount, "rot", nil)
		setAccountData(playeraccount, "dimension", nil)
		setAccountData(playeraccount, "interior", nil)
	end
end
addEventHandler("onPlayerQuit", getRootElement(), saveProperty)

function wasPlayerAlive()
	if getAccountData(getPlayerAccount(source), "aliveonquit") then
		--outputConsole("Seems like playah wus alive!")
		local playerAccount = getPlayerAccount(source)
		local x = getAccountData(playerAccount, "x")
		local y = getAccountData(playerAccount, "y")
		local z = getAccountData(playerAccount, "z")
		local rot = getAccountData(playerAccount, "rot")
		local team = getAccountData(playerAccount, "team")
		local permission = getAccountData(playerAccount, "lastSpawnPerm")
		local skin = getAccountData(playerAccount, "skin")
		local weps = getAccountData(playerAccount, "weapons")
		local skinName = getAccountData(playerAccount, "class")
		local r = getAccountData(playerAccount, "r")
		local g = getAccountData(playerAccount, "g")
		local b = getAccountData(playerAccount, "b")
		local dim = getAccountData(playerAccount, "dimension")
		local int = getAccountData(playerAccount, "interior")
		
		playerSpawn(x , y , z, team, permission, skin, weps, source, skinName, r, g, b, rot, dim, int)
	else
	triggerClientEvent(source,"showSpawnScreen",source)
	end
end

addEvent("wasPlayerAliveEvent", true)
addEventHandler("wasPlayerAliveEvent", getRootElement(), wasPlayerAlive)

my erorr is : attempt to index local 'permission' (a bloolean value)

line:

if permission:lower() == "none" then

line: 

Link to comment
5 hours ago, MrTasty said:

Hata mesajı açıkça önerdiğinden, boole değeri string.lower () yapmaya çalışıyorsunuz. Başka bir deyişle,  izin  değişkeni bir dizge değil, bir boole (doğru / yanlış) olur.

what I change?

can u share code pls

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