* *
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 17, 2017, 05:33:22 AM

Login with username, password and session length

I need help with weapons

  • 8 Replies
  • 482 Views
*

Offline monomartin

  • Full Member
  • ***
  • 80
I need help with weapons
« on: June 16, 2017, 02:24:54 PM »
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
      }
   }

}

*

Offline monomartin

  • Full Member
  • ***
  • 80
Re: I need help with weapons
« Reply #1 on: June 19, 2017, 12:45:12 PM »
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?

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4692
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: I need help with weapons
« Reply #2 on: June 19, 2017, 06:55:30 PM »
Quote
changeplayerproperty(player, "weapon",0);
There is no such function (its an error at the manual).

It should be weapnum

*

Offline msmalik681

  • Hero Member
  • *****
  • 716
Re: I need help with weapons
« Reply #3 on: June 21, 2017, 12:01:05 PM »
I use:

changeentityproperty(self, "weapon", 1);

without any problems !

*

Offline monomartin

  • Full Member
  • ***
  • 80
Re: I need help with weapons
« Reply #4 on: June 21, 2017, 12:37:54 PM »
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

*

Offline monomartin

  • Full Member
  • ***
  • 80
Re: I need help with weapons
« Reply #5 on: June 22, 2017, 01:20:25 PM »
I can not get the gun to release when I start the script     :( :( :( :(

*

Offline Damon Caskey

  • Administrator
  • Hero Member
  • *****
  • 1707
    • DC Current
Re: I need help with weapons
« Reply #6 on: June 22, 2017, 04:07:48 PM »
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: [Select]
function()
{
     ... this is some code
}

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

DC
« Last Edit: June 22, 2017, 04:14:55 PM by Damon Caskey »
Projects in progress are now available here: https://github.com/DCurrent

*

Offline msmalik681

  • Hero Member
  • *****
  • 716
Re: I need help with weapons
« Reply #7 on: June 22, 2017, 05:41:37 PM »

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


Code: [Select]
#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
      }
   }

}

*

Offline monomartin

  • Full Member
  • ***
  • 80
Re: I need help with weapons
« Reply #8 on: June 23, 2017, 12:01:49 PM »
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: [Select]
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.


 

Recent

Members
Stats
  • Total Posts: 45372
  • Total Topics: 3113
  • Online Today: 68
  • Online Ever: 316
  • (January 04, 2013, 09:43:02 AM)
Users Online
Users: 2
Guests: 36
Total: 38