Model Sizes

Post your scripting questions / solutions here

Moderator: Moderators

sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Model Sizes

Post by sdlall »

This problem has haunted me for longtime. Where can you find model sizes? Say like indycrate. What is it length, width, and heighth? I know 16 units = 1 foot but when read through the .tik for these models just not seeing it.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

If it's just the size of the bounding box that you want to know, look for the QUAKED directive at the end of the TIKI. The dimensions of the 3D mesh are impossible to obtain, though, without reading the SKD and SKC files.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Here is what i am trying to do but taking a will since I do not know the sizes. I am trying to put sandbags around the rocket pit in v2 rocket facility. I can do it by guessing but gets old going in and out of server to see if they are correctly placed. What I want to do is to be able to use ezmodder (which i know how to) and be able to place them that way so i can see ingame how they are turning out.
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

Well this isn't the solution you want, but you can type in console "editscript" and it will bring up notepad of the map script. Type in ur coords ctrl+s, then restart the server.

To use ezmodder, u need to have the "dev.cfg" in ur main...Then exec it in game by typing "exec dev". If your still having issues, well....There's no point in me posting anymore lol
HeavenBound

I'm new at this :)
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Unfortunately the setsize isn't always available nor always correct in the QUAKE directive. Sometimes it just says ( 0 0 0 ) while in reality, the model does have a bbox.

Credits to elgan:

Code: Select all

GetBBox local.object:

	if (local.object == NIL && self != NULL)
		local.object = self
	else if (local.object == NIL && self == NULL)
		end

	local.fwd = waitthread getbound 1 ( 1 0 0 ) local.object
	local.bwd = waitthread getbound 0 ( 1 0 0 ) local.object

	local.right = waitthread getbound 1 ( 0 1 0 ) local.object
	local.left = waitthread getbound 0 ( 0 1 0 ) local.object

	local.up = waitthread getbound 1 ( 0 0 1 ) local.object
	local.down = waitthread getbound 0 ( 0 0 1 ) local.object
		
	local.BBox[0] = ( -local.bwd -local.left -local.down )
	local.BBox[1] = ( local.fwd local.right local.up )

end local.BBox

getbound local.dir local.vector local.model:

	local.item = spawn script_origin origin local.model.origin
	local.item.angles = local.model.angles
	local.item setsize ( 0 0 0 ) ( 0 0 0 )

	for(local.i = 0;local.item istouching local.model; local.i++)
	{
		if(local.dir == 1)
		{
			local.item.origin += local.vector * 1
		}
		else
		{
			local.item.origin -= local.vector * 1
		}
	}	

	local.item delete
	    
	local.i = ( local.i * local.model.scale + 6) - 11.5

end local.i
To get the bbox printed in your console:

Code: Select all

local.bbox = waitthread GetBBox $myobject 
println (local.bbox[0] + " " + local.bbox[1])
[0] array being the minimum and [1] array the maximum.

Or you can use my "model spawner" tool. Execute 2 seconds after waittill spawn. First set the model to spawn then hold use to spawn it and use the console commands, to control the model.

All console commands:
"mdlorigin" ""
"mdlangles" ""
"mdlscale" ""
"mdlsolid" ""
"mdl" ""
"printmdl" ""
"undomdl" ""

All changes are applied instantly and you will see them instantly in game as well. When you're done, insert "printmdl 1" in the console wait till it's done printing and exit. Check your qconsole file for the print.

Code: Select all

// Model Creator by Sor

main:

	while($player.size <= 1)
	{
		for (local.i = 1; local.i <= $player.size; local.i++)
		{
			if ($player[local.i].modell != 1)
			{
				$player[local.i].modell = 1
				$player[local.i] thread modell
				end
			}
		}
		wait 3
	}

end


