SA-MP Forums Archive
give gun command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: give gun command (/showthread.php?tid=550929)



give gun command - Jhony_Blaze - 15.12.2014

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


Re: give gun command - JeaSon - 15.12.2014

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;
}



Re: give gun command - Jhony_Blaze - 15.12.2014

Thanks but how did you defined

Код:
GetName



Re: give gun command - JeaSon - 15.12.2014

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



Re: give gun command - Clad - 15.12.2014

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;
}



Re: give gun command - Jhony_Blaze - 15.12.2014

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);



Re: give gun command - Jhony_Blaze - 15.12.2014

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"



Re: give gun command - JeaSon - 15.12.2014

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



Re: give gun command - Clad - 15.12.2014

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