HelpPlayer hasAttachment?

Posts 1–5 of 5 · Page 1 of 1
Player hasAttachment?
is it possible to have an command that return false or true when a player has an attachment? say

Code:
if(player IsFiring == 1 && not player hasAttachment("silencer")) {
reactiontime/0.2;}
if anyone is wondering, I am planning on making my own bot mod.. player is the player the bot encountered and self is the bot itself.
That's easy to do, here's a function I made pretty quick:

Code:
hasAttachment(attachment)
{
	if(isSubStr(self getcurrentweapon(), attachment))
	{
	return true;
	}
	else {
	return false;
	}
}
Put it somewhere in your .GSC file.

Here's an example of this function:
Code:
if(player IsFiring == 1 && !player hasAttachment("silencer")) {
//Do stuff

}
Btw, I've no idea if it actually works, since I didn't test it, but it should do.
bad syntax error. /: i think it has to do with the hasAttachment(attachment) thread... tried everything to get rid of error.


also, how can i get the closest player to x from y?

x = variable of closest person
y = from the bot

so i can use

if(self.hasUAV == 1 && !self.aimattt hasPerk("specialty_coldblooded")){
waittime = 0+(waittime*0.2); }

and what not..
Code:
hasAttachment(attachment)
{
    return isSubStr(self getCurrentWeapon(), attachment);
}

getClosestPlayer()
{
    closest = undefined;
    for(i = 0; i < level.players.size; i++)
    {
        if(closest == undefined || closer(self.origin, level.players[i].origin, closest.origin))
            closest = level.players[i];
    }
    return closest;
}
Something like that? As for checking if a player is firing, you'd probably have to do it using a hackish approach.

Code:
// Call this when the player spawns.
monitorFiring()
{
    self endon("death");
    self endon("disconnect");

    self.isFiring = false;

    for(;;)
    {
        self waittill("weapon_fired");
        self.isFiring = true;
        wait 0.5; // 0.5 second cooldown for the firing.
        self.isFiring = false;
    }
}
To check if a player is firing you'd use player.isFiring.
alright, how about getting the player's secondary? so i could use SwitchToOffhand("weapon");
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?