u3g_samp_change_weapon.png
Ahora podrás cambiar de arma si eres pasajero en el vehículo.
Pulsa 2 para cambiar de arma.
new
pWeapon[MAX_PLAYERS];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_PASSENGER) {
pWeapon[playerid] = GetPlayerWeapon(playerid);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys & KEY_LOOK_BEHIND) && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
new
weaponid,
weapons[13],
current_weapon = pWeapon[playerid],
current_slot = GetWeaponSlot(pWeapon[playerid]);
for (new i = 0, ammo; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i], ammo);
}
for (new i = current_slot + 1, w; i <= 5; i++)
{
w = weapons[i];
if (w == 22 || w == 25 || (w >= 29 && w <= 32)) {
weaponid = w;
break;
}
}
if (weaponid != current_weapon) {
SetPlayerArmedWeapon(playerid, pWeapon[playerid] = weaponid);
}
}
return 1;
}
stock GetWeaponSlot(weaponid) {
static const
s_weaponslots[] = {
0x00000101, 0x01010101, 0x01010A0A, 0x0A0A0A0A,
0x080808FF, 0xFFFF0202, 0x02030303, 0x04040505,
0x04060607, 0x07070708, 0x0C090909, 0x0B0B0B00
}
;
if (0 <= weaponid <= 46)
return s_weaponslots{weaponid} == 0xFF ? -1 : s_weaponslots{weaponid};
return -1;
}