SA-MP Forums Archive
Ammo Problem - 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: Ammo Problem (/showthread.php?tid=652490)



Ammo Problem - bookknp - 12.04.2018

when I pick up a weapon, it gives me as max ammunition as possible instead of adding the ammunition of this weapon, someone could help me??

Код:
public DropPlayerWeapons(playerid)
{

    
	new playerweapons[13][2];
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid, x, y, z);

	for(new i=0; i<13; i++)
	{
    	GetPlayerWeaponData(playerid, i, playerweapons[i][0], playerweapons[i][1]);
    	new model = GetWeaponModel(playerweapons[i][0]);
		new times = floatround(playerweapons[i][1]/10.0001);
    	new Float:X = x + (random(3) - random(3));
    	new Float:Y = y + (random(3) - random(3));
    	if(playerweapons[i][1] != 0 && model != -1)
		{
		    if(times > DropLimit) times = DropLimit;
	    	for(new a=0; a<times; a++)
			{
				new pickupid = CreatePickup(model, 3, X, Y, z);
				SetTimerEx("DeletePickup", DeleteTime*1000, false, "d", pickupid);
			}
		}
	}
    new weap[2];
	SetPlayerAmmo(playerid, GivePlayerWeapon(playerid,weap[0], 20), weap[1]+20); // <--------- error??

	return 1;
}


//----------------------------------------------------------
public DeletePickup(pickupid)
{
   	DestroyPickup(pickupid);
	return 1;
}

GetWeaponModel(weaponid)
{
	switch(weaponid)
	{
	    case 1: return 331; case 2: return 333; case 3: return 334;
		case 4: return 335; case 5: return 336; case 6: return 337;
		case 7: return 338; case 8: return 339; case 9: return 341;
		case 10: return 321; case 11: return 322; case 12: return 323;
		case 13: return 324; case 14: return 325; case 15: return 326;
		case 16: return 342; case 17: return 343; case 18: return 344;
		case 22: return 346; case 23: return 347; case 24: return 348;
		case 25: return 349; case 26: return 350; case 27: return 351;
		case 28: return 352; case 29: return 353; case 30: return 355;
		case 31: return 356; case 32: return 372; case 33: return 357;
		case 34: return 358; case 35: return 359; case 36: return 360;
		case 37: return 361; case 38: return 362; case 39: return 363;
		case 41: return 365; case 42: return 366; case 46: return 371;
	}
	return -1;
}



Re: Ammo Problem - Mugala - 13.04.2018

so it gives u 20 bullet or ?


Re: Ammo Problem - bookknp - 13.04.2018

Quote:
Originally Posted by Mugala
Посмотреть сообщение
so it gives u 20 bullet or ?
Hi guy, it give 400 ammo and i want give 20 ammo


Re: Ammo Problem - Mugala - 13.04.2018

than remove weap[1] from code, like this - SetPlayerAmmo(playerid, GivePlayerWeapon(playerid,weap[0], 20), 20);


Re: Ammo Problem - bookknp - 13.04.2018

Quote:
Originally Posted by Mugala
Посмотреть сообщение
than remove weap[1] from code, like this - SetPlayerAmmo(playerid, GivePlayerWeapon(playerid,weap[0], 20), 20);
I got 400 bullets again, anything my code is a error??


Re: Ammo Problem - Mugala - 13.04.2018

I don't think that there is error, I think that problem must be in somewhere else, not here.
try order scripts like this:

GivePlayerWeapon(playerid,weap[0], 20);
SetPlayerAmmo(playerid,weap[0], 20);


Re: Ammo Problem - bookknp - 13.04.2018

Quote:
Originally Posted by Mugala
Посмотреть сообщение
I don't think that there is error, I think that problem must be in somewhere else, not here.
try order scripts like this:

GivePlayerWeapon(playerid,weap[0], 20);
SetPlayerAmmo(playerid,weap[0], 20);
it still give 400 bullets, damn it


Re: Ammo Problem - Mugala - 13.04.2018

dude, you're setting it's ammo to 20, there is no other way to change, I think that you have another code which sets the weapons ammo to 400 or, weap[0] is not a correct weapon which we want to change.