I was writing a plugin and all was going good. Then I finished, fixed the few compiler errors, and went to test it out.
It gave me a bad load. So I went to switch a few things around, and nothing seemed to work. So I'm going to do the IceMouse thing, and give up. I'll let someone else work on it, and do whatever they please with it.
All it is, is the beginning what would have been a small conversion of EntMod(By Drunken_F00l)
So if you want to take it off my hands, then just say you will. I'll happily answer any questions about the source you have, and offer ideas of where to go from there if you fix it
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
//#define VELOCITY
new PLUGIN[] = "EntMod";
new VERSION[] = "1.0BETA";
new AUTHOR[] = "IceMouse";
new grabbed[33] = {0,...};
new Float:grablength[33] = {0.0,...};
#if defined VELOCITY
new graboldmove[33] = {0,...};
new graboldsolid[33] = {0,...};
#endif
new rndTaskID;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("+grabent", "BeginEntGrab", ADMIN_LEVEL_A, " - Grab an entity");
register_clcmd("-grabent", "EndEntGrab");
register_clcmd("+pushent", "BeginEntPush", ADMIN_LEVEL_A, " - Push the currently held entity away");
register_clcmd("-pushent", "EndEntPush");
register_clcmd("+pullent", "BeginPullEnt", ADMIN_LEVEL_A, " - Pull the currently held entity close");
register_clcmd("-pullent", "EndEntPull");
register_clcmd("use_ent","cmdUseEnt",ADMIN_LEVEL_A," - Use the entity you are looking at");
register_cvar("amxx_movestrength","25");
rndTaskID = (random_num(35,3500)*random_num(3,18))%random_num(59, 293);
}
public client_connect(id)
{
#if defined VELOCITY
if(grabbed[id] > 0)
{
entity_set_int(grabbed[id],EV_INT_movetype,graboldmove[id]);
entity_set_int(grabbed[id],EV_INT_solid,graboldsolid[id]);
}
graboldmove[id] = 0;
graboldsolid[id] = 0;
#endif
grabbed[id] = 0;
grablength[id] = 0.0;
return PLUGIN_CONTINUE;
}
public client_disconnect(id)
{
#if defined VELOCITY
if(grabbed[id] > 0)
{
entity_set_int(grabbed[id],EV_INT_movetype,graboldmove[id]);
entity_set_int(grabbed[id],EV_INT_solid,graboldsolid[id]);
}
graboldmove[id] = 0;
graboldsolid[id]=0;
#endif
grabbed[id] = 0;
grablength[id] = 0.0;
return PLUGIN_CONTINUE;
}
public BeginEntGrab(id,level,cid)
{
if(!cmd_access(id,level,cid,1))
{
client_print(id,print_console,"You do not have access to this command");
return PLUGIN_HANDLED;
}
grabbed[id] = -1;
return PLUGIN_HANDLED;
}
public EndEntGrab(id,level,cid)
{
#if defined VELOCITY
if(grabbed[id] > 0)
{
entity_set_int(grabbed[id],EV_INT_movetype,graboldmove[id]);
entity_set_int(grabbed[id],EV_INT_solid,graboldsolid[id]);
}
graboldmove[id] = 0;
graboldsolid[id]=0;
#endif
grabbed[id] = 0;
grablength[id] = 0.0;
return PLUGIN_HANDLED;
}
public client_PreThink(id)
{
if(grabbed[id] != -1)
return PLUGIN_CONTINUE
new grabEnt;
new Float:Origin[3];
new Float:End[3];
new NmEnd[3];
new Float:Return[3];
entity_get_vector(id,EV_VEC_origin,Origin);
get_user_origin(id,NmEnd,3);
IVecFVec(NmEnd,End);
grabEnt = trace_line(id, Origin, End, Return);
if(!grabEnt)
return PLUGIN_CONTINUE;
grabbed[id] = grabEnt;
#if defined VELOCITY
graboldmove[id] = entity_get_int(id,EV_INT_movetype);
graboldsolid[id] = entity_get_int(id,EV_INT_solid);
entity_set_int(id,EV_INT_solid,SOLID_BBOX);
entity_set_int(id,EV_INT_movetype,MOVETYPE_FLY);
#endif
grablength[id] = vector_distance(Origin, Return);
return PLUGIN_CONTINUE;
}
public server_frame()
{
new a = 1;
for(a = 1; a < 33; a++)
{
new entid, entGrabber;
new i = 1;
new Float:GrabberOrigin[3];
new Float:GrabbedOrigin[3];
new Float:NewLook[3];
new NmNewLook[3];
new Float:NewLen;
new Float:Vec[3];
if(grabbed[a] > 0)
{
entid = grabbed[a];
entGrabber = a;
}
else
{
continue;
}
if(entid < 33 && entid > 0)
{
if(!is_user_alive(entid))
{
grabbed[a] = 0;
grablength[a] = 0.0;
continue;
}
}
entity_get_vector(entid,EV_VEC_origin,GrabbedOrigin);
entity_get_vector(entGrabber,EV_VEC_origin,GrabberOrigin);
get_user_origin(entGrabber,NmNewLook,3);
IVecFVec(NmNewLook,NewLook);
NewLen = vector_distance(GrabberOrigin,NewLook);
if(NewLen == 0.0)
NewLen = 1.0;
for(i = 0; i < 3; i++)
{
Vec[i] = (NewLook[i] - GrabberOrigin[i]) * (grablength[entGrabber]/NewLen);
Vec[i] = GrabberOrigin[i] + Vec[i];
#if defined VELOCITY
Vec[i] = Vec[i] - GrabbedOrigin[i];
#endif
}
#if defined VELOCITY
entity_set_vector(entid, EV_VEC_velocity, Vec);
#else
entity_set_vector(entid, EV_VEC_origin, Vec);
#endif
}
return PLUGIN_CONTINUE;
}
public BeginEntPull(id,level,cid)
{
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;
if(grabbed[id] > 0)
if(!task_exists(rndTaskID+id))
set_task(0.1, "PullTask", rndTaskID+id, "", 1, "b")
else
client_print(id,print_console,"You are already manipluating an entity!");
else
client_print(id,print_console, "You have no entity to pull!");
return PLUGIN_HANDLED;
}
public EndEntPull(id,level,cid)
{
if(task_exists(rndTaskID+id))
remove_task(rndTaskID+id);
return PLUGIN_HANDLED;
}
public BeginEntPush(id,level,cid)
{
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;
if(grabbed[id] > 0)
if(!task_exists(rndTaskID+id))
set_task(0.1, "PushTask", rndTaskID+id, "", 1, "b")
else
client_print(id,print_console,"You are already manipulating an entity!");
else
client_print(id,print_console, "You have no entity to push!");
return PLUGIN_HANDLED;
}
public EndEntPush(id,level,cid)
{
if(task_exists(rndTaskID+id))
remove_task(rndTaskID+id);
return PLUGIN_HANDLED;
}
public PushTask(TaskID)
{
new id = TaskID - rndTaskID;
if(grabbed[id] < 1)
remove_task(TaskID);
grablength[id] += get_cvar_num("amxx_movestrength");
}
public PullTask(TaskID)
{
new id = TaskID - rndTaskID;
if(grabbed[id] < 1)
remove_task(TaskID);
grablength[id] -= get_cvar_num("amxx_movestrength");
}
public cmdUseEnt(id,level,cid)
{
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;
new Float:Origin[3];
new NmLook[3];
new Float:Look[3];
new Float:Return[3];
new entid;
entity_get_vector(id,EV_VEC_origin,Origin);
get_user_origin(id,NmLook,3);
IVecFVec(NmLook,Look);
entid = trace_line(id,Origin, Look, Return);
if(!entid)
{
client_print(id,print_console,"You are not looking at an entity");
return PLUGIN_HANDLED;
}
force_use(id,entid);
return PLUGIN_HANDLED;
}
It compiles with no errors, and gives a bad load. Good luck!
EDIT: It's also likely to be a silly error(A misspelling or something)... I'm just too lazy to grammar-check