Create multiple weapons on one M4? -
Inuro - 02.12.2014
Good evening community samp,
I'm French and I do not speak much English.
I would like to create multiple weapon M4,
exemple:
(Weapon name, damage)
AN-94, 44
CAR 15, 32
Steyr AUG, 38
And all his on a single M4
And then how to retrieve the name of the weapon and display in a textdraw, damage too ?
Re: Create multiple weapons on one M4? -
Kyance - 02.12.2014
pawn Код:
stock WeaponName(weaponid)
{
new weapname[30];
GetWeaponName(weaponid, weapname, sizeof(weapname));
return weapname;
}
(I used "weaponid" because I use it on 'OnPlayerTakeDamage').
Anyways, for the AN, CAR, AUG, you can use variables to detect it, like;
pawn Код:
#define M4_DEFAULT 0
#define M4_AN94 1
#define M4_CAR15 2
#define M4_STEYRAUG 3
new M4Mode[ MAX_PLAYERS ] = M4_DEFAULT;
Then, just set it, and do checks at OnPlayerTakeDamage.
But, don't you think 44 is a bit too much?
Re : Create multiple weapons on one M4? -
Inuro - 02.12.2014
(44 had a value, for example, not final)
I did not understand the whole script, can you explain in detail?
new M4Mode[ MAX_PLAYERS ] = M4_DEFAULT; ?
How to know if Weaponname takes the name of weapons defined?
Re: Re : Create multiple weapons on one M4? -
Kyance - 02.12.2014
Quote:
Originally Posted by Inuro
(44 had a value, for example, not final)
I did not understand the whole script, can you explain in detail?
new M4Mode[ MAX_PLAYERS ] = M4_DEFAULT; ?
How to know if Weaponname takes the name of weapons defined?
|
M4Mode is the variable for the "M4 weapon type" -> Either the default one(GTA SA M4(0)), or your ones(AN94(1), CAR15(2) or Steyr Aug(3))
Ah, it doesn't.
You can try this though..
pawn Код:
//vvv defining the 'm4 modes'
#define M4_DEFAULT 0
#define M4_AN94 1
#define M4_CAR15 2
#define M4_STEYRAUG 3
new M4Mode[ MAX_PLAYERS ] = M4_DEFAULT; //variable which allows you to change the m4 mode for player
stock WeaponName(playerid) //get the weapon name
{
new weapname[30], weaponid = GetPlayerWeapon(playerid);
if(weaponid == WEAPON_M4) //if the weapon is m4(0.3z required)
{
switch(M4Mode[ playerid ]) //checks(switch, faster than 'if', 'else if'...)
{
case M4_DEFAULT: weapname = "M4"; //if its the default one, the name is M4
case M4_AN94: weapname = "AN-94"; //if its AN-94, the name is AN94
case M4_CAR15: weapname = "CAR-15"; //^^^^^^^^
case M4_STEYRAUG: weapname = "Steyr Aug"; //^^^^^^^^
}
}
else GetWeaponName(weaponid, weapname, sizeof(weapname)); //If the weapon isn't m4, we let SAMP get the name
return weapname; //return the weapon name
}
EDIT: You should reset the M4Mode when a player disconnects -- Set it to;
M4Mode[ playerid ] = M4_DEFAULT;
Re : Create multiple weapons on one M4? -
Inuro - 02.12.2014
And to give the weapon a player, I use this
pawn Код:
GivePlayerWeapon(playerid, M4_AN94, 500)
Or it is something else?
And to identify the damage
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(M4_AN94 == 1) SetPlayerHealth(playerid, HP-44);
return 1;
}
EDIT: And when it connect? To give him the gun?
Re: Re : Create multiple weapons on one M4? -
Kyance - 02.12.2014
Quote:
Originally Posted by Inuro
And to give the weapon a player, I use this
pawn Код:
GivePlayerWeapon(playerid, M4_AN94, 500)
Or it is something else?
And to identify the damage
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) { new Float:HP; GetPlayerHealth(playerid, HP); if(M4_AN94 == 1) SetPlayerHealth(playerid, HP-44); return 1; }
|
No, just give the M4, but set the M4Mode to 'M4_AN94', example:
pawn Код:
GivePlayerWeapon(playerid, WEAPON_M4, 500);
M4Mode[ playerid ] = M4_AN94;
About the Damage part, do the "switch-checks" again;
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(weaponid == WEAPON_M4) //if the weapon was M4
{
switch(M4Mode[ issuerid ]) //switch-checks for the m4 mode
{
case M4_AN94: SetPlayerHealth(playerid, HP-44); //if its an-94, take 44dmg
case M4_CAR15: SetPlayerHealth(playerid, HP-32); //if its car-15, take 32dmg
case M4_STEYRAUG: SetPlayerHealth(playerid, HP-38); //if its steyr-aug, take 38dmg
}
}
return 1;
}
Re : Create multiple weapons on one M4? -
Inuro - 02.12.2014
And to safeguard if the player M4 ID 1 or 2?
Re: Re : Create multiple weapons on one M4? -
Kyance - 02.12.2014
Quote:
Originally Posted by Inuro
And to safeguard if the player M4 ID 1 or 2?
|
What do you mean by 'safeguard'? o.o
Re : Create multiple weapons on one M4? -
Inuro - 02.12.2014
sauvegarde, sorry im not english ^^
Re: Re : Create multiple weapons on one M4? -
Kyance - 02.12.2014
Quote:
Originally Posted by Inuro
sauvegarde, sorry im not english ^^
|
No problem, your english is good!
But, I still don't understand what sauvegarde/safeguard is.. Is it like, saving stats or..? (could you explain?)