modell:

	setcvar "mdlorigin" ""
	setcvar "mdlangles" ""
	setcvar "mdlscale" ""
	setcvar "mdlsolid" ""
	setcvar "mdl" ""
	setcvar "printmdl" ""
	setcvar "undomdl" ""
	setcvar "sv_showbboxes" "2"

	self iprint "You can now spawn any model in game!!" 1

	while(1)
	{
		if (self.useheld == 1 && self.spawning != 1)
		{
			self.spawning = 1
			
			if (level.thing == NIL)
				level.i = 1
			else
				level.i = ( level.thing.size + 1 )

			if ( level.mdl == NIL || level.mdl == "" )
			{
				self iprint "NO MODEL HAS BEEN CHOSEN. USE mdl your/model.tik IN THE CONSOLE TO SET 1!!" 1
			}
			else
			{
				//local.model = (getcvar "mdl")
				level.thing[level.i] = spawn script_model model level.mdl
				level.thing[level.i].origin = self.origin + ( 0 0 40 )
				level.thing[level.i].angles = ( 0 0 0 )
				level.thing[level.i] scale 1
				level.thing[level.i].isSolid = 0
				level.thing[level.i] notsolid
	
				println "Model's origin: " level.thing[level.i].origin 
				self iprint "Model spawned!!" 1
			}
			
			wait 0.3 
			self.spawning = 0
		}
		if ( (getcvar "mdlorigin") != "")
		{
			local.origin = (getcvar "mdlorigin")
			setcvar "mdlorigin" ""
			local.origin = waitexec global/strings.scr::split_line local.origin 1 " "
			
			level.thing[level.i].origin = ( (float(local.origin[1][1])) (float(local.origin[1][2])) (float(local.origin[1][3])) )
			println "Model's new origin: " level.thing[level.i].origin 
			self iprint "New origin set for latest spawned model" 1
		}

		if ( (getcvar "mdlangles") != "")
		{
			local.angles = (getcvar "mdlangles")
			setcvar "mdlangles" ""
			local.angles = waitexec global/strings.scr::split_line local.angles 1 " "
			
			level.thing[level.i].angles = ( (int(local.angles[1][1])) (int(local.angles[1][2])) (int(local.angles[1][3])) )
			println "Model's new angles: " level.thing[level.i].origin 
			self iprint "New angles set for latest spawned model" 1
		}

		if ( (getcvar "mdlscale") != "")
		{
			local.scaler = (getcvar "mdlscale")
			setcvar "mdlscale" ""

			level.thing[level.i] scale local.scaler
			self iprint "New scale set for latest spawned model" 1
		}

		if ( (getcvar "mdlsolid") != "")
		{
			if ( (getcvar "mdlsolid") == "1")
			{
				local.feedback = "solid"
				level.thing[level.i] solid 
				level.thing[level.i].isSolid = 1
			}
			else
			{
				local.feedback = "notsolid"
				level.thing[level.i] notsolid 
				level.thing[level.i].isSolid = 0
			}
			setcvar "mdlsolid" ""
			self iprint ("The latest spawned model has been made " + local.feedback + "!!") 1
		}
		if ( (getcvar "mdl") != "")
		{
			level.mdl = (getcvar "mdl")
			self iprint "New model-to-use set!" 1
			setcvar "mdl" ""
		}
		if ( (getcvar "undomdl") != "")
		{
			setcvar "undomdl" ""

			level.thing[level.i] delete
			level.thing[level.i] = NIL

			level.i--

			self iprint "Model undone" 1
		}
		if ( (getcvar "printmdl") != "")
		{
			self iprint "Printing standby..."
			setcvar "logfile" "3"
			setcvar "printmdl" ""
			waitframe
			waitframe
			println "===================================================================================="
			println ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MDL PRINTOUT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
			println "===================================================================================="
			println " "
			for (local.i = 1; local.i <= level.thing.size; local.i++)
			{
				local.p_origin = ("( " + int(level.thing[local.i].origin[0]) + " " + int(level.thing[local.i].origin[1]) + " " + int(level.thing[local.i].origin[2]) + " )")
				local.p_angles = ("( " + int(level.thing[local.i].angles[0]) + " " + int(level.thing[local.i].angles[1]) + " " + int(level.thing[local.i].angles[2]) + " )")
				local.p_solid = level.thing[local.i].isSolid
				local.p_mdl = level.thing[local.i].model
				local.p_scale = level.thing[local.i].scale
				println ("local.model = spawn script_model model " + local.p_mdl)
				println ("local.model.origin = " + local.p_origin)
				println ("local.model.angles = " + local.p_angles)
          if (local.p_solid == 1)
				      println ("local.model solid")
          else if (local.p_solid == 0)
				      println ("local.model notsolid")
				println ("local.model scale " + local.p_scale)

			}
			
			println " "
			println ("Total amount of objects: " + level.i)
			println " "
			println "===================================================================================="
			println "===================================================================================="
		}
	
		wait 0.3
	}

