Hello,
I've been trying to create a script that will check if the client is within range of a specific entity, specifically a bomb plant zone within a map.
If they get within range of this entity I would like to be able to perform certain actions, but I'm having some trouble getting it to work. Essentially I want to compare [Player Position] with [Entity Position], where the entity is static in the map and player position will be dynamically updating.
Code:
decl Float:bombpos[3], Float:clientpos[3];
new BombZone = CreateEntityByName("ddd_bomb_plant_zone");
GetClientAbsOrigin(client, clientpos);
GetEntPropVector(BombZone, Prop_Send, "ddd_bomb_plant_zone", bombpos);
if(GetVectorDistance(clientpos, bombpos) < 100)
{
//Let me know that you're within range of this entity.
PrintToChat(client, "In bomb zone");
}
Notes:
1. "ddd_bomb_plant_zone" is an entity that already exists in the map.
2. There are multiple "ddd_bomb_plant_zone"(s) if that makes any difference.
What I'm currently doing is probably horribly wrong (please forgive me, this is all quite new stuff), any examples of how to add/change this and what I'm doing incorrectly would be much appreciated.
Thank you in advance for your time.