I need help with weapons

monomartin

Active member
hi, I need help
I want to add a line for the player to release the weapon in case he has one, to release it when he is walking, I add one but it does not work, he does not release the weapon

#import "data/scripts/area1/automvSP.c"

void main() {
  void self = getlocalvar("self");

float x = getentityvar(self, 5); //move x
float z = getentityvar(self, 6); //move z
float d = getentityvar(self, 7); //face left right
float p = getentityvar(self, 8); //player nº 0 1 2



  void player = getplayerproperty(p,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) {
      changeplayerproperty(player, "weapon",0); /// <-------------------<
if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,d,0.5) ) {
        if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",1);
        //drawstring(110,110,0,"wait");
        killentity(self); // to finish the script
      }
  }

}
 
monomartin said:
hi, I need help
I want to add a line for the player to release the weapon in case he has one, to release it when he is walking, I add one but it does not work, he does not release the weapon

#import "data/scripts/area1/automvSP.c"

void main() {
  void self = getlocalvar("self");

float x = getentityvar(self, 5); //move x
float z = getentityvar(self, 6); //move z
float d = getentityvar(self, 7); //face left right
float p = getentityvar(self, 8); //player nº 0 1 2



  void player = getplayerproperty(p,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) {
      changeplayerproperty(player, "weapon",0); /// <-------------------<
if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,d,0.5) ) {
        if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",1);
        //drawstring(110,110,0,"wait");
        killentity(self); // to finish the script
      }
  }

}

You understand what i'm asking ?    se entiende lo que pregunto?
 
msmalik681 said:
I use:

changeentityproperty(self, "weapon", 1);

without any problems !

The idea is that, when the script is executed, if the player has a gun release it. Drop your weapon. Sorry my english is not good, I only speak spanish
 
monomartin,

We need more details. Please provide the entity file and the script. Also, when you post a script or text file, please enclose it in code tags, like this:

Code:
function()
{
     ... this is some code
}

It will help us read and understand what's going on. :)

DC
 
or just try this code with the weapon change the way I suggested !


Code:
#import "data/scripts/area1/automvSP.c"

void main() {
   void self = getlocalvar("self");

float x = getentityvar(self, 5); //move x
float z = getentityvar(self, 6); //move z
float d = getentityvar(self, 7); //face left right
float p = getentityvar(self, 8);//player nº 0 1 2 



   void player = getplayerproperty(p,"entity"); // retrieve player 1 handler

   if ( getentityproperty(player,"exists") ) {
      changeentityproperty(self, "weapon", 0); /// *fixed*
   if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,d,0.5) ) {
         if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",1);
         //drawstring(110,110,0,"wait");
         killentity(self); // to finish the script
      }
   }

}
 
Hello friends, first thanks for the help, I am using the following script. For the player to walk automatically. What I want is for you to release the weapon when you start walking. I do it when I finish walking, forcing the player to end up in a "follow" animation using weaponframe 0 0. The idea is, when the script starts to force the weapon to release, the msmalik681 suggestion does not work.

Code:
float abs(float num) {
    if (num < 0) num *= -1;

    return num;
}



int movetoxz(void player, float dir_x, float dir_z, int final_direction) {
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");
    float a = getentityproperty(player, "y");
    float base = getentityproperty(player, "base");
    float threshold = 0.99; // precisione
    float speed = getentityproperty(player,"speed");
    float speed_x, speed_z;

    if ( getentityproperty(player, "animationid") != openborconstant("ANI_SPAWN") && getentityproperty(player, "animationid") != openborconstant("ANI_RESPAWN") ) {
        if ( a != base ) changeentityproperty(player, "position", x, z, base);

        if ( x > dir_x-threshold && x < dir_x+threshold  ) {
            speed_x = 0;
        } else if ( x < dir_x+threshold ) { // pg deve andare a destra
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_walk") ) changeentityproperty(player, "animation", openborconstant("ANI_walk"));
            changeentityproperty(player, "direction", 1);
            speed_x = speed;
           
	if ( (dir_x-x) <= threshold ) speed_x = (dir_x-x)*(2/3); // Impostiamo la velocità proprio uguale alla distanza che manca
        } else if ( x > dir_x-threshold ) { // pg deve andare a sinistra
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_walk") ) changeentityproperty(player, "animation", openborconstant("ANI_walk"));
            changeentityproperty(player, "direction", 0);
            speed_x = -1*speed;
            if ( (x-dir_x) <= threshold ) speed_x = -1*(x-dir_x)*(2/3);
        }

        // Diamo la priorità all'animazione UP/DOWN
        if ( z > dir_z-threshold && z < dir_z+threshold  ) {
            speed_z = 0;
        } else if ( z < dir_z+threshold ) { // pg deve andare giù
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_DOWN") ) changeentityproperty(player, "animation", openborconstant("ANI_DOWN"));
            speed_z = speed/2;
            if ( (dir_z-z) <= threshold ) speed_z = (dir_z-z)*(2/3);
        } else if ( z > dir_z-threshold ) { // pg deve andare su
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_UP") ) changeentityproperty(player, "animation", openborconstant("ANI_UP"));
            speed_z = -1*(speed/2);
            if ( (z-dir_z) <= threshold ) speed_z = -1*(z-dir_z)*(2/3);
        }

        if ( speed_x == 0 && speed_z == 0 ) {
            changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_IDLE") ) changeentityproperty(player, "animation", openborconstant("ANI_follow75"));


changeentityproperty(player, "direction", final_direction);
		
     
        
           
	return 1;
        
	}

        changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
   
} // fine if spawn

      
 
return 0;
}

#import "data/scripts/area1/automvSP.c"

void main() {
  void self = getlocalvar("self");

float x = getentityvar(self, 5); //move x
float z = getentityvar(self, 6); //move z
float d = getentityvar(self, 7); //face left right
float p = getentityvar(self, 8); //player nº 0 1 2



  void player = getplayerproperty(p,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) {
     

changeentityproperty(self, "weapon", 0);
if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,d,0.5) ) {
        if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",1);
        //drawstring(110,110,0,"wait");
        killentity(self); // to finish the script
      }
  }

}

[/quote]
I leave a video, in the view when you start walking with automov and endlevel_anim. That's when I need you to release the weapon.

https://www.youtube.com/watch?v=94R5zxQF52E
 
Back
Top Bottom