end
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

Why Does SOR have to know everything?!

:lol: :lol:
HeavenBound

I'm new at this :)
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Great work again SOR. Got it work right off except can not see the spawned items. here what i am typing into console for the .tik mdl sandbag_link_middle.tik says ready to use but when i hit e it says spawned but can not see it. any suggestions ?
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

ur using the menu right?

hit M to pull down the menu, select sand bags and boom ur good. =)
HeavenBound

I'm new at this :)
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

The full path must be given:
"folder/mytik.tik"

So:
mdl "static/sandbag_link_middle.tik"

;)

I often use sandbag bases. For my CTF and CnH gametypes. But I always use the same (takes a long time to get it right). Things might turn out like this:
http://i95.photobucket.com/albums/l127/ ... ot0052.jpg

Do you want to prefab script for this? But I figure that the sandbag base around the V2 will need to be bigger.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

HeavanBound got ezmodder to work easily. What I was talking about in my last post was using sor model spawner. That way seems like better way to go for me just having that one issue with it not seeing the spawned objects. As for ezmodder I can make the sandbags in a row but just getting them to fit end to end is hard because not knowing the exact lenght.

Example with ezmodder:

I go in spawn a sandbag.
Sandbag spawns with me in middle.
Now I want to spawn a sandbag in line to the left and/or right.
So how far do i go left and/or right to spawn the next sandbag to make it connect to the 1st.

From what I understand about sor's is that once you spawn a sandbag (which at the moment can't see mine) is that you can move it. This would work better because could move it to more exact locations. Then spawning 50 sandbags to see if i got it like in ezmodder.

Don't get me wrong been using ezmodder for awhile. It works great for going in a spawning things. Heck I like going in sometimes and spawning everything planes on the ground in v2, inferno in the rooms, and etc.
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Thanks, I must be going blind never saw your response until just now SOR.
Yeah prefab would be great if you have one. Would save alot of time but still going to try your model script out.

One or two more questions kind of off topics. Did you ever release more tuts then part 1 & 2 that I found on medalofhonor filefront. If so were can I get them from.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Unfortunately, no. However I recall I once started on part 3 but never finished it. If you need any help or a temporary teacher, I'm always here trying to help scripting enthusiasts.

Here's the prefab by the way (as you can see, I always use arrays and for statements to make things "easier"). Just put it in a thread or something and execute once.

Code: Select all

createSandbags local.origin:

	local.sandbags = makeArray
	( -65 -90 0 ) ( 0 90 0 ) "static/sandbag_link_topcap.tik"
	( 0 -90 0 ) ( 0 90 0 ) "static/sandbag_link_main.tik"
	( 70 -95 0 ) ( 0 -90 0 ) "static/sandbag_link_rightbend.tik"
	( 70 -50 0 ) ( 0 0 0 ) "static/sandbag_link_main.tik"
	( 70 25 0 ) ( 0 0 0 ) "static/sandbag_link_main.tik"
	( 70 95 0 ) ( 0 90 0 ) "static/sandbag_link_leftbend.tik"
	( 0 90 0 ) ( 0 -90 0 ) "static/sandbag_link_main.tik"
	( -70 90 0 ) ( 0 -270 0 ) "static/sandbag_link_topcap.tik"
      endArray

	for (local.i = 1; local.i <= local.sandbags.size; local.i++)
	{
		local.s = spawn script_model model local.sandbags[local.i][3] "targetname" "sandbags"
		local.s.origin = local.origin + local.sandbags[local.i][1]
		local.s.angles = local.sandbags[local.i][2]
		local.s solid
		local.s nodamage
	}

end
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

K thanks. Kind of getting the hang of things little by little. There are alot of tuts out there and have been reading. Everyday seem to understand it better and better. Again thanks


P.S. Will give me chance now to understand arrrays better.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

You probably will understand them better, but makeArray is a tricky one if you don't understand how it works. The first dimension always represents the row, the second dimension represents the Xth values on that row.

