Hi.
I'm using right now code from Dretax HomeSystem 3.5 plugin, edited it a little bit, but it get looped (and crashing game).
Plugin is checking if Victim is in his house, or not, or not inside of any house.
But it getting looped. It's working only if I clear first instruction "if dist > float5():" and just leave there "continue", like in Dretax plugin. But I want this to work like here:
1. What if Victiom is outside house (what if inside) (distance 5)
2. What if it's his house
3. What if not
And I know that i need to use for this "for" loop. But don't really know how to do this to not loop server. I'm not good at this.
Could you help? I would like to write some Wiki page to explain how to use it properly.. But first I need to know myself. Of course don't look at Player checking method, it's not a problem right now as I don't want to check if attacker is player. First I need to set loop.
I'm using right now code from Dretax HomeSystem 3.5 plugin, edited it a little bit, but it get looped (and crashing game).
Plugin is checking if Victim is in his house, or not, or not inside of any house.
Python:
def On_PlayerHurt(self, Hurt):
attacker = Hurt.Attacker
victim = Hurt.Victim
if len(attacker.SteamID) > 15:
Server.Broadcast("Attacker is player") #DEBUG
id = victim.SteamID
player_location = Util.CreateVector(victim.X, victim.Y, victim.Z)
type = Util.TryFindReturnType("StructureComponent")
objects = UnityEngine.Object.FindObjectsOfType(type)
Server.Broadcast("Searching for house")
for x in objects:
if "Foundation" in x.name or "Ceiling" in x.name or "Stairs" in x.name:
dist = round(Util.GetVectorsDistance(player_location, x.gameObject.transform.position), 2)
if dist > float(5): # Checking if player is near house
Server.Broadcast("Victim is off house")
continue
ownerid = long(x._master.ownerID)
if ownerid == long(id): # Checking if player is owner
Server.Broadcast("Victim is probably house owner")
continue
else:
Server.Broadcast("Victim is raider")
1. What if Victiom is outside house (what if inside) (distance 5)
2. What if it's his house
3. What if not
And I know that i need to use for this "for" loop. But don't really know how to do this to not loop server. I'm not good at this.
Could you help? I would like to write some Wiki page to explain how to use it properly.. But first I need to know myself. Of course don't look at Player checking method, it's not a problem right now as I don't want to check if attacker is player. First I need to set loop.
Last edited: