SA-MP Forums Archive
(BUG SCRIPT) Weapons duplication - Unsync player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: (BUG SCRIPT) Weapons duplication - Unsync player (/showthread.php?tid=608382)



(BUG SCRIPT) Weapons duplication - Unsync player - Raiden57 - 31.05.2016

Hello, before to strat I just want to say : I'm not english so sorry if my english is not perfect.

I have a little problem on my server SA:MP. I have a script to drop a weapon, but when a player is Unsync (with the server), he can drop weapon to infinity (the unsync player keep the weapon in his hand but the weapon is dropped too ).

So, I want to make a security, if the player is unsync, and he drop his weapon AND he keep the weapon in this hand, i want to delete the weapon (in this hand OR on the floor)

This is my code


Код:
if(strcmp(subcmd, "weapon", true) == 0)
        {
            if(GetPlayerWeapon(playerid) == 0)
                {SendClientMessage(playerid, COLOR_PINK, "[Info] You want to have your weapon in your hand."); return 1;}
            if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pMember] == 20)
            {
                 if(OnDuty[playerid]){SendClientMessage(playerid, COLOR_PINK, "[Info]You can't do that now."); return 1;}
            }
 
            new indice = -1;
            new wepId = GetPlayerWeapon(playerid);
            new ammo = GetPlayerAmmo(playerid);
            
            print("Lancement Boucle 57");
            for(i=0; i<drop_weapondsDropableCount; i++)
            {
                if(wepId ==drop_weapondsDropableId[i])
                    {indice = i; break;}
            }
            print("Fin Boucle 57");
 
            if(indice >= 0)
            {
                new f = MAX_GUNDROP+1;
                for(new a = 0; a < MAX_GUNDROP; a++)
                {
                    if(dGunData[a][ObjPos][0] ==0.0)
                    {
                        f = a;
                        break;
                    }
                }
                
                if(f > MAX_GUNDROP) returnSendClientMessage(playerid, -1, "You can't do that now.");
                RemovePlayerWeapon(playerid, wepId);
                dGunData[f][ObjData][0] = wepId;
                dGunData[f][ObjData][1] = ammo;
                GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
                dGunData[f][ObjID] =CreateObject(GunObjects[wepId], dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]-1, 93.7, 120.0, 120.0);
                new buffer[50];
                format(buffer, sizeof(buffer), "you dropped your %s on the floor.", GunNames[dGunData[f][ObjData][0]]);
                SendClientMessage(playerid, -1, buffer);
                format(proxy_msg, sizeof(proxy_msg), "%s drop a weapon on the floor.", playername);
                proxy_teteMsg(playerid, proxy_msg);
            }
            else
                {SendClientMessage(playerid, COLOR_PINK, "[Info] Impossible now."); return 1;}
            return 1;
        }
    }



Re: (BUG SCRIPT) Weapons duplication - Unsync player - TwinkiDaBoss - 31.05.2016

Keep the track of weapons on player and store that inside a variable.
https://sampwiki.blast.hk/wiki/GetPlayerWeaponData


Re: (BUG SCRIPT) Weapons duplication - Unsync player - Raiden57 - 31.05.2016

Hi, thanks TwinkiDaBoss !

But, Have u an example please ? I don't really see how to start the track