Help me code
#1

Guns with bullets 0 still hold guns.
Every time you make 30 ammo.
The ride is about 1 ammo. help me
thanks

pAmmo[9],

RemovePlayerWeapon(playerid, weaponid)
{
ResetPlayerWeapons(playerid);
PlayerInfo[playerid][pGuns][GetWeaponSlot(weaponid)] = 0;
PlayerInfo[playerid][pAmmo][GetWeaponSlot(weaponid)-1] = 0;
SetPlayerWeaponsEx(playerid);
return 1;
}

forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(GetPVarInt(playerid, "IsInArena") == -1)
{
if(GetPVarInt( playerid, "EventToken") == 0)
{
switch(weaponid)
{
case 16, 17, 18, 39: // SATCHEL, GRENADE, TEARGAS, MOLTOV
{
if(PlayerInfo[playerid][pAmmo][ 7 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 7 ] -= 1;

}
}
case 22, 23, 24: // 9mm, sdpid, DE
{
if(PlayerInfo[playerid][pAmmo][ 1 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 1 ] -= 1;
}
}
case 25,26,27: // Shotgun, spawn-off, combat shotgun
{
if(PlayerInfo[playerid][pAmmo][ 2 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 2 ] -= 1;
}
}
case 28,29,32: // Uzi, Tec9, Mp5
{
if(PlayerInfo[playerid][pAmmo][ 3 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 3 ] -= 1;
}
}
case 30,31: // M4, Ak 47
{
if(PlayerInfo[playerid][pAmmo][ 4 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 4 ] -= 1;
}
}
case 33,34: // rifle, sniper
{
if(PlayerInfo[playerid][pAmmo][ 5 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 5 ] -= 1;
}
}
case 35,36,37,38: // Bazoka, RPG, Firegun, minigun
{
if(PlayerInfo[playerid][pAmmo][ 6 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 6 ] -= 1;
}
}
case 40,41,42,43: // SPRAYCAN, FIREEXTINGUISHER, CAMERA
{
if(PlayerInfo[playerid][pAmmo][ 8 ] > 0)
{
PlayerInfo[playerid][pAmmo][ 8 ] -= 1;
}
}
}
}
}
return 1;
}

stock GetWeaponSlot(weaponid)
{
switch( weaponid )
{
case 0, 1: // none
{
return 0;
}
case 2, 3, 4, 5, 6, 7, 8, 9: // can chien
{
return 1;
}
case 22, 23, 24: // 9mm, sdpistol, deagle - Ammo1
{
return 2;
}
case 25, 26, 27: // shotgun, spas12, spawn-off -Ammo2
{
return 3;
}
case 28, 29, 32: // mp5,uzi.. Ammo3
{
return 4;
}
case 30, 31: // ak47 m4a1 Ammo4
{
return 5;
}
case 33, 34: // sniper rifle Ammo5
{
return 6;
}
case 35, 36, 37, 38: // baroka, minigun, laucher.. Ammo6
{
return 7;
}
case 16, 17, 18, 39, 40: // boom Ammo7
{
return 8;
}
case 41, 42, 43: // spraycan, camera... Ammo8
{
return 9;
}
case 10, 11, 12, 13, 14, 15: // sex toy bla bla
{
return 10;
}
case 44, 45, 46: // none
{
return 11;
}
}
return -1;
}





help me
Reply
#2

help me
Reply
#3

OMG please put your code between, [code] tags next time.

Код:
for(new i=0;i<9;i++)
{
     if(PlayerInfo[playerid][pAmmo][i] == 0)
              PlayerInfo[playerid][pGun][i] = 0;

     SetPlayerWeaponEx(playerid);
}
Isnt it more readable? ^^
Put it under OnPlayerUpdate or under a function using which you can remove the weapon.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)