Jump to content

x[ مشكلة ]x تيم سيليكتور


AE.

Recommended Posts

debugscript مايجيب اي اخطاء
وش الخطأ فيه ولا السكنات ولا التيمات تتغير .

 

local root = getRootElement()
defaultSkin = 0
defaultTeam = ""
currentSkin = 1
currentTeam = 1
team = ""
enabled = false

-------------------------------------------------- Configuration --------------------------------------------------
k = "F4"

teams = {
    {team = "Freeroamer",x = -1980.03125,y = 884.171875,z = 45.203125,camX = -1991.60546875,camY = 883.015625,camZ = 49.198482513428,rot = 0,r = 0,g = 0,b = 0},
    {team = "Gangster",x = 2498.328125,y = -1666.9169921875,z = 13.345584869385,camX = 2485.46484375,camY = -1666.2373046875,camZ = 16.649211883545,rot = 0,r = 0,g = 0,b = 0},
    {team = "Doctor",x = 1178.6708984375,y = -1323.6162109375,z = 14.131542205811,camX = 1178.6708984375,camY = -1323.6162109375,camZ = 13.531591415405,rot = 0,r = 0,g = 0,b = 0},
	{team = "Police",x = 1542.80078125,y = -1674.4306640625,z = 13.555210113525,camX = 1526.4638671875,camY = -1675.212890625,camZ = 19.493789672852,rot = 0,r = 0,g = 0,b = 0},
    {team = "Military",x = 201.4443359375,y = 1897.6630859375,z = 17.640625,camX = 204.458984375,camY = 1919.634765625,camZ = 23.877788543701,rot = 0,r = 0,g = 0,b = 0},
    {team = "Staff",x = -2025.8017578125,y = 171.3896484375,z = 28.84375,camX = -2002.76171875,camY = 170.9296875,camZ = 39.366466522217,rot = 0,r = 0,g = 0,b = 0}
}

skins = {}
skins["Freeroamer"] = {0,5}
skins["Gangster"] = {1,4}
skins["Doctor"] = {2,3}
skins["Police"] = {3,2}
skins["Military"] = {4,1}
skins["Staff"] = {5,0}
-------------------------------------------------------------------------------------------------------------------

addEventHandler("onPlayerLogin",root,function()
	setAccountData(getPlayerAccount(source),"firstTime",true)
	bindKey(source,k,"down",deathChangeTeam)
	firstChange(source)
end)

for i,t in pairs(teams) do
    createTeam(t.team,t.r,t.g,t.b)
end

function firstChange(player)
    if getElementType(player) == "player" then
        defaultSkin = getElementModel(player)
		if getPlayerTeam(player) then
			defaultTeam = getPlayerTeam(player)
		end
		team = "Freeroamer"
		if currentSkin == #skins[tostring(team)] then
            currentSkin = 1
        else
            currentSkin = currentSkin + 1
        end
		updateSkin(player)
		for i,te in pairs(teams) do
			if te.team == team then
				setElementPosition(player,tonumber(te.x),tonumber(te.y),tonumber(te.z))
				setCameraMatrix(player,tonumber(te.camX),tonumber(te.camY),tonumber(te.camZ),tonumber(te.x),tonumber(te.y),tonumber(te.z),0,70)
			end
		end
        setElementFrozen(player,true)
		bindKey(player,"arrow_u","down",changeTeam)
		bindKey(player,"arrow_d","down",changeTeam)
		bindKey(player,"arrow_l","down",changeSkin)
        bindKey(player,"arrow_r","down",changeSkin)
        bindKey(player,"enter","down",finishSelection)
		if getAccountData(getPlayerAccount(player),"firstTime") == false then
			bindKey(player,"backspace","down",exitSelection)
		end
		toggleAllControls(player,false)
    end
end

function changeSkin(player,key)
    if key == "arrow_l" then
        if currentSkin == 1 then
            currentSkin = #skins[tostring(team)]
        else
            currentSkin = currentSkin - 1
        end
   elseif key == "arrow_r" then
        if currentSkin == #skins[tostring(team)] then
            currentSkin = 1
        else
            currentSkin = currentSkin + 1
        end
    end
    updateSkin(player)
end

function changeTeam(player,key)
    if key == "arrow_d" then
        if currentTeam == 1 then
            currentTeam = #teams
        else
            currentTeam = currentTeam - 1
        end
   elseif key == "arrow_u" then
        if currentTeam == #teams then
            currentTeam = 1
        else
            currentTeam = currentTeam + 1
        end
    end
    updateTeam(player)
end

function updateSkin(player)
    for i,s in pairs(skins[tostring(team)]) do
        if i == currentSkin then
            setElementModel(player,tonumber(s))
        end
    end
