Hello!
Trying to write a plugin that add's buyzones to the map if there are none.
Now I have 2 problems:
- I could not figure out a good way to get the team spawn coordinates to teleport the buyzone to. Right now I'm looping through all clients to get a t and ct client's position.
- It doesn't work. No errors, the buyzone just doesn't show up. With bots i got the following console message:
Code:
pos0: 632.000000, pos1: 267.000000, pos2: -295.000000(debug msg by plugin)
CT bot spawned outside of a buy zone (632, 267, -295)
As you can see, I already tried to move the 3. coordinate, because it seemed to be > than the bot spawn coordinate otherwise - no success.
My Code:
Spoiler
#include <sdktools>
public Plugin:myinfo =
{
name = "Add Buyzone",
author = "kumpu",
description = "Adds a buyzone if there is none",
version = "1.0",
url = ""
}
public OnPluginStart()
{
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public OnMapStart()
{
manageBuyZones();
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
manageBuyZones();
}
manageBuyZones()
{
decl String:szClass[65];
new bool:hasBuyZone = false;
for (new i = MaxClients; i <= GetMaxEntities(); i++)
{
if(IsValidEdict(i) && IsValidEntity(i))
{
GetEdictClassname(i, szClass, sizeof(szClass));
if(StrEqual("func_buyzone", szClass))
{
PrintToServer("has bz");
hasBuyZone = true;
break;
}
}
}