Hey there,
I haven't worked with props before, but I think you shouldn't be creating a prop with a name, if you are looking for a prop that already exists. Not sure, how the function deals with name ambiquity. Will it pick the closest prop with that name on the map? Or just the first it finds in memory? That would make a difference for sure.
Let's see where I can actually help here..
I can't see what calls your code here, so I'd suggest the following. You may want to trigger the code execution on player movement, which is caught by
PHP Code:
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
//your code here
//or: to check movement, we could go further with this:
if(buttons & (IN_MOVELEFT | IN_MOVERIGHT | IN_FORWARD | IN_BACK))
{
//code, when player presses movement keys
}
return Plugin_Continue;
}
this may require the following defines somewhere at the top of your script. See:
http://docs.sourcemod.net/api/index....d=file&id=47&)
PHP Code:
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10)
Be aware, that this code gets executed several times a second. Maybe you only want to execute it, when a player enters or leaves the area. In that case you probably want to use boolean flags.
Globally define
PHP Code:
bool g_playerInZone[MAXPLAYERS+1]
then:
PHP Code:
if(GetVectorDistance(clientpos, bombpos) < 100)
{
if(!g_playerInZone[client])
{
//do something once, when the player enters the zone
g_playerInZone[client] = true;
PrintToChat(client, "Player entered bombzone");
}
//do something very often while a player is in the zone
//...
}
else
{
if(g_playerInZone[client])
{
g_playerInZone[client] = false;
PrintToChat(client, "Player left bombzone");
}
}