end

function updateTeam(player)
    for i,t in pairs(teams) do
        if i == currentTeam then
			if t.team == team then
				team = t.team
				updateSkin(player)
				setElementPosition(player,tonumber(t.x),tonumber(t.y),tonumber(t.z))
				setCameraMatrix(player,tonumber(t.camX),tonumber(t.camY),tonumber(t.camZ),tonumber(t.x),tonumber(t.y),tonumber(t.z),0,70)
			end
        end
    end
end

function deathChangeTeam(player,key)
	if key == "f4" then
		addEventHandler("onPlayerWasted",root,function()
			if source == player then
				if getAccountData(getPlayerAccount(source),"firstTime") == false then
					if enabled == false then
						firstChange(source)
						outputChatBox("You will now be entered into team selection when you die.",player,0,255,255)
						enabled = true
					elseif enabled == true then
						outputChatBox("Team selection cancelled!",player,0,255,255)
						enabled = false
					end
				end
			end
		end)
	end
end

function finishSelection(player,key)
    if key == "enter" then
        setCameraTarget(player,player)
        setElementFrozen(player,false)
		toggleAllControls(player,true)
		setPlayerTeam(player,getTeamFromName(team))
        unbindKey(player,"arrow_u","down",changeTeam)
        unbindKey(player,"arrow_d","down",changeTeam)
        unbindKey(player,"arrow_l","down",changeSkin)
        unbindKey(player,"arrow_r","down",changeSkin)
        unbindKey(player,"enter","down",finishSelection)
        unbindKey(player,"backspace","down",exitSelection)
		setAccountData(getPlayerAccount(player),"firstTime",true)
    end
end

function exitSelection(player,key)
	if key == "backspace" then
        setElementModel(player,tonumber(defaultSkin))
		setPlayerTeam(player,defaultTeam)
        setCameraTarget(player,player)
        setElementFrozen(player,false)
		toggleAllControls(player,true)
        unbindKey(player,"arrow_u","down",changeTeam)
        unbindKey(player,"arrow_d","down",changeTeam)
        unbindKey(player,"arrow_l","down",changeSkin)
        unbindKey(player,"arrow_r","down",changeSkin)
        unbindKey(player,"enter","down",finishSelection)
        unbindKey(player,"backspace","down",exitSelection)
    end
end

 

Link to comment
 

debugscript مايجيب اي اخطاء
وش الخطأ فيه ولا السكنات ولا التيمات تتغير .

 


local root = getRootElement()
defaultSkin = 0
defaultTeam = ""
currentSkin = 1
currentTeam = 1
team = ""
enabled = false

-------------------------------------------------- Configuration --------------------------------------------------
k = "F4"

teams = {
    {team = "Freeroamer",x = -1980.03125,y = 884.171875,z = 45.203125,camX = -1991.60546875,camY = 883.015625,camZ = 49.198482513428,rot = 0,r = 0,g = 0,b = 0},
    {team = "Gangster",x = 2498.328125,y = -1666.9169921875,z = 13.345584869385,camX = 2485.46484375,camY = -1666.2373046875,camZ = 16.649211883545,rot = 0,r = 0,g = 0,b = 0},
    {team = "Doctor",x = 1178.6708984375,y = -1323.6162109375,z = 14.131542205811,camX = 1178.6708984375,camY = -1323.6162109375,camZ = 13.531591415405,rot = 0,r = 0,g = 0,b = 0},
	{team = "Police",x = 1542.80078125,y = -1674.4306640625,z = 13.555210113525,camX = 1526.4638671875,camY = -1675.212890625,camZ = 19.493789672852,rot = 0,r = 0,g = 0,b = 0},
    {team = "Military",x = 201.4443359375,y = 1897.6630859375,z = 17.640625,camX = 204.458984375,camY = 1919.634765625,camZ = 23.877788543701,rot = 0,r = 0,g = 0,b = 0},
    {team = "Staff",x = -2025.8017578125,y = 171.3896484375,z = 28.84375,camX = -2002.76171875,camY = 170.9296875,camZ = 39.366466522217,rot = 0,r = 0,g = 0,b = 0}
}

skins = {}
skins["Freeroamer"] = {0,5}
skins["Gangster"] = {1,4}
skins["Doctor"] = {2,3}
skins["Police"] = {3,2}
skins["Military"] = {4,1}
skins["Staff"] = {5,0}
-------------------------------------------------------------------------------------------------------------------

addEventHandler("onPlayerLogin",root,function()
	setAccountData(getPlayerAccount(source),"firstTime",true)
	bindKey(source,k,"down",deathChangeTeam)
	firstChange(source)
end)

for i,t in pairs(teams) do
    createTeam(t.team,t.r,t.g,t.b)
end

function firstChange(player)
    if getElementType(player) == "player" then
        defaultSkin = getElementModel(player)
		if getPlayerTeam(player) then
			defaultTeam = getPlayerTeam(player)
		end
		team = "Freeroamer"
		if currentSkin == #skins[tostring(team)] then
            currentSkin = 1
        else
            currentSkin = currentSkin + 1
        end
		updateSkin(player)
		for i,te in pairs(teams) do
			if te.team == team then
				setElementPosition(player,tonumber(te.x),tonumber(te.y),tonumber(te.z))
				setCameraMatrix(player,tonumber(te.camX),tonumber(te.camY),tonumber(te.camZ),tonumber(te.x),tonumber(te.y),tonumber(te.z),0,70)
			end
		end
        setElementFrozen(player,true)
		bindKey(player,"arrow_u","down",changeTeam)
		bindKey(player,"arrow_d","down",changeTeam)
		bindKey(player,"arrow_l","down",changeSkin)
        bindKey(player,"arrow_r","down",changeSkin)
        bindKey(player,"enter","down",finishSelection)
		if getAccountData(getPlayerAccount(player),"firstTime") == false then
			bindKey(player,"backspace","down",exitSelection)
		end
		toggleAllControls(player,false)
    end
end

function changeSkin(player,key)
    if key == "arrow_l" then
        if currentSkin == 1 then
            currentSkin = #skins[tostring(team)]
        else
            currentSkin = currentSkin - 1
        end
   elseif key == "arrow_r" then
        if currentSkin == #skins[tostring(team)] then
            currentSkin = 1
        else
            currentSkin = currentSkin + 1
        end
    end
    updateSkin(player)
end

function changeTeam(player,key)
    if key == "arrow_d" then
        if currentTeam == 1 then
            currentTeam = #teams
        else
            currentTeam = currentTeam - 1
        end
   elseif key == "arrow_u" then
        if currentTeam == #teams then
            currentTeam = 1
        else
            currentTeam = currentTeam + 1
        end
    end
    updateTeam(player)
end

function updateSkin(player)
    for i,s in pairs(skins[tostring(team)]) do
        if i == currentSkin then
            setElementModel(player,tonumber(s))
        end
    end
end

function updateTeam(player)
    for i,t in pairs(teams) do
        if i == currentTeam then
			if t.team == team then
				team = t.team
				updateSkin(player)
				setElementPosition(player,tonumber(t.x),tonumber(t.y),tonumber(t.z))
				setCameraMatrix(player,tonumber(t.camX),tonumber(t.camY),tonumber(t.camZ),tonumber(t.x),tonumber(t.y),tonumber(t.z),0,70)
			end
        end
    end
end

function deathChangeTeam(player,key)
	if key == "f4" then
		addEventHandler("onPlayerWasted",root,function()
			if source == player then
				if getAccountData(getPlayerAccount(source),"firstTime") == false then
					if enabled == false then
						firstChange(source)
						outputChatBox("You will now be entered into team selection when you die.",player,0,255,255)
						enabled = true
					elseif enabled == true then
						outputChatBox("Team selection cancelled!",player,0,255,255)
						enabled = false
					end
				end
			end
		end)
	end
end

function finishSelection(player,key)
    if key == "enter" then
        setCameraTarget(player,player)
        setElementFrozen(player,false)
		toggleAllControls(player,true)
		setPlayerTeam(player,getTeamFromName(team))
        unbindKey(player,"arrow_u","down",changeTeam)
        unbindKey(player,"arrow_d","down",changeTeam)
        unbindKey(player,"arrow_l","down",changeSkin)
        unbindKey(player,"arrow_r","down",changeSkin)
        unbindKey(player,"enter","down",finishSelection)
        unbindKey(player,"backspace","down",exitSelection)
		setAccountData(getPlayerAccount(player),"firstTime",true)
    end
end

function exitSelection(player,key)
	if key == "backspace" then
        setElementModel(player,tonumber(defaultSkin))
		setPlayerTeam(player,defaultTeam)
        setCameraTarget(player,player)
        setElementFrozen(player,false)
		toggleAllControls(player,true)
        unbindKey(player,"arrow_u","down",changeTeam)
        unbindKey(player,"arrow_d","down",changeTeam)
        unbindKey(player,"arrow_l","down",changeSkin)
        unbindKey(player,"arrow_r","down",changeSkin)
        unbindKey(player,"enter","down",finishSelection)
        unbindKey(player,"backspace","down",exitSelection)
    end
end

 

اذا تقصد ليش اف 4 ما تشتفل
رح اقولك غير حرف ال
k
سطر 32
وحط بدل منه اف 4
جرب ورد لي خبر

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