Pick the gun not showing the wep need help
#1

When im going to drop the gun (unli ammu) and im going to pick up the gun not showing after picking up it. -.-


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/dropgun", true) == 0
	|| strcmp(cmdtext, "/dgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new GunID = GetPlayerWeapon(playerid);
        new GunAmmo = GetPlayerAmmo(playerid);
        if(GunID > 0 && GunAmmo != 0)
        {
            new f = MAX_OBJ+1;
            for(new a = 0; a < MAX_OBJ; a++)
            {
                if(dGunData[a][ObjPos][0] == 0.0)
                {
                    f = a;
                    break;
                }
            }
            if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!!");
			RemovePlayerWeapon(playerid, GunID);
			dGunData[f][ObjData][0] = GunID;
			dGunData[f][ObjData][1] = GunAmmo;
            GetPlayerPos(playerid, dGunData[f][ObjPos][0], dGunData[f][ObjPos][1], dGunData[f][ObjPos][2]);
            dGunData[f][ObjID] = CreateObject(GunObjects[GunID], 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 threw %s", GunNames[dGunData[f][ObjData][0]]);
			SendClientMessage(playerid, 0x33AA3300, buffer);
        }
        return 1;
    }
    if(strcmp(cmdtext, "/pickupgun", true) == 0
	|| strcmp(cmdtext, "/pgun", true) == 0)
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
        new f = MAX_OBJ+1;
		for(new a = 0; a < MAX_OBJ; a++)
		{
		    if(IsPlayerInRangeOfPoint(playerid, 5.0, dGunData[a][ObjPos][0], dGunData[a][ObjPos][1], dGunData[a][ObjPos][2]))
		    {
		        f = a;
		        break;
		    }
		}
		if(f > MAX_OBJ) return SendClientMessage(playerid, 0x33AA3300, "You are not near the weapon which you can pick up!");
		DestroyObject(dGunData[f][ObjID]);
		GivePlayerWeapon(playerid, dGunData[f][ObjData][0], dGunData[f][ObjData][1]);
		dGunData[f][ObjPos][0] = 0.0;
		dGunData[f][ObjPos][1] = 0.0;
		dGunData[f][ObjPos][2] = 0.0;
		dGunData[f][ObjID] = -1;
		//dGunData[f][ObjData][0] = 0;
		dGunData[f][ObjData][1] = 0;
		new buffer[50];
		format(buffer, sizeof(buffer), "You picked up %s", GunNames[dGunData[f][ObjData][0]]);
  		SendClientMessage(playerid, 0x33AA3300, buffer);
  		return 1;
    }
	return 0;
}
// -----------------------------------------------------------------------------
stock RemovePlayerWeapon(playerid, weaponid)
{ // Not mine :3
	new plyWeapons[12] = 0;
	new plyAmmo[12] = 0;
	for(new sslot = 0; sslot != 12; sslot++)
	{
		new wep, ammo;
		GetPlayerWeaponData(playerid, sslot, wep, ammo);
		if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
	}
	ResetPlayerWeapons(playerid);
	for(new sslot = 0; sslot != 12; sslot++) if(plyAmmo[sslot] != 0) GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
	return 1;
}
stock split(const strsrc[], strdest[][], delimiter)
{ // Not mine :3
	new i, li;
	new aNum;
	new len;
	while(i <= strlen(strsrc))
	{
	    if(strsrc[i]==delimiter || i==strlen(strsrc))
		{
	        len = strmid(strdest[aNum], strsrc, li, i, 128);
	        strdest[aNum][len] = 0;
	        li = i+1;
	        aNum++;
		}
		i++;
	}
	return 1;
}
Need help
Reply


Messages In This Thread
Pick the gun not showing the wep need help - by ToiletDuck - 26.04.2012, 12:03
Re: Pick the gun not showing the wep need help - by DarkB0y - 26.04.2012, 12:29

Forum Jump:


Users browsing this thread: 1 Guest(s)