local.sandbags[4][2] is the second value on the 4th row (and is ( 0 0 0 ))

The first column is the origin deviation, the second is the angles and the last the model.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

But there's something I forgot to give you. My model creator tool uses an external script "global/strings.scr" and I don't think you have it. Without this, it will not work so create a "global/strings.scr" file and put this in it:

Code: Select all


// 11 September 2005 added 3 new functions
// array_to_int
// array_to_str
// array_to_float

/*
Array_to_lower
Array_to_upper
to_lower
to_upper
InStr
Right
left
Mid
Reverse
split_line
Replace
Remove
Format_replace
array_to_int
array_to_str
array_to_float
*/


// Convert a array to lower  case.
// usage: exec global/strings.scr::Array_to_lower (const array of strings)
// returns: Array of lower case strings

Array_to_lower local.strings:

	local.lower = waitthread chardata_lowercase
	local.upper = waitthread chardata_uppercase

	for(local.linni = 1; local.linni <= local.strings.size; local.linni++)
	{	
		for(local.anniken = 1; local.anniken <= local.strings[local.linni].size; local.anniken++)
		{
			local.string = local.strings[local.linni] [local.anniken]

			for(local.i = 0; local.i <= local.string.size - 1; local.i++)
			{
				local.letter = local.string[local.i]
				for(local.t = 1; local.t <= local.upper.size; local.t++)
				{
					if(local.letter == local.upper[local.t])
					{	
						local.letter = local.lower[local.t] 
						local.string[local.i] = local.letter 
					}
				}

			}
			local.strings[local.linni][local.anniken] = local.string
		}
	}

end  local.strings



// Convert a array to upper case.
// usage: exec global/strings.scr::Array_to_upper (const array of strings)
// returns: Array of upper case strings

Array_to_upper local.strings:

	local.lower = waitthread chardata_uppercase 
	local.upper = waitthread chardata_lowercase
 
	for(local.linni = 1; local.linni <= local.strings.size; local.linni++)
	{	
		for(local.anniken = 1; local.anniken <= local.strings[local.linni].size; local.anniken++)
		{
			local.string = local.strings[local.linni] [local.anniken]

			for(local.i = 0; local.i <= local.string.size - 1; local.i++)
			{
				local.letter = local.string[local.i]
				for(local.t = 1; local.t <= local.upper.size; local.t++)
				{
					if(local.letter == local.upper[local.t])
					{	
						local.letter = local.lower[local.t] 
						local.string[local.i] = local.letter 
					}
				}

			}
			local.strings[local.linni][local.anniken] = local.string
		}
	}

end  local.strings


	
//stolen arrays from jv's string handler:D
//of cause by jv

// returns all lowercase chars
chardata_lowercase:
	local.hasharray = makeArray
	a
	b
	c
	d
	e
	f
	g
	h
	i
	j
	k
	l
	m
	n
	o
	p
	q
	r
	s
	t
	u
	v
	w
	x
	y
	z
	endArray
	
	for(local.i = 1; local.i <= local.hasharray.size; local.i++)
	{
		local.array[local.i] = local.hasharray[local.i][1]
	}	

end local.array

// returns all uppercase chars
chardata_uppercase:
	local.hasharray = makeArray
	A
	B
	C
	D
	E
	F
	G
	H
	I
	J
	K
	L
	M
	N
	O
	P
	Q
	R
	S
	T
	U
	V
	W
	X
	Y
	Z
	endArray
	
	for(local.i = 1; local.i <= local.hasharray.size; local.i++)
	{
		local.array[local.i] = local.hasharray[local.i][1]
	}	
end local.array


// instr
// Instr will find the position in wich a string is found at.
// Usage: exec global/strings.scr::InStr (string to find \ string)
// returns the position of string_to_find
// eg
// exec global/strings.scr::InStr "\" "hell\o"
// gives 4 because it starts at 0

