Weapon Loop
#1

How do I loop to all the player's weapons, and put all of their names in a dialog. Here's all of my resources, but I still don't know how to use them.

Weapon Loop - KingHual
Код:
new weapons[13][2];
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}

if(weapons[input the weapon slot here][0] == weapon id)
{
        //do something
}
Weapon Names - NealPeteros
Код:
new gunname1[24], gunname2[24], gunname3[24], gunname4[24], gunname5[24], gunname6[24], gunname7[24], gunname8[24], gunname9[24], gunname10[24], weapon1, weapon2, weapon3, weapon4, weapon5, weapon6, weapon7, weapon8, weapon9, weapon10;

weapon1 = PlayerInfo[playerid][pWeapon1];
weapon2 = PlayerInfo[playerid][pWeapon2];
weapon3 = PlayerInfo[playerid][pWeapon3];
weapon4 = PlayerInfo[playerid][pWeapon4];
weapon5 = PlayerInfo[playerid][pWeapon5];
weapon6 = PlayerInfo[playerid][pWeapon6];
weapon7 = PlayerInfo[playerid][pWeapon7];
weapon8 = PlayerInfo[playerid][pWeapon8];
weapon9 = PlayerInfo[playerid][pWeapon9];
weapon10 = PlayerInfo[playerid][pWeapon10];

GetWeaponName(weapon1, gunname1, sizeof(gunname1));
GetWeaponName(weapon2, gunname2, sizeof(gunname2));
GetWeaponName(weapon3, gunname3, sizeof(gunname3));
GetWeaponName(weapon4, gunname4, sizeof(gunname4));
GetWeaponName(weapon5, gunname5, sizeof(gunname5));
GetWeaponName(weapon6, gunname6, sizeof(gunname6));
GetWeaponName(weapon7, gunname7, sizeof(gunname7));
GetWeaponName(weapon8, gunname8, sizeof(gunname8));
GetWeaponName(weapon9, gunname9, sizeof(gunname9));
GetWeaponName(weapon10, gunname10, sizeof(gunname10));
Reply
#2

Something like this should do the trick. What you want is to get the weapon name in the same loop and add that to a string variable you're gonna use in a dialog.

Код:
new string[128],weaponName[24];
new weapon,ammo;

for (new i = 0; i < 13; i++) {
	GetPlayerWeaponData(playerid, i, weapon, ammo);
	if(weapon != 0) {
		GetWeaponName(weapon, weaponName, sizeof(weaponName));
		strcat(string, weaponName);
		strcat(string, "\n");
	}
}
//Show dialog by using the variable string.
Reply
#3

Works, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)