give gun command
#1

How to make an admin give gun command, like example /givegun (ammo) (weapon id/name) ?
Reply
#2

here you go

you need
pawn Код:
#include <sscanf2>
#include <zcmd>
pawn Код:
CMD:giveweapon(playerid, params[])
{
    new tmp[256];

    new lookupid, weapon, wname[64], ammo;
    if(IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "uii",lookupid, weapon, ammo))
        return SendClientMessage(playerid, COLOR_YELLOW, "/givewepon <playerid> <gunid> <ammo>");

        if (!IsPlayerConnected(lookupid)) { return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected."); }

        if (weapon < 1 || weapon > 46)
        return SendClientMessage(playerid, COLOR_YELLOW, "Invalid weapon ID, valid id's are between 0 and 46");

        GivePlayerWeapon(lookupid, weapon, ammo);

        GetWeaponName(weapon, wname, 64);

        format(tmp, sizeof(tmp), "Admin %s (ID:%d) gave %s (ID:%d) a %s with %d ammo", GetName(playerid), playerid, GetName(lookupid), lookupid, wname, ammo);
        SendClientMessageToAll(COLOR_YELLOW, tmp);

        format(tmp, sizeof(tmp), "Admin %s (ID:%d) gave you a %s with %d ammo", GetName(playerid), playerid, wname, ammo);
        SendClientMessage(lookupid, COLOR_YELLOW, tmp);
    }
    return 1;
}
Reply
#3

Thanks but how did you defined

Код:
GetName
Reply
#4

here you go
pawn Код:
stock GetName(playerid)
{
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    return PlayerName;
}
Reply
#5

pawn Код:
CMD:givegun(playerid, params[])
{
        if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
        if(sscanf(params, "ud", target, gun)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /givegun <playerid> <gun>");
        if(gun < 1 || gun > 47) return SendClientMessage(playerid, COLOR_GREY, "Don't go below 1 or above 47.");
        if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_GREY, "User is not connected!");
        if(gun != 21)
        {
            GivePlayerWeapon(target, gun, 50000); //Your version would be GivePlayerValidWeapon, this also may be causing issues.
             format(string, sizeof(string), "Admin %s has given you a weapon.", GetName(playerid));
             SendClientMessage(target, COLOR_GREY, string);
             format(string, sizeof(string), "You have given %s a weapon.", GetName(target));
             SendClientMessage(playerid, COLOR_GREY, string);
        }
        return 1;
}
Reply
#6

Thanks, but I am getting 4 errors on the same line

Код:
(13833) : error 012: invalid function call, not a valid address
(13833) : warning 215: expression has no effect
(13833) : error 001: expected token: ";", but found ")"
(13833) : error 029: invalid expression, assumed zero
(13833) : fatal error 107: too many error messages on one line
This is that line

Код:
format(tmp, sizeof(tmp), "Admin %s (ID:%d) gave %s (ID:%d) a %s with %d ammo", PlayerName(playerid), playerid, PlayerName(lookupid), lookupid, wname, ammo);
Reply
#7

Quote:
Originally Posted by Clad
Посмотреть сообщение
pawn Код:
CMD:givegun(playerid, params[])
{
        if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
        if(sscanf(params, "ud", target, gun)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /givegun <playerid> <gun>");
        if(gun < 1 || gun > 47) return SendClientMessage(playerid, COLOR_GREY, "Don't go below 1 or above 47.");
        if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_GREY, "User is not connected!");
        if(gun != 21)
        {
            GivePlayerWeapon(target, gun, 50000); //Your version would be GivePlayerValidWeapon, this also may be causing issues.
             format(string, sizeof(string), "Admin %s has given you a weapon.", GetName(playerid));
             SendClientMessage(target, COLOR_GREY, string);
             format(string, sizeof(string), "You have given %s a weapon.", GetName(target));
             SendClientMessage(playerid, COLOR_GREY, string);
        }
        return 1;
}
How do I define
Код:
(13818) : error 017: undefined symbol "target"
(13819) : error 017: undefined symbol "gun"
(13820) : error 017: undefined symbol "target"
(13821) : error 017: undefined symbol "gun"
(13823) : error 017: undefined symbol "target"
(13824) : error 017: undefined symbol "string"
C:\Users\Atti\Desktop\server\gamemodes\PPC_Trucking.pwn(13824) : error 017: undefined symbol "string"
Reply
#8

pawn Код:
new string[128], gun, target;
Reply
#9

pawn Код:
new string[128], targer, gun;
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)