GivePlayerWeapon help
#1

Hi sa:mp community. I have a problem with GivePlayerWeapon. When i executes the command, i dont get the gun. Thanks in advance.

pawn Код:
command(agiveweapon, playerid, params[])
{
    new WeaponN[ 60 ], Names[ 2 ][ MAX_PLAYER_NAME ], string[ 128 ], id, weaponid, ammo;
    if( sscanf( params, "ud", id, weaponid ) )
    {
        if( Player[playerid][AdminLevel] >= 3 )
        {
            SendClientMessage( playerid, SYNTAXMSG, "SYNTAX: /agiveweapon [playerid] [weaponid] [ammo] " );
        }
    }
    else
    {
        if( Player[playerid][AdminLevel] >= 3)
        {
            if(IsPlayerConnectedEx(id) )
            {
                if(weaponid >= 1 && weaponid < 47)
                {
               
                    GetPlayerName( id, Names[ 0 ], MAX_PLAYER_NAME );
                    GetPlayerName( playerid, Names[ 1 ], MAX_PLAYER_NAME );
                   
                    if(weaponid == 19)
                    {
                        SetPlayerSpecialAction(id, SPECIAL_ACTION_USEJETPACK);
                        format( string, sizeof( string ), "You have given %s a Jetpack (Weapon ID: 19).", GetName(id), weaponid);
                        SendClientMessage( playerid, WHITE, string);
                        format( string, sizeof( string ), "You have been given a Jetpack, from %s. ", GetName( playerid ) );
                        SendClientMessage(id, WHITE, string);
                        Player[id][HasJetpack] = 1;
                       
                        format( string, sizeof( string ), "%s has been given weapon %d by %s.", Names[ 0 ], weaponid, Names[ 1 ] );
                        AdminActionsLog( string );
                        format( string, sizeof( string ), "[ADMINMSG:] %s gave a Jetpack to %s.", Names[ 0 ], Names[ 1 ] );
                        SendToAdmins( ADMINACTION, string, 0 );
                    }
                    else
                    {
                        GetWeaponName(weaponid, WeaponN, sizeof(WeaponN) );
                        GivePlayerWeapon(id, weaponid, ammo );
                        format( string, sizeof( string ), "You have given %s a %s (Weapon ID: %d).", GetName(id), WeaponN, weaponid);
                        SendClientMessage( playerid, WHITE, string);
                        format( string, sizeof( string ), "You have been given a %s, from %s.", WeaponN, GetName( playerid ) );
                        SendClientMessage(id, WHITE, string);

                        format( string, sizeof( string ), "%s has been given weapon %d by %s.", Names[ 0 ], weaponid, Names[ 1 ] );
                        AdminActionsLog( string );
                        format( string, sizeof( string ), "[ADMINMSG:] %s gave a %d(%s ,%d ) to %d.", Names[ 1 ], WeaponN, weaponid, ammo, GetName(id), Names[ 0 ] );
                        SendToAdmins( ADMINACTION, string, 0 );
                    }
                }
                else
                {
                    SendClientMessage( playerid, SYNTAXMSG, "Invalid weapon ID." );
                }
            }
            else
            {
                SendClientMessage( playerid, SYNTAXMSG, "That player is not connected or isn't logged in." );
            }
        }
        else
        {
            SendClientMessage( playerid, SYNTAXMSG, "You are not authroized to use that command." );
        }
    }
    return 1;
}
Reply
#2

It would appear that you're never storing any information for the amount of ammunation you're giving the player, so the variable "ammo" will always be 0, therefore the gun given to the player will have no ammunation and therefore be lost. This is what you may be looking for to fix it.

pawn Код:
if( sscanf( params, "udd", id, weaponid,ammo ) )
Reply
#3

Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)