Forum

> > CS2D > Scripts > Lua Question - Makespec error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Question - Makespec error

8 replies
To the start Previous 1 Next To the start

old Lua Question - Makespec error

Anders4000
User Off Offline

Quote
Hello there!
I'm having some problems with the Makespec <player> command.

I'm gonna make notes in my code to show you where the error occurs.
Btw. The console doesn't print out any error.

1
2
3
4
5
6
7
8
addhook("spawn","OnSpawn")
function OnSpawn(id)
	if Lives[id] > 0 then				--If statement...
		--Code skipped.
	else							--Code below GETS executed. Just not makespec for some reason.
		parse("makespec "..id)			--Nothing happens.
	end
end

So, when i put parse("killplayer"..id) instead of makespec, it works. I just don't want the sound of people spawning and dieing all over the place.

Why isn't the command working?
Btw: makespec works when i type it in console manually.

EDIT: I tried making another file with a makespec command on the spawn hook, without anything else. That worked fine.

old Re: Lua Question - Makespec error

Anders4000
User Off Offline

Quote
Here is my whole script then ^^,

Just copy-pasted the script, so sorry there will be no tabbing. It's because i use spaces as spacing, and not tab. And DC's too lazy to make the forum accept more than 1 space in a row

Spoiler >


I'm going to edit the parse("makespec "..id) to AutoSpec(id) later. It's just nok there yet, because I tested if it would work when the parse was not in a function.

old Re: Lua Question - Makespec error

J4x
User Off Offline

Quote
i don't know if this causes the error, but you are putting the numbers iside of "" when you are declaring variables. i mean
1
CurrentWinnerPos  = "5 170"
that should be
1
CurrentWinnerPos  = 5 170

old Re: Lua Question - Makespec error

KimKat
GAME BANNED Off Offline

Quote
Perhaps the code itself when run. It performs the check on how many lives you got left or something and then that fails for some reason and that results in the execution of the "else" code in which causes this bug/error to occur because you mentioned that it works when you put only the makespec code into the spawn hook.

Well, isn't that problem solved then? this should work just fine if you make two different spawn hooks with different hook names however I do believe this needs a fix sometime around.

old Re: Lua Question - Makespec error

Anders4000
User Off Offline

Quote
I found the error!

But I still can't solve it though

The Teamchange blocker blocks the console from making a player spec for some reason.

1
2
3
4
5
6
addhook("team","OnTeam")
function OnTeam(id,team)
	if Lives[id] < 1 then
		return 1
	end
end

I'm gonna try and make the script allow teamchanging till the player gets autospec'd. Then block it again. (:
- Happy programming!

EDIT: I FIXED IT!
Although I'm just starting on Spectator now, and can't join a team
Gonna look more into it tomorrow, night night.
edited 1×, last 13.06.11 12:26:28 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview