help with scripting this!
#1

Hi I want to make if person have gun id 27 it automatically remove it and replace it with M4 anyone can do that?!
Reply
#2

PHP код:
public OnPlayerUpdate(playerid)
{
if(
GetPlayerWeapon(playerid) == 27)
{
GivePlayerWeapon(playerid,270);
GivePlayerWeapon(playerid,31,5000);//amount of ammo you want replace it with 5000
}
    return 
1;

Try this
Reply
#3

PHP код:
stock RemovePlayerWeapon(playeridpweaponid)
{
        new 
plyWeapons[12];
        new 
plyAmmo[12];
 
        for(new 
slot 0slot != 12slot++)
        {
                new 
pweppammo;
                
GetPlayerWeaponData(playeridslotpweppammo);
 
                if(
pwep != pweaponid)
                {
                        
GetPlayerWeaponData(playeridslotplyWeapons[slot], plyAmmo[slot]);
                }
        }
 
        
ResetPlayerGuns(playerid);
        for(new 
slot 0slot != 12slot++)
        {
                
GivePlayerGun(playeridplyWeapons[slot], plyAmmo[slot]);
        }

PHP код:
public OnPlayerUpdate(playerid)
{
    new 
weaponammo;
    
GetPlayerWeaponData(playerid3weaponammo);
    if(
weapon==27)
    {
         
RemovePlayerWeapon(playerid27);
         
GivePlayerWeapon(playeridWEAPON_M4100);
    }

Reply
#4

Thanks both of you! +REP
Reply
#5

Quote:
Originally Posted by nezo2001
Посмотреть сообщение
PHP код:
public OnPlayerUpdate(playerid)
{
if(
GetPlayerWeapon(playerid) == 27)
{
GivePlayerWeapon(playerid,270);
GivePlayerWeapon(playerid,31,5000);//amount of ammo you want replace it with 5000
}
    return 
1;

Try this
Giving player 0 ammo doesn't remove his current weapon.
Also, your code gets the weapon that he is holding in his hand not the one he posses.
Reply
#6

Ok but it will work when the player get the weapon and when the player get the weapon the weapon become in his hand !
Reply
#7

Quote:
Originally Posted by nezo2001
Посмотреть сообщение
Ok but it will work when the player get the weapon and when the player get the weapon the weapon become in his hand !
But it wont remove the weapon as weapon id 27 and M4 are in different slots.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)