Question about arrays
#3

Quote:
Originally Posted by Outbreak
I've got a spawn weapons feature, and im trying to create something to see what weapons each player has...

The weapons are stored in an array, im wondering is it possible to store, 12 weapons in an array, all with varying ammo..

Then use another function to extract the info on what weapons the player has...
I've already got a command to see what weapons the player is carrying.. This isnt what im asking...

I want to store weapon info in 1 array, then be able to extract the info and display it as weapons id and ammo amount.

Is it possible?
Yes, this is a simpler way than Panda's imo

pawn Code:
new Ammo[12];
new Wep[12];
new WepName[12][20];
for(new i = 0; i < 12; i++)
{
  GetPlayerWeaponData(idx, i+1, Wep[i], Ammo[i]);
  GetWeaponName(Wep[i], WepName[i], 20);
}
Ammo = Weapon Ammo
Wep = Weapon ID
WepName = Weapon Name

the number inside [] is the slot

so if you want the ammo of the weapon is slot 5

Ammo[5]

The reason why it only goes to 12 is because in GetPlayerWeaponData I use +1
so it skips slot 0 because it's bugged and will go to 13 too


p.s credits to seifs admin script for helping me figure this out when I needed it a while ago
Reply


Messages In This Thread
Question about arrays - by Outbreak - 23.04.2009, 20:32
Re: Question about arrays - by Think - 23.04.2009, 20:37
Re: Question about arrays - by lavamike - 23.04.2009, 20:38
Re: Question about arrays - by Outbreak - 23.04.2009, 21:16
Re: Question about arrays - by Think - 23.04.2009, 21:20
Re: Question about arrays - by 1337pr0 - 23.04.2009, 22:56

Forum Jump:


Users browsing this thread: 1 Guest(s)