Author |
Message |
MrC121989
Joined: Wed Feb 10, 2010 12:41 pm Posts: 182 Location: OMG where am i ?
|
[Request] Two Scripts (probably not very complicated)
Can someone please write me two scripts
The first one i need is to make a missile fly in random dirrection (in mid air it will curve in different directions)
And the second one i need is a script for a weapon where i can specify which actor can hold it, if he can't then the weapon is instantly dropped from his inventory.
|
Sun Dec 09, 2012 7:31 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: [Request] Two Scripts (probably not very complicated)
The first one you can do it using .ini. Just give spread to the particles that pushes the emitter (rocket). The second one isn't hard, but I haven't got any reliable methods for checking the parent, so this might simply result laggy: Code: function Create(self) self.ActorThatCanHoldThisWeapon = "Name of the Actor that can hold the weapon" self.parent = MovableMan:GetMOFromID(self.RootID) end
function Update(self)
if self.parent == nil or self.parent.ClassName ~= "AHuman" then self.parent = MovableMan:GetMOFromID(self.RootID) end if self.parent.PresetName ~= MovableMan:GetMOFromID(self.RootID).PresetName or self.parent.ClassName ~= "AHuman" then self.parent = MovableMan:GetMOFromID(self.RootID) end
if self.parent.PresetName ~= self.ActorThatCanHoldThisWeapon then self.parent:SetState(Controller.WEAPON_DROP,true) end end It probably won't work, my CC lua is pretty rusty.
|
Sun Dec 09, 2012 10:42 pm |
|
|
MrC121989
Joined: Wed Feb 10, 2010 12:41 pm Posts: 182 Location: OMG where am i ?
|
Re: [Request] Two Scripts (probably not very complicated)
1) Not what i was aiming to get, but it will do for now, maybe with some tweaking i can get it just right. 2) Just like you said, the script does not work
|
Sun Dec 09, 2012 11:40 pm |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: [Request] Two Scripts (probably not very complicated)
Try changing the 3rd last line to self.parent:GetController():SetState(Controller.WEAPON_DROP,true);
Everything else seems okay on a cursory glance, though it could probably be streamlined a bit to use 2 if statements instead of 3.
|
Mon Dec 10, 2012 3:43 am |
|
|
MrC121989
Joined: Wed Feb 10, 2010 12:41 pm Posts: 182 Location: OMG where am i ?
|
Re: [Request] Two Scripts (probably not very complicated)
In both cases this line seems causing some errors.
|
Mon Dec 10, 2012 12:50 pm |
|
|
Asklar
Data Realms Elite
Joined: Fri Jan 07, 2011 8:01 am Posts: 6211 Location: In your office, earning your salary.
|
Re: [Request] Two Scripts (probably not very complicated)
What does it print?
|
Mon Dec 10, 2012 9:33 pm |
|
|
MrC121989
Joined: Wed Feb 10, 2010 12:41 pm Posts: 182 Location: OMG where am i ?
|
Re: [Request] Two Scripts (probably not very complicated)
Ok guys i was busy a ♥♥♥♥ ton of time and could not respond. Anyway, here what console prints:
Attachments:
error.PNG [ 1.85 KiB | Viewed 9049 times ]
|
Sat Feb 23, 2013 4:36 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: [Request] Two Scripts (probably not very complicated)
Change Code: self.parent:GetController():SetState(Controller.WEAPON_DROP,true); to Code: ToActor(self.parent):GetController():SetState(Controller.WEAPON_DROP,true);
|
Sat Feb 23, 2013 4:47 am |
|
|
MrC121989
Joined: Wed Feb 10, 2010 12:41 pm Posts: 182 Location: OMG where am i ?
|
Re: [Request] Two Scripts (probably not very complicated)
It worked, but it floods the console with this mesage now, i'm afraid if i will place multiple weapons on a map it will produce massive lag.
BTW i was wondering how to make this weapon availiable to multiple units do i just write "self.ActorThatCanHoldThisWeapon = "Unit1"; "Unit2"; "Unit3"" ? And making a message popup when units that cant use it tries to pick it up, something like "Wrong unit class".
Attachments:
error2.PNG [ 2.48 KiB | Viewed 9046 times ]
|
Sat Feb 23, 2013 5:05 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: [Request] Two Scripts (probably not very complicated)
Code: function Create(self)
self.permittedUsers = {}; self.permittedUsers[1] = "Dummy"; self.permittedUsers[2] = "Browncoat Light"; self.permittedUsers[3] = "Crab"; -- You get the idea
end
function Update(self)
if self.RootID ~= self.ID then local actor = MovableMan:GetMOFromID(self.RootID); if MovableMan:IsActor(actor) then local isPermitted = false; for i = 1, #self.permittedUsers do if actor.PresetName == self.permittedUsers[i] then isPermitted = true; break; end end if not isPermitted then ToActor(actor):GetController():SetState(Controller.WEAPON_DROP,true); if ToActor(actor):IsPlayerControlled() then local parentPlayer = ToActor(actor):GetController().Player; FrameMan:ClearScreenText(parentPlayer); FrameMan:SetScreenText("YOU ARE NOT PERMITTED TO USE THIS ITEM!",parentPlayer,0,2,true); end end end end
end
|
Sun Feb 24, 2013 6:10 am |
|
|
MrC121989
Joined: Wed Feb 10, 2010 12:41 pm Posts: 182 Location: OMG where am i ?
|
Re: [Request] Two Scripts (probably not very complicated)
Awesome! Theres only slight problem, somehow the message desplays only once per match
|
Sun Feb 24, 2013 10:49 am |
|
|
|