Custom weapon.
#1

Hello.

I want to introduce custom weapons in my gamemode .

The trouble is that I do not know how.

I had the idea of ​​making an array to store the names of weapons and so on, but how to recover afterwards?

Since it will not be "Desert Eagle" for example, but another ..

++
Reply
#2

Exactly I do not see how.
Reply
#3

Make arrays of strings, set weapon names in them, use a saving system (whether file or SQL system) to save your variables and load them with the said system.
Reply
#4

I have a table that contains the name of each of my current weapons .

If I use the custom , the name of the basics of weapons will be replaced ... But then I do not see how

pawn Code:
enum weap_params {MAXAMMO, NAME[20]};
static WeaponInfo[][weap_params] ={
};
{0,     0,      0,      "Poing"},
{1,     20,     0,      "Poing Americain"},
{1,     0,      0,      "Club"}
// ...
};
Reply
#5

UP, please.
Reply
#6

UP, please.
Reply
#7

Check out SIF include by Southclaw, and his S&S open source gamemode.
Reply
#8

https://github.com/Southclaw/SIF

It's not for a custom weapon...
Reply
#9

I said check out his SIF / S&S gamemode, he has a system to make custom weapons, with custom bullets, so you might wanna throw an eye on that and check out how he did it.
Reply
#10

Thanks to the custom , I intended to add several weapons : several desert eagle, several AK-47 etc.

What to do? And give a name to each weapon , with your method?
Reply
#11

Can you help me please?
Reply
#12

Код:
enum E_WEAPON_DATA
{
        // add this little line and you tadaaa you have a custom name!
       wep_CustomName[16], // max name , 8 seems enough aswell.
        wep_BaseWeapon,
Float:  wep_Damage
}
Код:
DefineCustomWeapon(weaponName[], baseweapon, Float:damage)
{
    format(wep_Data[wep_Total][wep_CustomName], 16 or 8 read above, "%s", weaponName);
    wep_Data[wep_Total][wep_BaseWeapon] = baseweapon;
    wep_Data[wep_Total][wep_Damage] = damage;

    return wep_Total;
}

( in the gamemode init : )
DefineCustomWeapon("AK-65" ,30, 20.0); // Some fancy name ( keep it below 16 chars ) or put 32 if you have some loooong name. :3
DefineCustomWeapon("AK-11" ,30, 30.0);
DefineCustomWeapon("AK-xOne" ,30, 100.0); // 100 damage means oneshot
Код:
stock GivePlayerCustomWeapon(playerid, weapontype, ammo)
{
    if(!(0 <= weapontype < wep_Total))
        return 0;

    GivePlayerWeapon(playerid, wep_Data[weapontype][wep_BaseWeapon], ammo);
    new str[128];
    format(str, 128, "You just received a sexy %s", wep_Data[weapontype][wep_CustomName]);
    SendClientMessage(playerid, -1, str);
    return 1;
}
Not tested, hopefully it works. Also, Big thanks to Southclaw, this actually helped me too :3
Reply
#13

wep_Total already value 0.

If i add wep_Total++ in DefineCustomWeapon the value is 1, 2, 3... How to start at 0 with return wep_Total; ?
Reply
#14

it's actually return wep_Total++; ( I think )
A couple ideas you might wanna add, this is similar on S&S Project with textdraws, but to avoid complex things just to start out with, add a pool of ammo that custom weapons can have.
Like for the Ak-xOne must be like 15/x instead of 30/x ; the way you can do that is implement textdraws or automatically reload the gun when the ammo is below that amount. No idea if that's possible but if you find some way on the forums, PM me or write a post here

Edit : ye thats it, southclaw forgot to add the plus plus I guess :3


Код:
DefineCustomWeapon(weaponName[], baseweapon, Float:damage)
{
    format(wep_Data[wep_Total][wep_CustomName], 16 or 8 read above, "%s", weaponName);
    wep_Data[wep_Total][wep_BaseWeapon] = baseweapon;
    wep_Data[wep_Total][wep_Damage] = damage;

    return wep_Total++;
}
Reply
#15

I wondered especially :

When the player switch the weapon, the object is still attached ...
Reply
#16

if you follow the code Southclaw wrote you, what it does is, it gives a normal ak ( same id ) , just with a different name, different damage. so you can have multiple AK's, same ids, just different params. what you basically do is just give a normal ak so you won't worry about object attached because you don't even attach it in the first place.

The way Southclaw did it in S&S project, is you can only hold one weapon at a time, you can have more weapons but they are in the inventory and one slot for holstering.
You can know when the player switches the weapon through OnPlayerUpdate and save 2 vars, new weapon, last weapon, if they are different delete last object, attach the new object.
Reply
#17

How to detect if a player switch weapon?
Reply
#18

up, please
Reply
#19

Quote:
Originally Posted by Baltimore
Посмотреть сообщение
How to detect if a player switch weapon?
https://sampwiki.blast.hk/wiki/GetPlayerWeapon
https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
Reply
#20

I have 9 weapons custom.

If i make:

pawn Код:
for(new w; w < sizeof(wep_Data); w++)
{
    printf("w = %d", w);
}
In my logs:

[20:51:41] w: 9
[20:51:41] w: 10
[20:51:41] w: 11
[20:51:41] w: 12
[20:51:41] w: 13
[20:51:41] w: 14
[20:51:41] w: 15
[20:51:41] w: 16
[20:51:41] w: 17
[20:51:41] w: 18
[20:51:41] w: 19
[20:51:41] w: 20
[20:51:41] w: 21
[20:51:41] w: 22
[20:51:41] w: 23
[20:51:41] w: 24
[20:51:41] w: 25
[20:51:41] w: 26
[20:51:41] w: 27
[20:51:41] w: 28
[20:51:41] w: 29
[20:51:41] w: 30
[20:51:41] w: 31
[20:51:41] w: 32
[20:51:41] w: 33
[20:51:41] w: 34
[20:51:41] w: 35
[20:51:41] w: 36
[20:51:41] w: 37
[20:51:41] w: 38

Why?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)