// If none found it will return NIL
InStr local.char local.string:

	if(local.char.size == 1)
	{
		local.checktype = 0
	}
	else
	{
		local.checktype = 1
	}

	for(local.i = 0; local.i <= local.string.size - 1; local.i++)
	{
		if(local.checktype == 0)
		{
			local.check =  (local.char ==  local.string[local.i])
		}
		else
		{
			local.check =  (local.char[0] ==  local.string[local.i])
		}

		if(local.check)
		{
			if(local.checktype == 0)
			{
				local.i++
				end local.i
			}
			else
			{
				local.m = local.i
				for(local.t = 0;local.t <= local.char.size - 1 ;local.t++)
				{
					if(local.char[local.t] != local.string[local.m])
					{
						local.no = 1
					}
					local.m++
				}

				if(local.no != 1)
				{
					local.i++
					end local.i
				}
			}

		}
	}
end



// Rightr
// Right will return a string of characters from the right.
// usage: waitexec global/strings.scr::Right ( Number of characters#, STRING STRING )
// Returns a string right from the number given as position
// eg
// local.string = waitexec global/strings.scr::Right 3 "hello"
// local.string will be 'llo'
Right local.pos local.string:

	local.start = local.string.size - local.pos
	local.right = ""

	for(local.i = local.start; local.i <= local.string.size - 1 ; local.i++)
	{
		local.right += local.string[local.i]
	}

end local.right



// Left
// Left will return Left of the string for the given number.
// usage: waitexec global/strings.scr::Right (NUMBER OF CHARACTERS LEFT, STRING STRING )
// Returns a string left from the number given as position
// eg
// local.string = waitexec global/strings.scr::Left 3 "hello" 
// local.string will be 'hell'
// 
Left local.pos local.string:

	local.pos--
	local.left = ""
	for(local.i = 0; local.i <=  local.pos; local.i++)
	{
		local.left += local.string[local.i]
	}

end local.left



//Mid
//mid will return a string from a given position for a given number of characters.
// usage: local.string = waitexec global/strings.scr ( START POS, STRING, COUNT)
// returns: The string from start pos of string along the count.
//
//eg
// local.string = waitexec global/strings.scr 3 "hello" 2 
// local.string would become 'll'
Mid local.start local.string local.count:

	local.start--
	local.mid = ""

	for(local.i = 1; local.i <= local.count;local.i++)
	{
		local.mid += local.string[local.start]
		local.start++
	}

end local.mid




//Reverse
// Reverse will reverse a given string.
//useage:: local.string = waitexec global/strings.scr (STRING STRING)
// result: gives a string that is backwards to the string given.
//
//eg
// local.string = waitexec global/strings.scr::Reverse "hello" 
// local.string would become 'olleh'
Reverse local.string:

	local.left = ""
	for(local.i = local.string.size - 1; local.i >=  0; local.i--)
	{
		local.left += local.string[local.i]
	}

end local.left



// to_lower
// This will convert a given string to lower case
// usage local.string = waitexec global/strings.scr::to_lower (STRING STRING, INDEX TO CONVERT)
// Result: a lower case string
//
//eg
// local.string = waitexec global/strings.scr::to_lower "HELLO" 
// local.string will become 'hello'
//eg2
// local.string = waitexec global/strings.scr::to_lower "HELLO" 0
// local.string will become 'hELLO'
to_lower local.string local.index:

	local.lower = waitthread chardata_lowercase
	local.upper = waitthread chardata_uppercase

	for(local.i = 0; local.i <= local.string.size - 1; local.i++)
	{
		local.letter = local.string[local.i]

		if(local.i == local.index || local.index == NIL)
		{
			for(local.t = 1; local.t <= local.upper.size; local.t++)
			{
				if(local.letter == local.upper[local.t])
				{	
					local.letter = local.lower[local.t] 
					local.string[local.i] = local.letter 
				}
			}
		}
		else
		{
			local.string[local.i] = local.letter 
		}

	}

end local.string



// to_upper
// This will convert a given string to upper case
// usage local.string = waitexec global/strings.scr::to_upper (STRING STRING, INDEX TO CONVERT)
// Result: a upper case string
//
//eg
// local.string = waitexec global/strings.scr::to_upper "hello" 
// local.string will become 'HELLO'
//eg2
// local.string = waitexec global/strings.scr::to_upper "hello" 0
// local.string will become 'Hello'

