Custom weapon, problem.
#1

Hello !

I have a custom weapon.
  • When I have a custom gun at me, so I have the custom object and the basic weapon.
  • When I "switch" weapon, the basic weapon disappears, but the object remains attached.
  • I use a variable to store the id of the gun I own. Weaps[playerid][slot][Model]
How when I switch my weapon, the object is switched too? And when I "reswitch" a weapon, the object attached to it?

Thanks !
Reply
#2

UP, please.
Reply
#3

There's an example for detecting that in the OnPlayerUpdate wiki page:
https://sampwiki.blast.hk/wiki/OnPlayerUpdate

And an include:
https://sampforum.blast.hk/showthread.php?tid=59771
Reply
#4

The link of include (version 2) is dead...
At the same time it dates from 2008.
Reply
#5

UP, please.
Reply
#6

What about the OnPlayerUpdate example?
Reply
#7

pawn Код:
public OnPlayerUpdate(playerid)
{
    new iCurWeap = GetPlayerWeapon(playerid); // Return the player's current weapon    
    if(iCurWeap != GetPVarInt(playerid, "iCurrentWeapon")) // If he changed weapons since the last update
    {
        // Lets call a callback named OnPlayerChangeWeapon
        OnPlayerChangeWeapon(playerid, GetPVarInt(playerid, "iCurrentWeapon"), iCurWeap);
        SetPVarInt(playerid, "iCurrentWeapon", iCurWeap);//Update the weapon variable
    }
    return 1; // Send this update to other players.
}
 
stock OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
    new     s[128],
        oWeapon[24],
        nWeapon[24];
 
    GetWeaponName(oldweapon, oWeapon, sizeof(oWeapon));
    GetWeaponName(newweapon, nWeapon, sizeof(nWeapon));
 
    format(s, sizeof(s), "You changed weapon from %s to %s!", oWeapon, nWeapon);
 
    SendClientMessage(playerid, 0xFFFFFFFF, s);
}
I have a variable that can store the weapon in my hand, and its number of ammos.

How to change the value of the variable when I switch my weapon etc?
Reply
#8

You must check when the player switches of weapon.

Then, when he does, simply remove the weapon attached to this slot and attah the weapon attached to the new one.

As easy as it.
Reply
#9

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
You must check when the player switches of weapon.

Then, when he does, simply remove the weapon attached to this slot and attah the weapon attached to the new one.

As easy as it.
I know, but transcribe in pawn ...
Reply
#10

Remove it in OnPlayerChangeWeapon with that script.
We can't help about removing it, as we don't know how your code works.

And @ProBrad, go away with your spam, do you think anybody cares about moderator in your server...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)