Can't make the command work.
#1

I was working on a command that gives a player a random gun, everything works, but It doesn't shot the player's name, and the weapon name.
can any one check what's the problem ?
pawn Код:
CMD:gw(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");

else
{
new pID, wID, Ammo;

  new otherId;
  new sendername[MAX_PLAYER_NAME];
new gunname[32];
  new string[256];

 

if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "* User is offline!");
    {
   
     if(sscanf(params, "rii", otherId, wID, Ammo)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage: /gw [PlayerID/PartOfName] [Weapon ID] [Ammo/Quantity]");

GetWeaponName(pID,gunname,sizeof(gunname));
format(string, sizeof(string), "* You have successfully given %s Weapon ID: %s Ammo/Quantity: %d.",sendername, gunname, Ammo);
  SendClientMessage(playerid, COLOR_LIGHTRED, string);
   
 
    GivePlayerWeapon(otherId, wID, Ammo);

GetWeaponName(pID,gunname,sizeof(gunname));
GetPlayerName(playerid, sendername, sizeof(sendername)); // This is for admin name
format(string, sizeof(string), "* You have been given a %s ID:%d Ammo/Quantity: %d by Admin %s  ",gunname,  wID, Ammo, sendername );
SendClientMessage(otherId, 0xFF4646FF, string);

}

        }
    return 1;
}
Reply
#2

You already posted that same topic >.<

pawn Код:
CMD:gw(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");

    new pID, wID, Ammo, pName[MAX_PLAYER_NAME], GivenName[MAX_PLAYER_NAME];
    if(sscanf(params, "rii", pID, wID, Ammo)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /GW < PlayerID > < WeaponID > < Ammo >");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not online!");
    GivePlayerWeapon(pID, wID, Ammo);
    new Str[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(pID, GivenName, sizeof(GivenName));
    format(Str, sizeof(Str), "Admin %s has given %s weapon id %d with %d rounds of ammo.", pName, GivenName, wID, Ammo);
    SendClientMessage(playerid, COLOR_GREEN, Str);
    return 1;
}
Reply
#3

I think it should be:
pawn Код:
CMD:gw(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");

else
{
new pID, wID, Ammo;

  new otherId;
  new sendername[MAX_PLAYER_NAME];
new gunname[32];
  new string[256];

 

if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "* User is offline!");
    {
   
     if(sscanf(params, "rii", otherId, wID, Ammo)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage: /gw [PlayerID/PartOfName] [Weapon ID] [Ammo/Quantity]");

GetWeaponName(pID,gunname,sizeof(gunname));
format(string, sizeof(string), "* You have successfully given %s Weapon ID: %s Ammo/Quantity: %d.",sendername, gunname, Ammo);
  SendClientMessage(playerid, COLOR_LIGHTRED, string);
   
 
    GivePlayerWeapon(otherId, weaponID, Ammo);

GetWeaponName(pID,gunname,sizeof(gunname));
GetPlayerName(playerid, sendername, sizeof(sendername)); // This is for admin name
format(string, sizeof(string), "* You have been given a %s ID:%d Ammo/Quantity: %d by Admin %s  ",gunname,  weaponID, Ammo, sendername );
SendClientMessage(otherId, 0xFF4646FF, string);

}

        }
    return 1;
}
I'm not sure about it.
Reply
#4

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
You already posted that same topic >.<

pawn Код:
CMD:gw(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");

    new pID, wID, Ammo, pName[MAX_PLAYER_NAME], GivenName[MAX_PLAYER_NAME];
    if(sscanf(params, "rii", pID, wID, Ammo)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /GW < PlayerID > < WeaponID > < Ammo >");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not online!");
    GivePlayerWeapon(pID, wID, Ammo);
    new Str[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(pID, GivenName, sizeof(GivenName));
    format(Str, sizeof(Str), "Admin %s has given %s weapon id %d with %d rounds of ammo.", pName, GivenName, wID, Ammo);
    SendClientMessage(playerid, COLOR_GREEN, Str);
    return 1;
}
It works, but It doesn't show the name of the weapon .
can you help me with that ?
Reply
#5

pawn Код:
CMD:gw(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");

    new pID, wID, Ammo, pName[MAX_PLAYER_NAME], GivenName[MAX_PLAYER_NAME], WeapName[20];
    if(sscanf(params, "rii", pID, wID, Ammo)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /GW < PlayerID > < WeaponID > < Ammo >");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not online!");
    GivePlayerWeapon(pID, wID, Ammo);
    new Str[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(pID, GivenName, sizeof(GivenName));
    GetWeaponName(wID, WeapName, sizeof(WeapName));
    format(Str, sizeof(Str), "Admin %s has given %s weapon %s id %d with %d rounds of ammo.", pName, GivenName, WeapName, wID, Ammo);
    SendClientMessage(playerid, COLOR_GREEN, Str);
    return 1;
}
Should work.
Reply
#6

Thanks for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)