What it's wrong with this ?
#1

pawn Код:
CMD:giveweapon(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] >= 1)
    {
        new ID;
        new GUN;
        new AMMO;
        if(sscanf(params,"i", ID, GUN, AMMO)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/GiveWeapon [ID] [Gun ID/Part Of Name] [Ammo]");
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave a gun to specified player !");
        GivePlayerWeapon(ID, GUN, AMMO);
    }
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}ERROR: {15FF00}You are not authorized to use this command !");
    }
    return 1;
}

- No errors when I compile, when I enter in server, and write : /GiveWeapon 0, it's appear that message : You gave a gun to specified player, but I still don't get any gun !

- Fix?
Reply
#2

This:
Код:
if(sscanf(params,"i", ID, GUN, AMMO)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/GiveWeapon [ID] [Gun ID/Part Of Name] [Ammo]");
You need to get 3 variables out of params, and you only took 1.
Код:
if(sscanf(params,"iii", ID, GUN, AMMO)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/GiveWeapon [ID] [Gun ID/Part Of Name] [Ammo]");
Reply
#3

Quote:
Originally Posted by dominik523
Посмотреть сообщение
This:
Код:
if(sscanf(params,"i", ID, GUN, AMMO)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/GiveWeapon [ID] [Gun ID/Part Of Name] [Ammo]");
You need to get 3 variables out of params, and you only took 1.
Код:
if(sscanf(params,"iii", ID, GUN, AMMO)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/GiveWeapon [ID] [Gun ID/Part Of Name] [Ammo]");
Thank you for help. + Rep.
Reply
#4

I fixed it for you. The problem was, when you didn't put the required amount of data types in the sscanf section (you just had an i). I also neatened your code up a little bit for you

pawn Код:
CMD:giveweapon(playerid,params[])
{
    new ID,GUN,AMMO;
    if(sscanf(params,"udd", ID, GUN, AMMO)) return SendClientMessage(playerid,-1,"{FF0000}AdmUsage: {15FF00}/GiveWeapon [ID] [Gun ID/Part Of Name] [Ammo]");
    if(PlayerInfo[playerid][Admin] < 1) return SendClientMessage(playerid,-1,"{FF0000}You Must Be An Admin To Use This Command.");
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}AdmCmd: {15FF00}You gave a gun to specified player !");
        GivePlayerWeapon(ID, GUN, AMMO);
    }
    return 1;
}
EDIT: I see someone beat me to it as I was replying.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)