Home » Renegade Discussions » Mod Forum » problem with lua scripts
problem with lua scripts [message #412452] |
Sat, 28 November 2009 01:07 |
|
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
Cookie Jar<glome> Who stole the cookie from the cookie jar?!
<content> glome stole the cookie from the cookie jar!
<glome> Who me?!
<content> Yes you!
<glome> Couldn't be!
<content> Then WHO?!!
<glome> Woody stole the cookie from the cookie jar!
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch
Suicide<TB> I was depressed last night so I called the Suicide Life Line.
<TB> I reached a call center in Pakistan.
<TB> I told them I was suicidal.
<TB> They got all excited and asked if I could drive a truck
|
|
|
Re: problem with lua scripts [message #412456 is a reply to message #412452] |
Sat, 28 November 2009 01:58 |
|
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 |
|
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
Cookie Jar<glome> Who stole the cookie from the cookie jar?!
<content> glome stole the cookie from the cookie jar!
<glome> Who me?!
<content> Yes you!
<glome> Couldn't be!
<content> Then WHO?!!
<glome> Woody stole the cookie from the cookie jar!
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch
Suicide<TB> I was depressed last night so I called the Suicide Life Line.
<TB> I reached a call center in Pakistan.
<TB> I told them I was suicidal.
<TB> They got all excited and asked if I could drive a truck
|
|
|
Re: problem with lua scripts [message #412602 is a reply to message #412452] |
Sun, 29 November 2009 09:16 |
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 |
|
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 |
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
-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 |
|
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
Cookie Jar<glome> Who stole the cookie from the cookie jar?!
<content> glome stole the cookie from the cookie jar!
<glome> Who me?!
<content> Yes you!
<glome> Couldn't be!
<content> Then WHO?!!
<glome> Woody stole the cookie from the cookie jar!
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch
Suicide<TB> I was depressed last night so I called the Suicide Life Line.
<TB> I reached a call center in Pakistan.
<TB> I told them I was suicidal.
<TB> They got all excited and asked if I could drive a truck
|
|
|
Re: problem with lua scripts [message #412658 is a reply to message #412452] |
Sun, 29 November 2009 21:48 |
Hubba
Messages: 40 Registered: October 2009
Karma: 0
|
Recruit |
|
|
Haha whoops srry 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 |
|
Distrbd21
Messages: 743 Registered: September 2008
Karma: 0
|
Colonel |
|
|
Hubba wrote on Sun, 29 November 2009 22:48 | Haha whoops srry 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
Cookie Jar<glome> Who stole the cookie from the cookie jar?!
<content> glome stole the cookie from the cookie jar!
<glome> Who me?!
<content> Yes you!
<glome> Couldn't be!
<content> Then WHO?!!
<glome> Woody stole the cookie from the cookie jar!
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch
Suicide<TB> I was depressed last night so I called the Suicide Life Line.
<TB> I reached a call center in Pakistan.
<TB> I told them I was suicidal.
<TB> They got all excited and asked if I could drive a truck
[Updated on: Mon, 30 November 2009 00:08] Report message to a moderator
|
|
|
|
Re: problem with lua scripts [message #412670 is a reply to message #412452] |
Mon, 30 November 2009 00:13 |
|
Distrbd21
Messages: 743 Registered: September 2008
Karma: 0
|
Colonel |
|
|
ty
Live Your Life Not Some one Else's.| Sharing Is Caring
Cookie Jar<glome> Who stole the cookie from the cookie jar?!
<content> glome stole the cookie from the cookie jar!
<glome> Who me?!
<content> Yes you!
<glome> Couldn't be!
<content> Then WHO?!!
<glome> Woody stole the cookie from the cookie jar!
*** glome has been kicked by DrWoody (fuck you i didn't touch the motherfucking cookie, bitch
Suicide<TB> I was depressed last night so I called the Suicide Life Line.
<TB> I reached a call center in Pakistan.
<TB> I told them I was suicidal.
<TB> They got all excited and asked if I could drive a truck
|
|
|
Goto Forum:
Current Time: Sun Dec 15 06:33:49 MST 2024
Total time taken to generate the page: 0.00855 seconds
|