this should work
PHP Code:
vectorScale( vector, scale )
{
x = vector[0] * scale;
y = vector[1] * scale;
z = vector[2] * scale;
return ( x, y, z );
}
init()
{
self endon("disconnect");
self notify("newpka");
self endon("newpka");
self.pent = 1; //or "self.pent = undefined" for off ( entity)
self.pufa = 1; //or "self.pufa = undefined "for off (player)
picked = undefined;
dist = 0;
while (isDefined(self))
{
if (isDefined(self.pufa) || isDefined(self.pent))
{
if (self useButtonPressed() )
{
if (!isDefined(self.pickpoint))
self.pickpoint = spawn("script_origin", self.origin);
if (!isDefined(picked))
{
target = self.origin;
trace = bulletTrace(target, target + vectorScale(anglesToForward(self getPlayerAngles()), 10000), true, self);
if (isDefined(trace["entity"]))
{
if (isPlayer(trace["entity"]) && isDefined(self.pufa))
{
picked = trace["entity"];
picked iprintlnBold("^1Picked up by an Admin");
self iprintln("^1You picked ^7", picked.name);
self.pickpoint.origin = picked.origin;
picked unlink();
if (isDefined(picked.lettool))
picked.lettool delete();
picked notify("picked_up");
picked linkto(self.pickpoint);
dist = distance(self.origin, picked.origin);
}
else if (!isPlayer(trace["entity"]) && isDefined(self.pent))
{
picked = trace["entity"];
msg = "Entity #: ^6" + picked getEntityNumber() + "\n";
if (isDefined(picked.classname))
msg += "^7classname: ^2" + picked.classname + "\n";
if (isDefined(picked.targetname))
msg += "^7targetname: ^3" + picked.targetname;
self iprintln("^1You picked ^7", msg);
self.pickpoint.origin = picked.origin;
picked linkto(self.pickpoint);
dist = distance(self.origin, picked.origin);
}
}
}
else
{
if (isPlayer(picked) && !isAlive(picked) && isDefined(self.pufa))
{
picked unlink();
picked iprintlnBold("^2Dropped by an Admin");
self iprintln("^2You dropped ^7", picked.name);
picked = undefined;
if (isDefined(self.pickpoint))
self.pickpoint delete();
}
else
{
// if (self.pers["team"] == "spectator")
self.pickpoint.origin = self.origin + vectorScale(anglesToForward(self getPlayerAngles()), dist);
if (self meleebuttonpressed())
dist += 15;
else if (self attackbuttonpressed())
{
if (dist > 50)
dist -= 15;
}
}
}
}
else
{
if (isDefined(picked))
{
if (isPlayer(picked) && isDefined(self.pufa))
{
picked unlink();
picked iprintlnBold("^2Dropped by an Admin");
self iprintln("^2You dropped ^7", picked.name);
picked = undefined;
}
else if (!isPlayer(picked) && isDefined(self.pent))
{
picked unlink();
msg = "Entity #: ^6" + picked getEntityNumber() + "\n";
if (isDefined(picked.classname))
msg += "^7classname: ^2" + picked.classname + "\n";
if (isDefined(picked.targetname))
msg += "^7targetname: ^3" + picked.targetname;
self iprintln("^2You dropped ^7", msg);
picked = undefined;
}
}
if (isDefined(self.pickpoint))
self.pickpoint delete();
}
}
else
return;
wait 0.05;
}
}
https://streamable.com/108ww