Trouble with Ammo-Array
#1

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?
Reply
#2

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

Put gAmmo[playerid] = 20; in OnPlayerConnect
Reply
#4

@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.
Reply
#5

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;
	}
Reply
#6

Try gAmmo[playerid] = gAmmo[playerid] + 20;
Reply
#7

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

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.
Reply
#9

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

please help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)