How would you create a buyzone in a certain spot that can be used? Let's just say for example in a spot where a person spawns, thus something like {-16.0,-16.0,-36.0}/{16.0,16.0,36.}.
I've tried checking if the person is next to it and forcing them to touch, but nothing is happening. I've also tried forcing the status icon, but that also doesn't work.
Code:
Ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
if(!Ent)
return 0
//new TeamValue[5]
//format(TeamValue,4,"%d",Team + 1)
set_pev(Ent,pev_classname,g_Buyzone)
set_pev(Ent,pev_model,"*19")
//set_kvd(0,KV_ClassName,g_Buyzone)
//set_kvd(0,KV_KeyName,"team")
//set_kvd(0,KV_Value,TeamValue)
//set_kvd(0,KV_fHandled,0)
//dllfunc(DLLFunc_KeyValue,Ent,0)
//set_pev(Ent,pev_movetype,MOVETYPE_PUSH)
set_pev(Ent,pev_team,Team + 1)
dllfunc(DLLFunc_Spawn,Ent)
engfunc(EngFunc_SetOrigin,Ent,Origin)
new Float:Min[3],Float:Max[3]
Min = Origin
Max = Origin
Min[2] -= 36.0
Max[2] += 36.0
for(new Count;Count < 2;Count++)
{
Min[Count] -= 16.0
Max[Count] += 16.0
}
set_pev(Ent, pev_renderfx, kRenderFxNone)
set_pev(Ent, pev_rendercolor, Float:{0.0,255.0,0.0})
set_pev(Ent, pev_rendermode, kRenderNormal)
set_pev(Ent, pev_renderamt, 255.0)
//set_pev(Ent,pev_absmin,Min)
//set_pev(Ent,pev_absmax,Max)
//set_pev(Ent,pev_mins,Min)
//set_pev(Ent,pev_maxs,Max)
//engfunc(EngFunc_SetSize,Ent,Min,Max)
engfunc(EngFunc_SetSize,Ent,Float:{-100.0,-100.0,-36.0},Float:{100.0,100.0,36.0})
set_pev(Ent,pev_solid,SOLID_TRIGGER)
//set_pev(Ent,pev_team,Team + 1)
Very messy, I know.
Code:
public ForwardPlayerPostThink(id)
{
static Float:Origin[3],Classname[33]
pev(id,pev_origin,Origin)
new Ent,Team = get_user_team(id)
while((Ent = engfunc(EngFunc_FindEntityByString,Ent,"classname",g_Buyzone)) != 0)
{
if(fm_distance_to_boxent(id,Ent) > 50.0 || pev(Ent,pev_team) != Team)
continue
client_print(id,print_chat,"Found buyzone")
dllfunc(DLLFunc_Touch,Ent,id)
break
}
}
It says "found buyzone" when you're close to one, but it doesn't let you buy.