I have been working on a script using information and tutorials on the forums, wiki, and internet in general that makes props you spawn orbit around a set target, which by default is the e2 chip. I have chat commands to change the target and also the props that orbit, but its not perfect.
When the chip is spawned the currently existing props will begin to orbit, but when they are dropped with the chat command, using the pick up command will not pick them up unless the chip is re-uploaded.
The script which originally inspired me to make this (which i haven't used as any sort of reference) can pick up props without having to reset the chip, but i no longer have the script so i cant compare it to mine.
Also, when the targeting command is used, props will fly to the origin. And will return when i use the null command.
If anyone can tell me what is wrong with my entity discovery code and point me in the right direction, it would be 3.5% more excellent than expensive ice cream and i would appreciate it.
Code:
@name proporbit
@persist Counter Theta TotalProps OrbitHeight P Y R OrbitSpeed Radius Orbit
@persist FoundProps:array TargArray:array String:array
@persist Facing:angle Inertia:angle Chpfl:vector DiffPos:vector Dest:vector
@persist OrbitTarg:entity
##################### Chat Commands
if(first()|duped()) {
runOnTick(1)
runOnChat(1)
OrbitTarg = entity()
Orbit = 0
OrbitHeight = 100
Radius = 300
OrbitSpeed = 1
runOnChat(1)
findClearWhiteList()
findIncludePlayerProps(owner())
findByClass("prop_physics")
FoundProps = findToArray()
}
if(chatClk(owner())) {
if(owner():lastSaid():left(4) == "face") {
String = lastSaid():explode(" ")
Name = String:string(2)
if(Name=="null") {
FaceTarg=entity()
}elseif(Name=="aim") {
#FaceTarg=owner():eye()
}else{
FaceTarg = findPlayerByName(Name)
}
}elseif(owner():lastSaid():left(5) == "orbit") {
String = lastSaid():explode(" ")
Name = String:string(2)
if(Name=="null") {
OrbitTarg=entity()
}else{
OrbitTarg = findPlayerByName(Name)
}
}elseif(owner():lastSaid():left(3) == "set") {
String = lastSaid():explode(" ")
Var = String:string(2)
Val = String:string(3):toNumber()
if(Var=="radius") {
Radius=Val
}elseif(Var=="orbitheight") {
OrbitHeight=Val
}elseif(Var=="orbitspeed") {
OrbitSpeed=Val
}
}elseif(owner():lastSaid():left(4) == "prop") {
String = lastSaid():explode(" ")
Cmd = String:string(2)
if(Cmd=="drop") {
Temp = FoundProps:removeEntity(1)
Temp:setColor(255,255,255,255)
Temp:setMaterial("")
}elseif(Cmd=="dropfirst") {
Temp = FoundProps:popEntity()
Temp:setColor(255,255,255,255)
Temp:setMaterial("")
}elseif(Cmd=="excludefirst") {
Temp = FoundProps:popEntity()
Temp:setColor(255,255,255,255)
Temp:setMaterial("")
findExcludeEntity(Temp)
}elseif(Cmd=="exclude") {
Temp = FoundProps:removeEntity(1)
Temp:setColor(255,255,255,255)
Temp:setMaterial("")
findExcludeEntity(Temp)
}elseif(Cmd=="include") {
findClearBlackList()
}elseif(Cmd=="grab") {
findClearWhiteList()
findIncludePlayerProps(owner())
findByClass("prop_*")
FoundProps = findToArray()
}
}elseif(owner():lastSaid():left(4) == "mode") {
String = lastSaid():explode(" ")
Cmd = String:string(2)
if(Cmd=="orbit") {
Orbit=1
}
}
}
#####################
TotalProps = FoundProps:count()
AllProps = FoundProps:entity(Counter+1)
Counter = (Counter+1)%TotalProps
##################### Make Props Orbit
Theta = Theta+OrbitSpeed
Theta = mod(Theta,360)
OrbitCenter = OrbitTarg:pos() + vec(0,0,OrbitHeight)
OrbitOffset = vec(Radius*cos(Theta+((360/TotalProps)*Counter)),Radius*sin(Theta+((360/TotalProps)*Counter)),0)
TargPropPos = OrbitCenter + OrbitOffset
DiffPos = TargPropPos-AllProps:pos()
if(Orbit) {
AllProps:applyForce((DiffPos*10-AllProps:vel())*AllProps:mass())
}
insta-by-the-way-edit: hello everyone, i am new here
Bookmarks