to_upper local.string local.index:

	local.upper = waitthread chardata_lowercase
	local.lower = waitthread chardata_uppercase

	for(local.i = 0; local.i <= local.string.size - 1; local.i++)
	{
		local.letter = local.string[local.i]

		if(local.i == local.index || local.index == NIL)
		{
			for(local.t = 1; local.t <= local.upper.size; local.t++)
			{
				if(local.letter == local.upper[local.t])
				{	
					local.letter = local.lower[local.t] 
					local.string[local.i] = local.letter 
				}
			}
		}
		else
		{
			local.string[local.i] = local.letter 
		}

	}

end local.string



// Used to split a line of words into a array of words. return with word count
// localinfo == line to split
// local.say = say to admins input detected or not, set 1 usualy
// local.spacer = What to use to split the line. If none is set then " " will be used.
// usage local.wordarray = waitexec global/strings.scr::split_line ( STRING STRING , CONSOLE FEEDBACK, STRING SPACER)
//
//eg
//  local.wordarray = waitexec global/strings.scr::split_line "hello_mummy" 1 "_"
// local.wordarray is a const array
//
// local.wordarray[1] = array of words
// local.wordarray[2] word count
// local.wordarray[3] full string with " " spaces
//
// local.wordarray[1][1] is 'hello'
// local.wordarray[1][1] is 'mummy'
//
// local.wordarray[2] is 2 'two words'
//
// local.wordarray[3] is 'hello mummy'
//

split_line local.info local.dont_say local.spacer:

	local.wordcount = 1

	if(local.spacer==NIL)
	{
		if(local.info[0] == "`")
		{
			local.spacer = "_"
			local.start = 1
		}
		else if(local.info[0] == " " || local.info[0] == "")
		{
			local.spacer = " "

			for(local.i = 0;local.i <= local.info.size;local.i++)
			{
				if(local.info[local.i] != " " && local.info[local.i] != "")
				{
					local.start = local.i
					break
				}
			}

		}
		else 
		{
			local.spacer = " "
			local.start = 0
		}
	}
	else
	{
		local.start = 0
		local.altcheck = 1
	}

	for(local.i=local.start;local.i<=local.info.size - 1;local.i++)
	{	
		if(local.info[local.i]!=local.spacer && local.info[local.i] != "`")
		{
			if(local.words[local.wordcount]==NIL)
			{
				local.words[local.wordcount]=""
			}

			local.words[local.wordcount] += local.info[local.i]
		}
		else
		{	
			if(local.altcheck != 1)
			{
				if(local.spacer == "_" && local.info[local.i + 1] == "`")	// if its like ui_hud 1. sud be ui_`hud so it knows:).
				{
					local.words[local.wordcount] += local.info[local.i]			
				}
				else if(local.spacer == "_" && local.info[local.i ] != "`")
				{
					local.wordcount++
				}
				else if(local.spacer == " " && local.info[local.i ] == " ")
				{
					if(local.i != local.info.size - 1)
					{
						if(local.info[local.i + 1] != " " && local.info[local.i + 1] != NIL)
						{
							local.wordcount++
						}
					}
				}
			}
			else
			{
				if(local.info[local.i ] == local.spacer)
				{
					local.wordcount++
				}
			}
		}
	}	

	if(local.spacer == "_")
	{
		local.actual = ""

		for(local.i=3;local.i<=local.words.size;local.i++)
		{
			if(local.i < local.words.size)
			{
				local.space = " "
			}
			else
			{
				local.space = ""
			}
			local.actual += ( local.words[local.i] + local.space )
		}

		if(local.dont_say != 1)
		{
			exec global/ac/console_feedback.scr ( "> Input detected: " + local.actual )
		}
	}
	else
	{
		if(local.dont_say != 1)
		{
			exec global/ac/console_feedback.scr ( "> Input detected: " + local.info)
			local.actual = local.info
		}
	}

end ( local.words::local.wordcount::local.actual) 




// Replace is used just like replace in notepad or any text editor. 
// It will replace any string in a string with a string of any size. 
//
// exec global/strings::Replace ( String string , String String to replace, string string to replace with )
//
// eg
// local.string = waitexec global/strings.scr::Replace "once_upon_a_time_there_was__a_mod" "_" " "
// local.string would become
// "once upon a time there was  a mod" 

