• 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!

[Request] math.random...

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
Hello Otlanders!
I did the script to my OT but I stopped at a difficult time.
I can't do my idea, I need your help.

I got it:
local teams = {OTland, GarQet, Support, OpenTibia, Forum, OTS, Topic}
Now I need a script that drew the two names, marged them and ascribed "number" 1 and ID 1 and 2. The script must create two tables with the same NUMBER but with different names and different IDs.
ID is entered in the tebeli which is located in (System -> ID)
NAME is entered in the tebeli which is located in (System -> NAME)
NUMBER is entered in the tebeli which is located in (System -> NUMBER)
The next two names give your target NUMBER 2, and also it adds.

Example:
The script draws a GarQet and OTland.
He chose it as the first therefore assign NUMBER 1.
Picture:
35944700661001258075.png


Then drew two other names (The script can't draw NAMES who have already picked!): Support and Topic.
Picture:
56487722993631932028.png


If the name was not evenly, it prints the same one.
When all names will be linked to terminate its operation.
Example:
12250231965436818951.png


I need this a piece of script.
PLEASE HELP ME...
Sorry for my bad English.
 
Code:
local teams = {"List","of","Teams","here"}
local x = teams
function onSay(cid, words, param, channel)
	local number = 1
		while #teams >= 2 do
			local r = math.random(#teams)
			db.executeQuery("INSERT INTO `system` (`name`,`number`) VALUES ('"..teams[r].."',"..number..");")
			table.remove(teams,r)
			r = math.random(#teams)
			db.executeQuery("INSERT INTO `system` (`name`,`number`) VALUES ('"..teams[r].."',"..number..");")
			table.remove(teams,r)	
			number = number + 1
		end
		if #teams == 1 then
			db.executeQuery("INSERT INTO `system` (`name`,`number`) VALUES ('"..teams[1].."',"..number..");")
			table.remove(teams,1)	
		end
		teams = x
    return true
end
 
Summ i really thanks you but my friend who do the script PHP can't get informations from tables :(.
If you were so nice, I would ask for a light change.
I like this:
79122418547520780779.png

IDs go in turn.
opponent_1 - First name drawn for the first time
opponent_2 - Second name drawn for the first time
winner - I manually typed
time - I manually typed
So the point is that the two names to be selected for the first time were in a box, and opponent_2 opponent_1.

I'm sorry that I changed a lot, but you can not do that differently in PHP.
I'm really sorry... :(
Summ could you help me again or anyone else?
//Sorry for my bad english.
 
PHP:
local teams = {"Hil","H","Oer","Her","ggasdg","hh","ko","lo","lll"}
function onSay(cid, words, param, channel)
		while #teams >= 2 do
			local r = math.random(#teams)
			local team = {teams[r]}
			table.remove(teams,r)
			r = math.random(#teams)
			team[2] = teams[r]
			table.remove(teams,r)	
			db.executeQuery("INSERT INTO `system` (`opponent_1`,`opponent_2`,`winner`) VALUES ('"..team[1].."','"..team[2].."','?');")
			print(team[1] .. " - " .. team[2])
		end
		if #teams == 1 then
			db.executeQuery("INSERT INTO `system` (`opponent_1`,`opponent_2`,`winner`) VALUES ('"..teams[1].."','!<<No ememy>>!','?');")
			print(teams[1])
			table.remove(teams,1)	
		end
    return true
end
 
Back
Top