SA-MP Forums Archive
Can't make the command work. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can't make the command work. (/showthread.php?tid=180746)



Can't make the command work. - Scriptissue - 02.10.2010

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



Re: Can't make the command work. - [L3th4l] - 02.10.2010

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



Re: Can't make the command work. - New_Player[USW] - 02.10.2010

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.


Re: Can't make the command work. - Scriptissue - 02.10.2010

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 ?


Re: Can't make the command work. - [L3th4l] - 02.10.2010

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.


Re: Can't make the command work. - Scriptissue - 02.10.2010

Thanks for your help.