Replace local.string local.replace local.replace_with:


	if(local.replace.size == 1)
	{
		local.checktype = 0
	}
	else
	{
		local.checktype = 1
	}
	
	local.new_str = ""

	for(local.i = 0; local.i <= local.string.size - 1; local.i++)
	{
		if(local.checktype == 0)
		{
			local.check =  (local.replace ==  local.string[local.i])
		}
		else
		{
			local.check =  (local.replace[0] ==  local.string[local.i])
		}

		if(local.check)
		{
			if(local.checktype == 0)
			{
				if(local.replace_with.size == 1)
				{
					local.new_str += local.replace_with
				}
				else
				{
					for(local.t = 0;local.t <= local.replace_with.size - 1 ;local.t++)
					{
						local.new_str += local.replace_with[local.t]
					}
				}

			}
			else
			{
				local.no = 0
				local.m = local.i
				for(local.t = 0;local.t <= local.replace.size - 1 ;local.t++)
				{
					if(local.replace[local.t] != local.string[local.m])
					{
						local.no = 1
					}
					local.m++
				}

				if(local.no != 1)
				{
					for(local.t = 0;local.t <= local.replace_with.size - 1 ;local.t++)
					{
						local.new_str += local.replace_with[local.t]
					}
					local.i += local.replace.size - 1
				}
				else
				{
					local.new_str += local.string[local.i]
				}
				
			}

		}
		else
		{
			local.new_str += local.string[local.i]
		}
	}

end local.new_str 




// Remove is used to remove words or single characters from a line.
//
// exec global/strings::Remove ( String string , String String to replace )
//
// eg
// local.string = waitexec global/strings.scr::Remove "hello you idiot" "idiot"
// local.string would become
// "hello you idiot"

Remove local.string local.string_remove:

	local.string = waitthread Replace local.string local.string_remove ""

end local.string




// Format_replace is used like Replace except it will only replace a single instance in a group of the same character.
// It will only replace single characters.
//
// exec global/strings::Replace ( String string , String String to replace, string string to replace with )
//
// eg
// local.string = waitexec global/strings.scr::Format_replace "once_upon_a_time_there_was__a_mod" "_" " "
// local.string would become
// "once upon a time there was_a mod" 

Format_replace local.string local.replace local.replace_with:

	local.new_str = ""

	for(local.i = 0; local.i <= local.string.size - 1; local.i++)
	{

		local.check =  (local.replace ==  local.string[local.i] && local.replace != local.string[local.i + 1])

		if(local.check)
		{
			if ( local.string[local.i - 1] !=  local.replace)
			{
				local.new_str += local.replace_with
			}
		}
		else
		{
			local.new_str += local.string[local.i]
		}
	}

end local.new_str 


// Combine combines a array of stirngs into one single string of all.
// exec global/strings:;Combine (ARRAY , INT START IN ARRAY)
// 

Combine local.words local.start:

	local.actual = ""

	for(local.i=local.start;local.i<=local.words.size;local.i++)
	{
		if(local.i < local.words.size)
		{
			local.space = " "
		}
		else
		{
			local.space = ""
		}

		local.actual += ( local.words[local.i] + local.space )
	}

end local.actual

// array_to_int
// converts a array into interger
// returns the array as int

array_to_int local.array:

	if(local.array[0] != NIL)
	{
		local.start = 0
	}
	else
	{
		local.start = 1
	}

	for(local.i = local.start;local.i <= local.array.size; local.i++)
	{
		 local.array[local.i] = int local.array[local.i]
	}

end local.array

// array_to_str
// converts a array into string
// returns the array as string
array_to_str local.array:

	if(local.array[0] != NIL)
	{
		local.start = 0
	}
	else
	{
		local.start = 1
	}

	for(local.i = local.start;local.i <= local.array.size; local.i++)
	{
		 local.array[local.i] = string local.array[local.i]
	}

end local.array

// array_to_float
// converts a array into float
// returns the array as float
array_to_float local.array:

	if(local.array[0] != NIL)
	{
		local.start = 0
	}
	else
	{
		local.start = 1
	}

	for(local.i = local.start;local.i <= local.array.size; local.i++)
	{
		 local.array[local.i] = float local.array[local.i]
	}

end local.array
Good luck ;)
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Post Reply