• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Basketball

Sherlok

Active Member
Joined
Aug 29, 2008
Messages
2,116
Reaction score
44
Location
Poland, Wrocław.
same as title :p
I need basketball script ;d

basket.png


Download map:
http://f.files.1ts.pl/basket.rar

ps. someone will do better map ;d
 
i guess it'd be like soccer, just that when player gets close enough to basket, he has to click on it to score a basket
 
it should be like ehm.. in 3 sqm far of the basket u have just a litle % to get 3 points in 2 sqm far of the basket u have like 40 or 50 % to get 2 points and, if u are 1 sqm far of the basket u have 100% [?] to get 1 point

good idea??


edit: and there should be like 2 tiles and in each tile says the points of each team like

6 Points 9 Points
-tile 1- -tile 2-
 
Last edited:
Hmm maybe onStepIn , and onUse will be used when u are shooting , it will check your range , if you are in range of basket

[3 sqms - 15% chance to hit the score]
[2 sqms - 40% chance to hit the score]
[1 sqm - 85% chance to hit the score]

mmm .. this will need a lot of work and improvements ..
 
ok, i made almost all of it:
bask.lua:
Code:
local t = {
	fromPos = {x = 1012, y = 1016, z = 7},
	toPos = {x = 1028, y = 1026, z = 7},
	s1 = 1023,
	s2 = 1042,
	scorePosition = {
		red = {x = 1015, y = 1021, z = 7},
		blue = {x = 1025, y = 1021, z = 7}
	},
	redStorage = 1000,
	blueStorage = 2000,
	centerPosition = {x = 1020, y = 1021, z = 7}
}

local function score()
	local positions = {
		{storage = t.s1, pos1 = {x = 1020, y = 1016, z = 7}, text = "Red"},
		{storage = t.s2, pos1 = {x = 1020, y = 1026, z = 7}, text = "Blue"}
	}
	for _, pos in ipairs(positions) do
		addEvent(doSendAnimatedText, 5 * 1000, pos.pos1, getGlobalStorageValue(pos.storage) .. " Score" .. (getGlobalStorageValue(pos.storage) < 2 and "" or "s") .. "!", math.random(1, 254))
		addEvent(doSendAnimatedText, 10 * 1000, pos.pos1, pos.text, math.random(1, 254))
	end
	return addEvent(score, 2 * 1000)
end

