Jump to content

Recommended Posts

  • 1 year later...
Posted

CMD:givegun(playerid, params[]) {

    new adminLevel = GetPlayerAdminLevel(playerid);

    if (adminLevel < 1) {

        SendClientMessage(playerid, COLOR_RED, "You need to be an admin (level 1 or higher) to use this command."); // poti modifica din admin 1 in ce admin vrei tu

        return 1;

    }

 

    if (params[0] < 0 || params[0] >= MAX_PLAYERS || !IsPlayerConnected(params[0])) {

        SendClientMessage(playerid, COLOR_RED, "Invalid player ID. Please specify a valid online player.");

        return 1;

    }

 

    new gunid, ammo;

 

    if (sscanf(params, "ui", gunid, ammo)) {

        if (gunid < 0 || gunid >= MAX_WEAPONS) {

            SendClientMessage(playerid, COLOR_RED, "Invalid weapon ID. Please specify a valid weapon ID.");

            return 1;

        }

 

        if (ammo < 0) {

            SendClientMessage(playerid, COLOR_RED, "Invalid ammo amount. Please specify a non-negative value.");

            return 1;

        }

 

        GivePlayerWeapon(params[0], gunid, ammo);

        SendClientMessage(playerid, COLOR_GREEN, "You've given weapon ID: " + gunid + " with " + ammo + " ammo to player ID: " + params[0]);

    } else {

        SendClientMessage(playerid, COLOR_RED, "Usage: /givegun [playerid] [gunid] [ammo]");

    }

    return 1;

}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.