Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » problem with lua scripts
problem with lua scripts [message #412452] Sat, 28 November 2009 01:07 Go to next message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

Ok i have 2 right now that i'm trying to get to work but when i put them on, they don't???
Do i have to have a bot running with them, for them to work?

Here they are one is !B rail the other is First Blood.

if Message == "!b rail" then
               if Purchase_Item(Get_GameObj(pID), 600) == 1 then
                  local pos = Get_Position(Get_GameObj(pID))
                  Grant_Powerup(Get_GameObj(pID), "POW_Railgun_Player")
            Grant_Powerup(Get_GameObj(pID), "CnC_POW_Ammo_ClipMax")
            InputConsole("cmsg 0,230,57 [Weap-Bot]: %s has bought a railgun.", Get_Player_Name_By_ID(pID))
               else
               InputConsole("ppage %d You Need 600 credits to buy this.", pID)
            end
      end

function Killed(ID, obj, killer)
   if ReadINI("LuaPlugins/Misc/Misc.ini", "misc", "firstblood") == "1" then
      KpID = Get_Player_ID(killer)
      DpID = Get_Player_ID(obj)
      if Is_Soldier(obj) == 1 then
         if KpID >= 1 then
            Knick = Get_Player_Name(killer)
            if KpID ~= DpID then
               stored = ReadINI("LuaPlugins/Misc/Misc.ini", "firstblood", "kills")
               givecash = ReadINI("LuaPlugins/Misc/Misc.ini", "firstblood", "cash")
               kilz = stored + 1
               if kilz == 1 then
                  InputConsole("msg ***FIRST BL00D*** | %s, Enjoy $%s for First Blood!", Knick, givecash)
                  pcash = Get_Money(killer)
                  Set_Money(killer, pcash + givecash)
                  InputConsole("ppage %d, Enjoy $%s for First Blood!", KpID, givecash)
                  InputConsole("SNDA mxxdsgn_dsgn0059i1nemg_snd.wav")
                  WriteINI("LuaPlugins/Misc/Misc.ini", "firstblood", "kills", kilz)
               else
                  WriteINI("LuaPlugins/Misc/Misc.ini", "firstblood", "kills", kilz)
               end
            end
         end
      end
   end
end


Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
Re: problem with lua scripts [message #412456 is a reply to message #412452] Sat, 28 November 2009 01:58 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
I don't know anything about LUA or the LUA plugin, either. However, I spotted this line 'local pos = Get_Position(Get_GameObj(pID))' and I am curious as to why it is needed. I am looking at the code like it was any other OOP code and cannot see a reason for it.

Also, that first blood code to me looks not so nice. As far as I can tell it writes to disk to store information.
Surely it should use the level_loaded event to set a variable to false or something. It seems a strange way to work.

Sorry I cannot answer your questions.



[Updated on: Sat, 28 November 2009 02:01]

Report message to a moderator

Re: problem with lua scripts [message #412548 is a reply to message #412452] Sat, 28 November 2009 15:06 Go to previous messageGo to next message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

ty for trying though, i'm going to try someone that can help me on this.

Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
Re: problem with lua scripts [message #412602 is a reply to message #412452] Sun, 29 November 2009 09:16 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
What version of lua do you use?

If you use version 5 you have to change all the PiD's to PlayerId

Like this:
	if Message == "!b rail" then
               if Purchase_Item(Get_GameObj(PlayerId), 600) == 1 then
                  local pos = Get_Position(Get_GameObj(PlayerId))
                  Grant_Powerup(Get_GameObj(PlayerId), "POW_Railgun_Player")
            Grant_Powerup(Get_GameObj(PlayerId), "CnC_POW_Ammo_ClipMax")
            InputConsole("cmsg 0,230,57 [Weap-Bot]: %s has bought a railgun.", Get_Player_Name_By_ID(PlayerId))
               else
               InputConsole("ppage %d You Need 600 credits to buy this.", PlayerId)
            end
      end


I don't know if the other one works. But do you have Misc.Ini file at this location LuaPlugins/Misc/Misc.ini?

[Updated on: Sun, 29 November 2009 09:26]

Report message to a moderator

Re: problem with lua scripts [message #412605 is a reply to message #412602] Sun, 29 November 2009 10:38 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
Hubba wrote on Sun, 29 November 2009 16:16

What version of lua do you use?

If you use version 5 you have to change all the PiD's to PlayerId

Like this:
	if Message == "!b rail" then
               if Purchase_Item(Get_GameObj(PlayerId), 600) == 1 then
                  local pos = Get_Position(Get_GameObj(PlayerId))
                  Grant_Powerup(Get_GameObj(PlayerId), "POW_Railgun_Player")
            Grant_Powerup(Get_GameObj(PlayerId), "CnC_POW_Ammo_ClipMax")
            InputConsole("cmsg 0,230,57 [Weap-Bot]: %s has bought a railgun.", Get_Player_Name_By_ID(PlayerId))
               else
               InputConsole("ppage %d You Need 600 credits to buy this.", PlayerId)
            end
      end


I don't know if the other one works. But do you have Misc.Ini file at this location LuaPlugins/Misc/Misc.ini?




"Change all pIDs to PlayerIds"? This is not true at all, you can name the argument to any of the event functions (OnChat OnPlayerJoin etc) whatever you like. For example:
function OnChat(theplayaidentifcationnumber, messagetype, themessage, themessagetarget)

end

Re: problem with lua scripts [message #412606 is a reply to message #412602] Sun, 29 November 2009 10:41 Go to previous messageGo to next message
raven
Messages: 595
Registered: January 2007
Location: Toronto, Ontario
Karma: 0
Colonel
Hubba wrote on Sun, 29 November 2009 16:16

What version of lua do you use?

If you use version 5 you have to change all the PiD's to PlayerId



AFAIK you can change it to whatever you'd like.

Edit: jnz beat me to it Sad


-Jelly Administrator
-Exodus Administrator

[Updated on: Sun, 29 November 2009 10:41]

Report message to a moderator

Re: problem with lua scripts [message #412646 is a reply to message #412605] Sun, 29 November 2009 16:02 Go to previous messageGo to next message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

jnz wrote on Sun, 29 November 2009 11:38

Hubba wrote on Sun, 29 November 2009 16:16

What version of lua do you use?

If you use version 5 you have to change all the PiD's to PlayerId

Like this:
	if Message == "!b rail" then
               if Purchase_Item(Get_GameObj(PlayerId), 600) == 1 then
                  local pos = Get_Position(Get_GameObj(PlayerId))
                  Grant_Powerup(Get_GameObj(PlayerId), "POW_Railgun_Player")
            Grant_Powerup(Get_GameObj(PlayerId), "CnC_POW_Ammo_ClipMax")
            InputConsole("cmsg 0,230,57 [Weap-Bot]: %s has bought a railgun.", Get_Player_Name_By_ID(PlayerId))
               else
               InputConsole("ppage %d You Need 600 credits to buy this.", PlayerId)
            end
      end


I don't know if the other one works. But do you have Misc.Ini file at this location LuaPlugins/Misc/Misc.ini?




"Change all pIDs to PlayerIds"? This is not true at all, you can name the argument to any of the event functions (OnChat OnPlayerJoin etc) whatever you like. For example:
function OnChat(theplayaidentifcationnumber, messagetype, themessage, themessagetarget)

end



i have tried to add that on chat thing but all it does is give me errors.


Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
Re: problem with lua scripts [message #412658 is a reply to message #412452] Sun, 29 November 2009 21:48 Go to previous messageGo to next message
Hubba is currently offline  Hubba
Messages: 40
Registered: October 2009
Karma: 0
Recruit
Haha whoops srry Blush i dont know much about lua.

But anyways could you post your whole function?
And do you have hooks.dll and luaplugin.dll in your servers folder?
Have you added LuaPlugin to your ssgm file?

This should work:
function OnChat(PlayerId, Type, Message, Target)

if Message == "!b rail" then
               if Purchase_Item(Get_GameObj(PlayerId), 600) == 1 then
                  local pos = Get_Position(Get_GameObj(PlayerId))
                  Grant_Powerup(Get_GameObj(PlayerId), "POW_Railgun_Player")
		  Grant_Powerup(Get_GameObj(PlayerId), "CnC_POW_Ammo_ClipMax")
		  InputConsole("cmsg 0,230,57 [Weap-Bot]: %s has bought a railgun.", Get_Player_Name_By_ID(PlayerId))
               else
               InputConsole("ppage %d You Need 600 credits to buy this.", PlayerId)
            end
      end

	return 1
end

[Updated on: Sun, 29 November 2009 21:58]

Report message to a moderator

Re: problem with lua scripts [message #412667 is a reply to message #412658] Sun, 29 November 2009 23:54 Go to previous messageGo to next message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

Hubba wrote on Sun, 29 November 2009 22:48

Haha whoops srry Blush i dont know much about lua.

But anyways could you post your whole function?
And do you have hooks.dll and luaplugin.dll in your servers folder?
Have you added LuaPlugin to your ssgm file?

This should work:
function OnChat(PlayerId, Type, Message, Target)

if Message == "!b rail" then
               if Purchase_Item(Get_GameObj(PlayerId), 600) == 1 then
                  local pos = Get_Position(Get_GameObj(PlayerId))
                  Grant_Powerup(Get_GameObj(PlayerId), "POW_Railgun_Player")
		  Grant_Powerup(Get_GameObj(PlayerId), "CnC_POW_Ammo_ClipMax")
		  InputConsole("cmsg 0,230,57 [Weap-Bot]: %s has bought a railgun.", Get_Player_Name_By_ID(PlayerId))
               else
               InputConsole("ppage %d You Need 600 credits to buy this.", PlayerId)
            end
      end

	return 1
end


SSGM has the lua plugin on it, hooks is in there, no i don't have the misc.ini stuff in there i thought it did it by it self.. i'm going to try this.

Is there anyway to keep people from buying stuff when they are not in there base?

OK so i just tested it and it worked but i had no message's, is that because i had no bot on?

Also i got these errors.

[Error] C:\Westwood\RenegadeFDS\Server\LuaPlugins\Rail.lua:10: attempt to call g
lobal 'InputConsole' (a nil value)
[Error] C:\Westwood\RenegadeFDS\Server\LuaPlugins\Rail.lua:10: attempt to call g
lobal 'InputConsole' (a nil value)
Distrbd21: hmm
Distrbd21 picked up a Health Crate.
[Error] C:\Westwood\RenegadeFDS\Server\LuaPlugins\Rail.lua:8: attempt to call gl
obal 'InputConsole' (a nil value)


I got these when i was trying to buy it and when i bought it.


Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide

[Updated on: Mon, 30 November 2009 00:08]

Report message to a moderator

Re: problem with lua scripts [message #412669 is a reply to message #412452] Sun, 29 November 2009 23:59 Go to previous messageGo to next message
Lone0001 is currently offline  Lone0001
Messages: 2112
Registered: August 2006
Location: Ontario, Canada
Karma: 0
General (2 Stars)

Here are some old examples I've collected/had lying around, though take note that some of the lua code might be from outdated/older versions.

[Updated on: Fri, 12 February 2010 09:38]

Report message to a moderator

Re: problem with lua scripts [message #412670 is a reply to message #412452] Mon, 30 November 2009 00:13 Go to previous message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma: 0
Colonel

ty

Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
Previous Topic: [Tutorial]Add moving effects and bone a character
Next Topic: !afk command for lua
Goto Forum:
  


Current Time: Tue Dec 24 01:52:04 MST 2024

Total time taken to generate the page: 0.00958 seconds