I need help calling the right array for time!

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

I need help calling the right array for time!

Post by The Jackal »

I am trying to write this lil script to welcome players to the server as they join.

However I am stumped for the array for getting the time for the player. Or perhaps, I have a error someplace else. See if you can pick it up.


playergreet:

for(local.p = 1; local.p < $player.size + 1; local.p++)
{
if($player[local.p].health == 0 && $player[local.p].dmteam == "spectator" && $player[local.p].time < 15)
{
$player[local.p] iprint "*******************************************"
$player[local.p] iprint "Welcome To <[OneX]> Sniper Alliance Server!"
$player[local.p] iprint "*******************************************"
wait 5
$player[local.p] iprint "AS I WALK THROUGH THE VALLEY OF THE SHADOW OF DEATH"
$player[local.p] iprint " I SHALL FEAR NO EVIL, FOR I AM <[OneX]>"
$player[local.p] iprint " God Bless The USA"
}
else
{

}

}
wait (10)

goto playergreet

end
Help a brother out!
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

try this:

Code: Select all

playergreet:

	level.numberoflines = 3 //for the mygreet 1, 2, and 3 arrays

	level.mygreet[1] = "*******************************************"
	level.mygreet[2] = "Welcome To <[OneX]> Sniper Alliance Server!"
	level.mygreet[3] = "*******************************************"
	
	level.mystory[1] = "AS I WALK THROUGH THE VALLEY OF THE SHADOW OF DEATH"
	level.mystory[2] = " I SHALL FEAR NO EVIL, FOR I AM <[OneX]>"
	level.mystory[3] = " God Bless The USA"

	while (1)
	{
		wait 0.5 //don't wanna eat up all the memory do we?
		local.guys = $player.size
		local.firstguy = 1
		
		for (local.i = local.guys; local.i >= local.firstguy; local.i--)
		{
			//ill start from the highest array and go down, since the newer players
			//will get the higher number arrays
			wait 0.05 //would take 3.2 seconds to go through 64 players
			local.player = $player[local.i] //easier to type for me
			if (local.player.greeted != 1) //by default his .greeted is not 1
			{
				local.player thread greetme
				local.player.greeted = 1 //so he doesn't get the greet anymore
			}
		}
	}
	end //don't really need this end here. this thread is undying.
	
greetme:

//wait until the player finishes loading
	while (self.dmteam != allies && self.dmteam != axis && self.dmteam != spectator && self.dmteam != freeforall)
	{
		wait 0.5
	}

	for (local.i = 1; local.i <= level.numberoflines; local.i++)
	{
		self iprint level.mygreet[local.i] //i used a for statement so i don't have to repeat the iprint
	}
	
	wait 5
	
	for (local.i = 1; local.i <= level.numberoflines; local.i++)
	{
		self iprint level.mystory[local.i] //now look how easy that was =)
	}
	end
If you have trouble reading it, you can paste it in notepad or something... You can just overwrite your playergreet thread. :D
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

Post by The Jackal »

Man that script made my newbie script look boring.

Thanks. I'll give it a run and see.
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

Post by The Jackal »

I placed this script in a global/greet_message.scr file. From the map file, do i call it after wait til prespawn or waitilspawn?
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

After level waittill prespawn "exec global/greet_message.scr"
Post Reply