I'm trying to add zones to SP but no matter what i try the game always freezes and the console gives no hint as to why. I've tried changing the code up a bit but it its always the same result.
First there is an array entity, and it is being called by an istouching() which YaPhil says it is not working. Then if you maybe just remove the array entity at the top which I did here now and not remove the array entity at the bottom because that entity is not being called by an istouching()
Am I right about this? I don't know if this will work but I did as Phil said, removed the array.
Am I right about this? I don't know if this will work but I did as Phil said, removed the array.
I have never said one should remove the array. Also, you removed the zone array not the player array which IsTouching() is being called on. jjbradman got the basic idea right, you have to do a for loop through the players array and test for every player entity individually. Obviously you have to change up your logic to accomodate for this. Also since you now have a for loop inside a for loop make sure to name the counting variables different in the inner loop, otherwise it won't work like you want it to.
I have never said one should remove the array. Also, you removed the zone array not the player array which IsTouching() is being called on. jjbradman got the basic idea right, you have to do a for loop through the players array and test for every player entity individually. Obviously you have to change up your logic to accomodate for this. Also since you now have a for loop inside a for loop make sure to name the counting variables different in the inner loop, otherwise it won't work like you want it to.
- Phil.
I'm sorry Phil, I assumed that you mean't to remove the array. I thought you mean't the zone array itself.
Alright i removed the array on the zone variable, and added it to players so it would check for each individual player, but its still not spawning AI when i enter a zone(the ai is a spawner if it helps any).
I changed it so it would put all the players into an array, not the zones. since i can't use istouching(); with an array i have no use for it, right?
EDIT: Nevermind, i was just confused on what you meant.
Re-Edit: Still not working. I added a lprintln("player in zone"); and it keeps saying i'm in the zone when i'm not, it also doesn't get the spawners of a zone.
Last Edit: March 02, 2014, 11:25:30 pm by daedra descent
if(players[i] istouching(zone[a]) ) { level.zone[a].is_active = true; //Unsure if '[a]' has to be there but just test it for now level.zone_spawners = get_zone_specific_spawners(zone[a]);
iprintln("Player in zone"); } else if(!players[i] istouching(zone[a]) ) { level.zone[a].is_active = false; //Unsure if '[a]' has to be there but just test it for now iprintln("player not in zone"); } } }
if(players[i] istouching(zone[a]) ) { level.zone[a].is_active = true; //Unsure if '[a]' has to be there but just test it for now level.zone_spawners = get_zone_specific_spawners(zone[a]);
iprintln("Player in zone"); } else if(!players[i] istouching(zone[a]) ) { level.zone[a].is_active = false; //Unsure if '[a]' has to be there but just test it for now iprintln("player not in zone"); } } }