function onStepIn(cid, item, position, fromPosition, toPosition)
	local dir = getCreatureLookDirection(cid)
	local pos = getThingPos(cid)
	local nextPos = {}
	if isInRange(getThingPos(cid), t.fromPos, t.toPos) then
		if dir == NORTH then
			nextPos = {x = pos.x, y = pos.y-1, z = pos.z}
		elseif dir == SOUTH then
			nextPos = {x = pos.x, y = pos.y+1, z = pos.z}
		elseif dir == EAST then
			nextPos = {x = pos.x+1, y = pos.y, z = pos.z}
		elseif dir == WEST then
			nextPos = {x = pos.x-1, y = pos.y, z = pos.z}
		end
		if nextPos ~= {} then
			doRemoveItem(getTileItemById(position, item.itemid).uid)
			doCreateItem(11251, 1, nextPos)
			if getGlobalStorageValue(t.s1) == -1 then
				setGlobalStorageValue(t.s1, 0)
			end
			if getGlobalStorageValue(t.s2) == -1 then
				setGlobalStorageValue(t.s2, 0)
			end
			if t.scorePosition.red.x == nextPos.x and t.scorePosition.red.y == nextPos.y then
				if getPlayerStorageValue(cid, t.redStorage) == 1 then
					setGlobalStorageValue(t.s1, getGlobalStorageValue(t.s1)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Red Team!")
				end
			elseif t.scorePosition.blue.x == nextPos.x and t.scorePosition.blue.y == nextPos.y then
				if getPlayerStorageValue(cid, t.blueStorage) == 1 then
					setGlobalStorageValue(t.s2, getGlobalStorageValue(t.s2)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Blue Team!")
				end
			end
			if nextPos.x == (t.scorePosition.red.x or t.scorePosition.blue.x) and nextPos.y == (t.scorePosition.red.y or t.scorePosition.blue.y) then
				doRemoveItem(getTileItemById(nextPos, item.itemid).uid)
				doCreateItem(11251, 1, t.centerPosition)
				doBroadcastMessage("Current Basketball Score:\nRed Team: " .. getGlobalStorageValue(t.s1) .. "\nBlue Team: " .. getGlobalStorageValue(t.s2))
				score()
			end
		end
	end
	return true
end
teleport.lua:
Code:
local t = {
	redPos = {x = 1014, y = 1021, z = 7},
	bluePos = {x = 1026, y = 1021, z = 7},
	redStorage = 1000,
	blueStorage = 2000,
	waitingRoom = {x = 1020, y = 1032, z = 7},
	waitingFrom = {x = 1012, y = 1028, z = 7},
	waitingTo = {x = 1029, y = 1037, z = 7}
}

local function teleport()
	local list = {}
	for x = t.waitingFrom.x, t.waitingTo.x do
		for y = t.waitingFrom.y, t.waitingTo.y do
			local creature = getTopCreature({x = x, y = y, z = t.waitingRoom.z}).uid
			if isPlayer(creature) then
				table.insert(list, creature)
			end
		end
	end
	if #list > 0 then
		for _, player in ipairs(list) do
			if math.random(20) < 2 then
				doTeleportThing(player, t.redPos, true)
				setPlayerStorageValue(player, t.redStorage, 1)
			else
				doTeleportThing(player, t.bluePos, true)
				setPlayerStorageValue(player, t.blueStorage, 1)
			end
		end
	end
	local item = getTileItemById({x = 1020, y = 1021, z = 7}, 11257).uid
	if item > 0 then
		doRemoveItem(item)
	end
	doCreateItem(11251, 1, {x = 1020, y = 1021, z = 7})
	return true
end

function onStepIn(cid, item, position, fromPosition)
	doTeleportThing(cid, t.waitingRoom, true)
	doBroadcastMessage("Basketball will begin in 1 minute.")
	addEvent(doBroadcastMessage, 1 * 1000, "Basket ball has begun.")
	addEvent(teleport, 1 * 1000)
	return true
end
movements.xml
Code:
<movevent type="StepIn" itemid="11251" event="script" value="bask.lua"/>
<movevent type="StepIn" actionid="1000" event="script" value="teleport.lua"/>
if ur dumb please continue reading:
this part:
Code:
			if t.scorePosition.red.x == nextPos.x and t.scorePosition.red.y == nextPos.y then
				if getPlayerStorageValue(cid, t.redStorage) == 1 then
					setGlobalStorageValue(t.s1, getGlobalStorageValue(t.s1)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Red Team!")
				end
			elseif t.scorePosition.blue.x == nextPos.x and t.scorePosition.blue.y == nextPos.y then
				if getPlayerStorageValue(cid, t.blueStorage) == 1 then
					setGlobalStorageValue(t.s2, getGlobalStorageValue(t.s2)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Blue Team!")
				end
			end
Question: why i made it like this?
Answer: because i cant compare table with table
Question: why i made this question?
Answer: because i know that ppl will ask
--map:
basket otbm
 
Last edited:
ok, i made almost all of it:
bask.lua:
Code:
local t = {
	fromPos = {x = 1012, y = 1016, z = 7},
	toPos = {x = 1028, y = 1026, z = 7},
	s1 = 1023,
	s2 = 1042,
	scorePosition = {
		red = {x = 1015, y = 1021, z = 7},
		blue = {x = 1025, y = 1021, z = 7}
	},
	redStorage = 1000,
	blueStorage = 2000,
	centerPosition = {x = 1020, y = 1021, z = 7}
}

local function score()
	local positions = {
		{storage = t.s1, pos1 = {x = 1020, y = 1016, z = 7}, text = "Red"},
		{storage = t.s2, pos1 = {x = 1020, y = 1026, z = 7}, text = "Blue"}
	}
	for _, pos in ipairs(positions) do
		addEvent(doSendAnimatedText, 5 * 1000, pos.pos1, getGlobalStorageValue(pos.storage) .. " Score" .. (getGlobalStorageValue(pos.storage) < 2 and "" or "s") .. "!", math.random(1, 254))
		addEvent(doSendAnimatedText, 10 * 1000, pos.pos1, pos.text, math.random(1, 254))
	end
	return addEvent(score, 2 * 1000)
end

function onStepIn(cid, item, position, fromPosition, toPosition)
	local dir = getCreatureLookDirection(cid)
	local pos = getThingPos(cid)
	local nextPos = {}
	if isInRange(getThingPos(cid), t.fromPos, t.toPos) then
		if dir == NORTH then
			nextPos = {x = pos.x, y = pos.y-1, z = pos.z}
		elseif dir == SOUTH then
			nextPos = {x = pos.x, y = pos.y+1, z = pos.z}
		elseif dir == EAST then
			nextPos = {x = pos.x+1, y = pos.y, z = pos.z}
		elseif dir == WEST then
			nextPos = {x = pos.x-1, y = pos.y, z = pos.z}
		end
		if nextPos ~= {} then
			doRemoveItem(getTileItemById(position, item.itemid).uid)
			doCreateItem(11251, 1, nextPos)
			if getGlobalStorageValue(t.s1) == -1 then
				setGlobalStorageValue(t.s1, 0)
			end
			if getGlobalStorageValue(t.s2) == -1 then
				setGlobalStorageValue(t.s2, 0)
			end
			if t.scorePosition.red.x == nextPos.x and t.scorePosition.red.y == nextPos.y then
				if getPlayerStorageValue(cid, t.redStorage) == 1 then
					setGlobalStorageValue(t.s1, getGlobalStorageValue(t.s1)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Red Team!")
				end
			elseif t.scorePosition.blue.x == nextPos.x and t.scorePosition.blue.y == nextPos.y then
				if getPlayerStorageValue(cid, t.blueStorage) == 1 then
					setGlobalStorageValue(t.s2, getGlobalStorageValue(t.s2)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Blue Team!")
				end
			end
			if nextPos.x == (t.scorePosition.red.x or t.scorePosition.blue.x) and nextPos.y == (t.scorePosition.red.y or t.scorePosition.blue.y) then
				doRemoveItem(getTileItemById(nextPos, item.itemid).uid)
				doCreateItem(11251, 1, t.centerPosition)
				doBroadcastMessage("Current Basketball Score:\nRed Team: " .. getGlobalStorageValue(t.s1) .. "\nBlue Team: " .. getGlobalStorageValue(t.s2))
				score()
			end
		end
	end
	return true
end
teleport.lua:
Code:
local t = {
	redPos = {x = 1014, y = 1021, z = 7},
	bluePos = {x = 1026, y = 1021, z = 7},
	redStorage = 1000,
	blueStorage = 2000,
	waitingRoom = {x = 1020, y = 1032, z = 7},
	waitingFrom = {x = 1012, y = 1028, z = 7},
	waitingTo = {x = 1029, y = 1037, z = 7}
}

local function teleport()
	local list = {}
	for x = t.waitingFrom.x, t.waitingTo.x do
		for y = t.waitingFrom.y, t.waitingTo.y do
			local creature = getTopCreature({x = x, y = y, z = t.waitingRoom.z}).uid
			if isPlayer(creature) then
				table.insert(list, creature)
			end
		end
	end
	if #list > 0 then
		for _, player in ipairs(list) do
			if math.random(20) < 2 then
				doTeleportThing(player, t.redPos, true)
				setPlayerStorageValue(player, t.redStorage, 1)
			else
				doTeleportThing(player, t.bluePos, true)
				setPlayerStorageValue(player, t.blueStorage, 1)
			end
		end
	end
	local item = getTileItemById({x = 1020, y = 1021, z = 7}, 11257).uid
	if item > 0 then
		doRemoveItem(item)
	end
	doCreateItem(11251, 1, {x = 1020, y = 1021, z = 7})
	return true
end

function onStepIn(cid, item, position, fromPosition)
	doTeleportThing(cid, t.waitingRoom, true)
	doBroadcastMessage("Basketball will begin in 1 minute.")
	addEvent(doBroadcastMessage, 1 * 1000, "Basket ball has begun.")
	addEvent(teleport, 1 * 1000)
	return true
end
movements.xml
Code:
<movevent type="StepIn" itemid="11251" event="script" value="bask.lua"/>
<movevent type="StepIn" actionid="1000" event="script" value="teleport.lua"/>
if ur dumb please continue reading:
this part:
Code:
			if t.scorePosition.red.x == nextPos.x and t.scorePosition.red.y == nextPos.y then
				if getPlayerStorageValue(cid, t.redStorage) == 1 then
					setGlobalStorageValue(t.s1, getGlobalStorageValue(t.s1)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Red Team!")
				end
			elseif t.scorePosition.blue.x == nextPos.x and t.scorePosition.blue.y == nextPos.y then
				if getPlayerStorageValue(cid, t.blueStorage) == 1 then
					setGlobalStorageValue(t.s2, getGlobalStorageValue(t.s2)+1)
					doBroadcastMessage(getCreatureName(cid) .. " has scored 1 point for the Blue Team!")
				end
			end
Question: why i made it like this?
Answer: because i cant compare table with table
Question: why i made this question?
Answer: because i know that ppl will ask
--map:
basket otbm

great fag script! rep++ xDD
 
Back
Top