/dropgun problem
#1

Код:
command(dropgun, playerid, params[])
{
    new GunID = GetPlayerWeapon(playerid);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    RemovePlayerWeapon(playerid, GunID);
    RemovePickups(playerid);
	new Float:x, Float:y, Float:z, dropped;
	GetPlayerPos(playerid,x,y,z);
	for(new i=0; i<13; i++)
	{
	    new weapon, ammo;
	    GetPlayerWeaponData(playerid, i, weapon, ammo);
	    if((ammo > 0 || weapon == 1) && weapon != 0)
	    {
			new model = GetModel(weapon);
			if(model != -1)
			{
	        	WeaponData[playerid][i][0] = weapon;
	        	WeaponData[playerid][i][1] = ammo;
	        	dropped++;
			}
	    }
	}
So. I've got a filterscript that drops my weapons when I die. However, I'm creating a command /dropgun so I could drop my gun on the ground like on player death but it seems to drop all of my guns on the ground when I type /dropgun. However it only removes my gun that were in use and spawns objects from all of my guns. Any idea?

Thanks
Reply
#2

LoL i didn't get anything what are you trying to say like what do you want explain a bit more
Reply
#3

What script you use for weapons drop ?
Reply
#4

Quote:
Originally Posted by aslan890
Посмотреть сообщение
LoL i didn't get anything what are you trying to say like what do you want explain a bit more
I edited the explanation, read it again.

Quote:
Originally Posted by [HRD]Mar1
Посмотреть сообщение
What script you use for weapons drop ?
I'm using this one https://sampforum.blast.hk/showthread.php?tid=252128&page=4
Reply
#5

pawn Код:
COMMAND:drop(playerid, params[]) {
    OnWeaponDrop(playerid);
    ResetPlayerWeapons(playerid);
    return 1;
}
Reply
#6

Quote:
Originally Posted by [HRD]Mar1
Посмотреть сообщение
pawn Код:
COMMAND:drop(playerid, params[]) {
    OnWeaponDrop(playerid);
    ResetPlayerWeapons(playerid);
    return 1;
}
Well, I'm trying to make it like when I type /dropgun it'd remove my weapon + spawn an object on the ground which are pickupable. This happens when I use my script to /dropgun. It spawns objects on the ground of all my weapons but only removes one. I'm trying to create it like when you use /dropgun it removes your gun and ONLY spawns one object on the ground. http://i.imgur.com/qsTr3.png
Reply
#7

Quote:
Originally Posted by Bobman
Посмотреть сообщение
Well, I'm trying to make it like when I type /dropgun it'd remove my weapon + spawn an object on the ground which are pickupable. This happens when I use my script to /dropgun. It spawns objects on the ground of all my weapons but only removes one. I'm trying to create it like when you use /dropgun it removes your gun and ONLY spawns one object on the ground. http://i.imgur.com/qsTr3.png
What do you mean sir ? you want to send weapons to another player
Reply
#8

Quote:
Originally Posted by Bobman
Посмотреть сообщение
Well, I'm trying to make it like when I type /dropgun it'd remove my weapon + spawn an object on the ground which are pickupable. This happens when I use my script to /dropgun. It spawns objects on the ground of all my weapons but only removes one. I'm trying to create it like when you use /dropgun it removes your gun and ONLY spawns one object on the ground. http://i.imgur.com/qsTr3.png
On the weapon drop command you are defining it to drop all the guns
pawn Код:
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]); the i is the slot for example. slot 2 is for pistols.
I would do it like this.

