SA-MP Forums Archive
Trouble with Ammo-Array - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Trouble with Ammo-Array (/showthread.php?tid=147897)



Trouble with Ammo-Array - Jonni8 - 14.05.2010

Hi, I wanted to make an arry which contains the ammo of each player.

so i tried this:
Код:
new gAmmo[MAX_PLAYERS];
/* ... */
public OnGameModeInit()
{
AddPlayerClass(0,1438.4336,-926.9862,39.6477,168.6258,24,20,18,10,0,0); //spawn CJ
AddPlayerClass(102, 1318.6892,-901.4059,39.5781,179.3070,24,20,39,10,0,0); //spawn Balla
AddPlayerClass(107, 1334.2068,-984.2917,33.8966,262.7202,24,20,16,10,0,0); //spawn Grove

gAmmo[playerid] = 20;
}

/* ... */

GivePlayerWeapon(playerid, 24, gAmmo[playerid]);
here is the result of compiling:
Код:
C:\Users\Jonni\Desktop\SA-MP Server\gamemodes\TheKillerzBeta.pwn(80) : error 017: undefined symbol "playerid"
any idea?


Re: Trouble with Ammo-Array - Assyria - 14.05.2010

Where are you using this: "GivePlayerWeapon(playerid, 24, gAmmo[playerid]);"?


Re: Trouble with Ammo-Array - Killa_ - 14.05.2010

Put gAmmo[playerid] = 20; in OnPlayerConnect


Re: Trouble with Ammo-Array - Jonni8 - 14.05.2010

@thanks for help
now it works.

Quote:
Originally Posted by Assyria
Where are you using this: "GivePlayerWeapon(playerid, 24, gAmmo[playerid]);"?
I use it in a command.


Re: Trouble with Ammo-Array - Jonni8 - 14.05.2010

ok, now it works almost fine, but usually the ammo should get increased by 20 but it gets increased by 40 oO

here the code:
Код:
else if (!strcmp(cmdtext, "/waffe kaufen", true))
	{
			if (GetPlayerMoney(playerid) < 300)
			{
				SendClientMessage(playerid, RED, "Du hast nicht genug Geld.");
			}	
			else 
			{
				gAmmo[playerid] += 20;
				GivePlayerMoney(playerid, -300);
				SendClientMessage(playerid, GREEN, "Du hast dir eine Desert Eagle gekauft");
				GivePlayerWeapon(playerid, 24, gAmmo[playerid]);
			}
		return 1;
	}



Re: Trouble with Ammo-Array - Killa_ - 14.05.2010

Try gAmmo[playerid] = gAmmo[playerid] + 20;


Re: Trouble with Ammo-Array - Jonni8 - 14.05.2010

Hm still same thing.
but i tried it a few more times.
first time i get +40 ammo, second time, +60...


Re: Trouble with Ammo-Array - Killa_ - 14.05.2010

Thats wht its doing, increasing by 20 each time, so whats the problem? first it is 20 then you add another 20 = 40 + 20 = 60.


Re: Trouble with Ammo-Array - Jonni8 - 15.05.2010

no.
i listed how much it gets increased.
so its too much.
just want +20, +20, +20.....


Re: Trouble with Ammo-Array - Jonni8 - 15.05.2010

please help