SA-MP Forums Archive
What it's wrong with this ? - 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: What it's wrong with this ? (/showthread.php?tid=544329)



What it's wrong with this ? - HY - 01.11.2014

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?


Re: What it's wrong with this ? - dominik523 - 01.11.2014

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



Re: What it's wrong with this ? - HY - 01.11.2014

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.


Re: What it's wrong with this ? - Banana_Ghost - 01.11.2014

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.