pawn Код:
command(dropgun, playerid, params[])
{
    new GunID = GetPlayerWeapon(playerid);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    RemovePlayerWeapon(playerid, GunID);
    RemovePickups(playerid);
    new Float:x, Float:y, Float:z, dropped;
    GetPlayerPos(playerid,x,y,z);
    for(new i=0; i<13; i++)
    {
        new weapon, ammo;
        weapon = GetPlayerWeapon(playerid);
                 ammo = GetPlayerAmmo(playerid);
        if((ammo > 0 || weapon == 1) && weapon != 0)
        {
            new model = GetModel(weapon);
            if(model != -1)
            {
                WeaponData[playerid][i][0] = weapon;
                WeaponData[playerid][i][1] = ammo;
                dropped++;
            }
        }
    }
Reply
#9

Quote:
Originally Posted by [HRD]Mar1
Посмотреть сообщение
What do you mean sir ? you want to send weapons to another player
Alright, it's very hard to explain but i'm trying my best here. So, I've got a filterscript that drops my weapons on death and it spawns weapon objects on the ground that are pickupable of my weapons. However I'm trying to create a command here so I could drop only one gun that spawns the object model on the ground (which are pickupable). I'm using the same script as onplayerdeath and I'm trying to convert it to a command that I could drop only one gun if I want to. But the problem is that when I type /dropgun it REMOVES one of my guns like it should be BUT it spawns pickupable object models on the ground of ALL my weapons and it won't remove all of my weapons, only one. So, I'm trying to make it like when I type /dropgun it removes only one of my guns and spawns it on the ground, not all of them.


Код:
command(dropgun, playerid, params[])
{
    new GunID = GetPlayerWeapon(playerid);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    RemovePlayerWeapon(playerid, GunID);
    RemovePickups(playerid);
	new Float:x, Float:y, Float:z, dropped;
	GetPlayerPos(playerid,x,y,z);
	for(new i=0; i<13; i++)
	{
	    new weapon, ammo;
	    GetPlayerWeaponData(playerid, i, weapon, ammo);
	    if((ammo > 0 || weapon == 1) && weapon != 0)
	    {
			new model = GetModel(weapon);
			if(model != -1)
			{
	        	WeaponData[playerid][i][0] = weapon;
	        	WeaponData[playerid][i][1] = ammo;
	        	OnWeaponDrop(playerid);
			}
	    }
	}
	if(dropped > 0)
	{
	    new radius;
	    if(dropped < 3) radius = 1;
		if(dropped < 6) radius = 2;             /*If you want another radius, change it here.*/
		if(dropped < 9) radius = 3;
		if(dropped > 8) radius = 4;
		new Float:degree, Float:tmp;
		degree = 360.0 / (float(dropped));
		tmp = degree;
		if(WeaponTimer[playerid] != -1) KillTimer(WeaponTimer[playerid]);
		WeaponTimer[playerid] = SetTimerEx("RemovePickups", WEAPON_RESPAWN_TIME*1000, 0, "d", playerid);
	    for(new i=0; i<13; i++)
		{
		    if((WeaponData[playerid][i][1] > 0 || WeaponData[playerid][i][0] == 1) && WeaponData[playerid][i][0] > 0)
		    {
				new model = GetModel(WeaponData[playerid][i][0]);
				if(model != -1)
				{
				    WeaponDrop[playerid][i] = CreatePickup(model, 1, x+(floatsin(degree, degrees)*radius), y+(floatcos(degree, degrees)*radius), z);
					degree = degree + tmp;
				}
		    }
		}
	}
	return 1;
}
Reply
#10

Quote:
Originally Posted by Bobman
Посмотреть сообщение
Alright, it's very hard to explain but i'm trying my best here. So, I've got a filterscript that drops my weapons on death and it spawns weapon objects on the ground that are pickupable of my weapons. However I'm trying to create a command here so I could drop only one gun that spawns the object model on the ground (which are pickupable). I'm using the same script as onplayerdeath and I'm trying to convert it to a command that I could drop only one gun if I want to. But the problem is that when I type /dropgun it REMOVES one of my guns like it should be BUT it spawns pickupable object models on the ground of ALL my weapons and it won't remove all of my weapons, only one. So, I'm trying to make it like when I type /dropgun it removes only one of my guns and spawns it on the ground, not all of them.


Код:
command(dropgun, playerid, params[])
{
    new GunID = GetPlayerWeapon(playerid);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    RemovePlayerWeapon(playerid, GunID);
    RemovePickups(playerid);
	new Float:x, Float:y, Float:z, dropped;
	GetPlayerPos(playerid,x,y,z);
	for(new i=0; i<13; i++)
	{
	    new weapon, ammo;
	    GetPlayerWeaponData(playerid, i, weapon, ammo);
	    if((ammo > 0 || weapon == 1) && weapon != 0)
	    {
			new model = GetModel(weapon);
			if(model != -1)
			{
	        	WeaponData[playerid][i][0] = weapon;
	        	WeaponData[playerid][i][1] = ammo;
	        	OnWeaponDrop(playerid);
			}
	    }
	}
	if(dropped > 0)
	{
	    new radius;
	    if(dropped < 3) radius = 1;
		if(dropped < 6) radius = 2;             /*If you want another radius, change it here.*/
		if(dropped < 9) radius = 3;
		if(dropped > 8) radius = 4;
		new Float:degree, Float:tmp;
		degree = 360.0 / (float(dropped));
		tmp = degree;
		if(WeaponTimer[playerid] != -1) KillTimer(WeaponTimer[playerid]);
		WeaponTimer[playerid] = SetTimerEx("RemovePickups", WEAPON_RESPAWN_TIME*1000, 0, "d", playerid);
	    for(new i=0; i<13; i++)
		{
		    if((WeaponData[playerid][i][1] > 0 || WeaponData[playerid][i][0] == 1) && WeaponData[playerid][i][0] > 0)
		    {
				new model = GetModel(WeaponData[playerid][i][0]);
				if(model != -1)
				{
				    WeaponDrop[playerid][i] = CreatePickup(model, 1, x+(floatsin(degree, degrees)*radius), y+(floatcos(degree, degrees)*radius), z);
					degree = degree + tmp;
				}
		    }
		}
	}
	return 1;
}
check my first post i updated it with some code, look at it and tell me if it works.

"Edited for saying look at it, which is a bit rude xd"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)