Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Lua. Answers.
Lua. Answers. [message #449409] Mon, 04 July 2011 09:57 Go to next message
hego64 is currently offline  hego64
Messages: 19
Registered: April 2011
Location: Hegoville
Karma: 0
Recruit
Look. I know I have posted a lot about this. Thing is, I just want a straight answer. How can I edit/use this function.

function myscript:Killed(ID, obj, killer) 
	print("Killed", ID, obj, killer)
end


All I need is to know HOW to use this and make it work for what I want.

Quote:

When a player not in spectate mode dies, he/she turns into a spectator and someone else in spectate mode dies and spawns to take their place. I'm not sure how to do this, or if it is even possible. Any help would be appreciated Very Happy

Thanks,
Hego64


Just someone please help me out with this, and I can get out of everyone's hair here for awhile.

-Hego64
Re: Lua. Answers. [message #449455 is a reply to message #449409] Tue, 05 July 2011 21:36 Go to previous messageGo to next message
Dave Anderson is currently offline  Dave Anderson
Messages: 1953
Registered: December 2004
Location: United States
Karma: 0
General (1 Star)
You may want to search for "killed script" or something similar in this forum. There's a lot of resources there and its been asked numerous times before. I did some small searching and there's a few topics that may have what you need, but I don't write LUA or touch C&C so I can't help you myself.

David Anderson
Founder, Software Consultant
DCOM Productions
Microsoft Partner (MSP)
Re: Lua. Answers. [message #449471 is a reply to message #449455] Wed, 06 July 2011 12:25 Go to previous messageGo to next message
hego64 is currently offline  hego64
Messages: 19
Registered: April 2011
Location: Hegoville
Karma: 0
Recruit
Ok, Thanks! I think I found what I needed. My only problem now is that my spectate wont work...its not listed in the commands.txt or the real console commands one.

Whenever I try to use InputConsole("spectate %d", pID) the FDS says that its not a real command. Any ideas on how to fix/make it work?

Thanks,
-Hego64
Re: Lua. Answers. [message #449472 is a reply to message #449471] Wed, 06 July 2011 13:01 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
There is no such command, you need to make your own spectate function Wink if you want to use it then you have to have Brenbot 1.52 (Brenbot.dll loaded in to ssgm)
Re: Lua. Answers. [message #449480 is a reply to message #449472] Wed, 06 July 2011 16:55 Go to previous messageGo to next message
hego64 is currently offline  hego64
Messages: 19
Registered: April 2011
Location: Hegoville
Karma: 0
Recruit
Thanks! I was able to make the spectate work now. But I have one more problem...

This is what I currently have in LUA.

function OnObjectCreate(o) 
	if Is_A_Star(o) then 
		Attach_Script_Once(o, "myscript", ""
              
    end
end

myscript = {}

function myscript:Killed(ID, obj, killer) 
	print("Killed", ID, obj, killer)
end

	if KpID ~= -1 then
	InputConsole("spectate %d", pID)

Register_Script("myscript", "", myscript) 
	
end


I do not know what is wrong with this. But when I try it in-game, this is what happens.



  1. Type/chat does not show up.
  2. Whenever we do type, we are sent to spectate and the second time we die and spawn. Happens regardless of what you type.
  3. I still get an FDS error saying I can't have more than one script named myscript. I do not know why this happens, because I have checked and I have only ONE myscript function with that. What can I do to rename this or something to fix it? I really need the chat fixed too.


I don't know what else to do...can anyone help me to figure out what I did wrong in this?

Thanks,
-Hego64


Re: Lua. Answers. [message #449492 is a reply to message #449480] Thu, 07 July 2011 00:12 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
local killedtimes = 0

function OnObjectCreate(o) 
	if Is_A_Star(o) then 
	   Attach_Script_Once(o, "Killed_Speccript", "")    
    end
end

Killed_Speccript = {}

function Killed_Speccript:Killed(ID, obj, killer) 
	print("Killed | ID - %d", ID) 
        if killedtimes == 0 then
	    InputConsole("spectate %d", ID)           
            killedtimes = 1
        else
            killedtimes = 0  
        end
end

Register_Script("Killed_Speccript", "", Killed_Speccript) 


Haven't done LUA in a long time but i think that should work Wink

[Updated on: Thu, 07 July 2011 00:30]

Report message to a moderator

Re: Lua. Answers. [message #449500 is a reply to message #449492] Thu, 07 July 2011 12:09 Go to previous messageGo to next message
hego64 is currently offline  hego64
Messages: 19
Registered: April 2011
Location: Hegoville
Karma: 0
Recruit
Thanks, but it still doesn't work...it still says that I can't have more than one script with the same name, even with it being called Killed_Speccript. It says that on my line 181 which is

Register_Script("Killed_Speccript", "", Killed_Speccript) 


Any ideas on why it still says this? I've tried to change the name on that line, but then it just says that it expects a table. I am stumped on what to do with this...

-Hego64
Re: Lua. Answers. [message #449514 is a reply to message #449500] Fri, 08 July 2011 09:48 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
Hmmmm Im sorry i dont rember LUA That well but that dont make sence to me, :S
Re: Lua. Answers. [message #449780 is a reply to message #449409] Wed, 20 July 2011 18:09 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Try moving all the LUA files out of the LuaPlugins folder and adding the text from this link as .lua file in there:

http://pastebin.com/PxFetuHZ

It's a build server script made by jnz, see if it causes the FDS console window to complain about the registering scripts stuff like it does with your code.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Previous Topic: Looking for some mappers for campaign mode...
Next Topic: Lua sleep()
Goto Forum:
  


Current Time: Wed Dec 18 06:47:58 MST 2024

Total time taken to generate the page: 0.00898 seconds